From 62d95e30e8d0b478e4a6c6b90fd0394c5a98e627 Mon Sep 17 00:00:00 2001 From: John Haxby Date: Wed, 9 Dec 2015 16:30:22 +1100 Subject: [PATCH] ocfs2: return non-zero st_blocks for inline data Some versions of tar assume that files with st_blocks == 0 do not contain any data and will skip reading them entirely. See also commit 9206c561554c ("ext4: return non-zero st_blocks for inline data"). Signed-off-by: John Haxby Reviewed-by: Mark Fasheh Cc: Joel Becker Acked-by: Gang He Reviewed-by: Junxiao Bi Signed-off-by: Andrew Morton (cherry picked from commit ca426103429543e7a9be9017537fc3ffc37b5724) Orabug: 22218243 Signed-off-by: John Haxby --- fs/ocfs2/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index cbb2ccdb326a..19cf01b958ab 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -1294,6 +1294,14 @@ int ocfs2_getattr(struct vfsmount *mnt, } 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 don't incorrectly think the file is completely sparse. + */ + if (unlikely(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) + stat->blocks += (stat->size + 511)>>9; /* We set the blksize from the cluster size for performance */ stat->blksize = osb->s_clustersize; -- 2.50.1