mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
btrfs: fix stat blocks accounting
Round inode bytes and delalloc bytes up to real blocksize before converting to sector size. Otherwise eg. files smaller than 512 are reported with zero blocks due to incorrect rounding. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
52621cb6ed
commit
fadc0d8be4
1 changed files with 4 additions and 2 deletions
|
@ -6794,11 +6794,13 @@ static int btrfs_getattr(struct vfsmount *mnt,
|
|||
struct dentry *dentry, struct kstat *stat)
|
||||
{
|
||||
struct inode *inode = dentry->d_inode;
|
||||
u32 blocksize = inode->i_sb->s_blocksize;
|
||||
|
||||
generic_fillattr(inode, stat);
|
||||
stat->dev = BTRFS_I(inode)->root->anon_dev;
|
||||
stat->blksize = PAGE_CACHE_SIZE;
|
||||
stat->blocks = (inode_get_bytes(inode) +
|
||||
BTRFS_I(inode)->delalloc_bytes) >> 9;
|
||||
stat->blocks = (ALIGN(inode_get_bytes(inode), blocksize) +
|
||||
ALIGN(BTRFS_I(inode)->delalloc_bytes, blocksize)) >> 9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue