aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Dilger <andreas.dilger@intel.com>2013-11-11 22:38:12 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-11-11 22:38:12 -0500
commit9206c561554c948111d3cf6fc563a0beaaf790b3 (patch)
tree0ae1b0bd79963fb9bc3b608581f9b5d6ad6d9efd
parentdd1f723bf56bd96efc9d90e9e60dc511c79de48f (diff)
ext4: return non-zero st_blocks for inline data
Return a non-zero st_blocks to userspace for statfs() and friends. Some versions of tar will assume that files with st_blocks == 0 do not contain any data and will skip reading them entirely. Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/inode.c14
1 files changed, 11 insertions, 3 deletions
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
@@ -4694,6 +4694,15 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
4694 generic_fillattr(inode, stat); 4694 generic_fillattr(inode, stat);
4695 4695
4696 /* 4696 /*
4697 * If there is inline data in the inode, the inode will normally not
4698 * have data blocks allocated (it may have an external xattr block).
4699 * Report at least one sector for such files, so tools like tar, rsync,
4700 * others doen't incorrectly think the file is completely sparse.
4701 */
4702 if (unlikely(ext4_has_inline_data(inode)))
4703 stat->blocks += (stat->size + 511) >> 9;
4704
4705 /*
4697 * We can't update i_blocks if the block allocation is delayed 4706 * We can't update i_blocks if the block allocation is delayed
4698 * otherwise in the case of system crash before the real block 4707 * otherwise in the case of system crash before the real block
4699 * allocation is done, we will have i_blocks inconsistent with 4708 * allocation is done, we will have i_blocks inconsistent with
@@ -4704,9 +4713,8 @@ int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
4704 * blocks for this file. 4713 * blocks for this file.
4705 */ 4714 */
4706 delalloc_blocks = EXT4_C2B(EXT4_SB(inode->i_sb), 4715 delalloc_blocks = EXT4_C2B(EXT4_SB(inode->i_sb),
4707 EXT4_I(inode)->i_reserved_data_blocks); 4716 EXT4_I(inode)->i_reserved_data_blocks);
4708 4717 stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits - 9);
4709 stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits-9);
4710 return 0; 4718 return 0;
4711} 4719}
4712 4720