<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 1 Dec 2015, at 07:08, Junxiao Bi &lt;<a href="mailto:junxiao.bi@oracle.com" class="">junxiao.bi@oracle.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On 11/25/2015 05:07 AM, John Haxby wrote:</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Some versions of tar assume that files with st_blocks == 0 do not<br class="">contain any data and will skip reading them entirely. See also<br class="">commit 9206c561554c ("ext4: return non-zero st_blocks for inline data").<br class=""><br class="">Signed-off-by: John Haxby &lt;<a href="mailto:john.haxby@oracle.com" class="">john.haxby@oracle.com</a>&gt;<br class="">---<br class="">fs/ocfs2/file.c | 8 ++++++++<br class="">1 file changed, 8 insertions(+)<br class=""><br class="">diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c<br class="">index 0e5b451..d631279 100644<br class="">--- a/fs/ocfs2/file.c<br class="">+++ b/fs/ocfs2/file.c<br class="">@@ -1302,6 +1302,14 @@ int ocfs2_getattr(struct vfsmount *mnt,<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>generic_fillattr(inode, stat);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>/*<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space">&nbsp;</span>* If there is inline data in the inode, the inode will normally not<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space">&nbsp;</span>* have data blocks allocated (it may have an external xattr block).<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space">&nbsp;</span>* Report at least one sector for such files, so tools like tar, rsync,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space">&nbsp;</span>* others don't incorrectly think the file is completely sparse.<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space">&nbsp;</span>*/<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>if (unlikely(OCFS2_I(inode)-&gt;ip_dyn_features &amp; OCFS2_INLINE_DATA_FL))<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">        </span>stat-&gt;blocks += (stat-&gt;size + 511)&gt;&gt;9;<br class=""></blockquote><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">From filesystem side, looks reasonable that data block is 0 for</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">inlined-data file. This is like a hack to filesystem to fix tools issue.</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Indeed tar-1.26-27 have been fixed to not think file with st_blocks == 0</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">empty. But I am not sure why ext4 merge that fix.</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div>It’s not just tar and it’s not just ext4. &nbsp; Programmers not unreasonably assume that a file occupying zero blocks contains no data (where would you put it?)</div><div><br class=""></div><div>ext4, btrfs and ntfs-3g all give inlined files a non-zero block size to avoid surprising programmers. &nbsp; There’s nothing in Posix that says what stat’s st_blocks so in this case it’s right for the file systems in question to stick to the principle of least surprise. &nbsp;In this case, it would be surprising if some small files suddenly started occupying no space while being non-empty. &nbsp; It’s not as though it would be consistent: some small files would occupy space and some would not. &nbsp;We want to present a consistent view of files to the user. &nbsp;It’s not as though we’re breaking du either: it already tells lies :)</div><div><br class=""></div><div>Does that make sense now?</div><div><br class=""></div><div>jch</div><div><br class=""></div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thanks,</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Junxiao.</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>/* We set the blksize from the cluster size for performance */<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>stat-&gt;blksize = osb-&gt;s_clustersize;</blockquote></div></blockquote></div><br class=""></body></html>