<html><body bgcolor="#FFFFFF"><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">On 2011-04-17, at 6:40 PM, Dave Chinner &lt;<a href="mailto:david@fromorbit.com">david@fromorbit.com</a>&gt; wrote:</span></div><div></div><blockquote type="cite"><div><span>On Sat, Apr 16, 2011 at 08:21:28AM -0400, Theodore Tso wrote:</span><blockquote type="cite"><span>On Apr 16, 2011, at 1:11 AM, Andreas Dilger wrote:</span></blockquote><blockquote type="cite"><blockquote type="cite"><span>In that case, it means cp should just always use FIEMAP_FLAG_SYNC, which is fine. </span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Except that if someone is copying a large delay allocated file, it will cause </span><br></blockquote><blockquote type="cite"><span>the file to immediately snapped to disk, which might not be the greatest</span><br></blockquote><blockquote type="cite"><span>thing in the world. </span><br></blockquote><span></span><br><span>Obvious workaround - if the initial fiemap call shows unwritten</span><br><span>extents, redo it with the sync flag set. Though that assumeŃ• that</span><br><span>you can trust things like delalloc extents to only cover the range</span><br><span>that valid data exists in. Which, of course, you can't assume,</span><br><span>either. :/</span><br></div></blockquote><div><br></div>Always passing&nbsp;<span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">FIEMAP_FLAG_SYNC is fine in this case. It should only do anything if there is unwritten data, which is the only case we are concerned with at this point. &nbsp;In any case, this is a simple solution for coreutils until such a time that a more complex solution is added in the kernel (if ever).</span><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span><blockquote type="cite"><div><blockquote type="cite"><span>Christoph is write, SEEK_HOLE and SEEK_DATA are</span><br></blockquote><blockquote type="cite"><span>a much better API for what cp woulld lke to do. &nbsp;Unfortunately it hasn't</span><br></blockquote><blockquote type="cite"><span>been implemented yet in the VFS...</span><br></blockquote><span></span><br><span>Agreed, SEEK_HOLE/SEEK_DATA is the right way to solve this problem.</span><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#0023A3"><br></font></font></div></blockquote><br></div><div>I don't see how this will change the problem in any meaningful way. There will still need to be code that is traversing the on-disk mapping, and also keeping it coherent with unwritten data in the page cache.</div><div><br></div><div>Since FIEMAP already exists for most Linux filesystems, it probably makes s<span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">ense to implement SEEK_{HOLE,DATA} by calling FIEMAP to get the disk mapping in the first place.</span></div><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); "><br></span></div><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">I agree that&nbsp;</span><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">SEEK_{HOLE,DATA} is an easier programming interface, and probably what cp, tar, etc should use, once it is implemented.&nbsp;</span></div><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); "><br></span></div><div><span class="Apple-style-span" style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">Cheers, Andreas</span></div></body></html>