Skip to content

Commit

Permalink
ocfs2: return non-zero st_blocks for inline data
Browse files Browse the repository at this point in the history
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
9206c56 ("ext4: return non-zero st_blocks for inline data").

Signed-off-by: John Haxby <[email protected]>
Reviewed-by: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Acked-by: Gang He <[email protected]>
Reviewed-by: Junxiao Bi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jchax authored and torvalds committed Jan 15, 2016
1 parent 3eb5bdf commit d636462
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,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;
Expand Down

0 comments on commit d636462

Please sign in to comment.