ext4l: Fix dquot functions to update i_blocks

The dquot_alloc_block(), dquot_free_block() and dquot_alloc_block_nofail()
functions are stubs that do nothing. These functions are called by ext4
when allocating and freeing blocks, and they should update the inode's
i_blocks field.

Fix these functions to properly track block allocation in i_blocks,
which is stored in 512-byte units.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-29 07:35:38 -07:00
parent 22d24122c6
commit bd195aeed9
2 changed files with 13 additions and 1 deletions

View File

@@ -375,7 +375,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block);
/* Quota operations - stubs (only define if quotaops.h not included) */
#ifndef _LINUX_QUOTAOPS_H
#define dquot_alloc_block_nofail(inode, nr) ({ (void)(inode); (void)(nr); 0; })
#define dquot_alloc_block_nofail(inode, nr) \
({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; })
#define dquot_initialize(inode) ({ (void)(inode); 0; })
#define dquot_free_inode(inode) do { (void)(inode); } while (0)
#define dquot_alloc_inode(inode) ({ (void)(inode); 0; })

View File

@@ -669,11 +669,22 @@ void dquot_free_space_nodirty(struct inode *inode, loff_t size)
int dquot_alloc_block(struct inode *inode, loff_t nr)
{
/*
* Update i_blocks to reflect the allocated blocks.
* i_blocks is in 512-byte units, so convert from fs blocks.
*/
inode->i_blocks += nr << (inode->i_blkbits - 9);
return 0;
}
void dquot_free_block(struct inode *inode, loff_t nr)
{
/*
* Update i_blocks to reflect the freed blocks.
* i_blocks is in 512-byte units, so convert from fs blocks.
*/
inode->i_blocks -= nr << (inode->i_blkbits - 9);
}
/*