[Concept,10/15] ext4l: Fix dquot functions to update i_blocks
Commit Message
From: Simon Glass <simon.glass@canonical.com>
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>
---
fs/ext4l/ext4_uboot.h | 3 ++-
fs/ext4l/stub.c | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
@@ -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; })
@@ -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);
}
/*