X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=fs%2Fext4%2Finode.c;h=0757634741187a568cc2255187bcd2cf250d852b;hb=9206c561554c;hp=43015fa69c3a2f804ee06c83aec59f5112f7cdcf;hpb=dd1f723bf56bd96efc9d90e9e60dc511c79de48f;p=karo-tx-linux.git diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 43015fa69c3a..075763474118 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4693,6 +4693,15 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, inode = dentry->d_inode; generic_fillattr(inode, stat); + /* + * If there is inline data in the inode, the inode will normally not + * have data blocks allocated (it may have an external xattr block). + * Report at least one sector for such files, so tools like tar, rsync, + * others doen't incorrectly think the file is completely sparse. + */ + if (unlikely(ext4_has_inline_data(inode))) + stat->blocks += (stat->size + 511) >> 9; + /* * We can't update i_blocks if the block allocation is delayed * otherwise in the case of system crash before the real block @@ -4704,9 +4713,8 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, * blocks for this file. */ delalloc_blocks = EXT4_C2B(EXT4_SB(inode->i_sb), - EXT4_I(inode)->i_reserved_data_blocks); - - stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits-9); + EXT4_I(inode)->i_reserved_data_blocks); + stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits - 9); return 0; }