diff options
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0fbe678d40bb..8ca2763df091 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4231,6 +4231,32 @@ err_out: | |||
4231 | return error; | 4231 | return error; |
4232 | } | 4232 | } |
4233 | 4233 | ||
4234 | int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, | ||
4235 | struct kstat *stat) | ||
4236 | { | ||
4237 | struct inode *inode; | ||
4238 | unsigned long delalloc_blocks; | ||
4239 | |||
4240 | inode = dentry->d_inode; | ||
4241 | generic_fillattr(inode, stat); | ||
4242 | |||
4243 | /* | ||
4244 | * We can't update i_blocks if the block allocation is delayed | ||
4245 | * otherwise in the case of system crash before the real block | ||
4246 | * allocation is done, we will have i_blocks inconsistent with | ||
4247 | * on-disk file blocks. | ||
4248 | * We always keep i_blocks updated together with real | ||
4249 | * allocation. But to not confuse with user, stat | ||
4250 | * will return the blocks that include the delayed allocation | ||
4251 | * blocks for this file. | ||
4252 | */ | ||
4253 | spin_lock(&EXT4_I(inode)->i_block_reservation_lock); | ||
4254 | delalloc_blocks = EXT4_I(inode)->i_reserved_data_blocks; | ||
4255 | spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); | ||
4256 | |||
4257 | stat->blocks += (delalloc_blocks << inode->i_sb->s_blocksize_bits)>>9; | ||
4258 | return 0; | ||
4259 | } | ||
4234 | 4260 | ||
4235 | /* | 4261 | /* |
4236 | * How many blocks doth make a writepage()? | 4262 | * How many blocks doth make a writepage()? |