diff options
author | David Sterba <dsterba@suse.cz> | 2011-11-20 13:33:38 +0100 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-11-20 13:42:15 +0100 |
commit | fadc0d8be4dfca80f6c568bc5874931893c6709b (patch) | |
tree | a73dd18819b86cc14a1f01a7f58e34d94b8d84da /fs/btrfs/inode.c | |
parent | Btrfs: avoid unnecessary bitmap search for cluster setup (diff) | |
download | linux-fadc0d8be4dfca80f6c568bc5874931893c6709b.tar.xz linux-fadc0d8be4dfca80f6c568bc5874931893c6709b.zip |
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>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e16215f480d0..8ad26b135a1c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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; } |