<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,sans-serif">On Thu, Apr 21, 2016 at 10:13 PM, Eric Sandeen </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:sandeen@sandeen.net" target="_blank">sandeen@sandeen.net</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 4/21/16 8:43 AM, Jan Tulak wrote:<br>
> On Thu, Apr 21, 2016 at 11:39 AM, Jan Tulak <<a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a> <mailto:<a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a>>>wrote:<br>
><br>
> From: Dave Chinner <<a href="mailto:dchinner@redhat.com">dchinner@redhat.com</a> <mailto:<a href="mailto:dchinner@redhat.com">dchinner@redhat.com</a>>><br>
<span class="">><br>
> THIS PATCH HAS KNOWN ISSUES - it fails xfs/206 and xfs/216 tests, as it<br>
> shrinks a file instead just not using it entirely, when -d size is used.<br>
><br>
><br>
> So the shrinking is happening here:<br>
> 3127 /*<br>
> 3128 * If the data area is a file, then grow it out to its final size<br>
> 3129 * so that the reads for the end of the device in the mount code<br>
> 3130 * will succeed.<br>
> 3131 */<br>
> 3132 if (xi.disfile && ftruncate64(xi.dfd, dblocks * blocksize) < 0) {<br>
><br>
><br>
> Before the patch, xi.disfile was 0 and so it didn't shrink the file<br>
> to the size of the new FS. Now, what is the correct solve to this?<br>
> Tests are written for the old behaviour, but this shrinking seems to<br>
> be an intentional thing. It seems that the FS works ok even when this<br>
> truncating is not applied, so I think that I should remove this chunk<br>
> (or change it to xi.dcreate=1 only), and keep the old behaviour.<br>
><br>
> What do you think about it, guys?<br>
<br>
</span>Can't remove it; that would break the other side of things, if you try<br>
to mkfs.xfs -d size=2g on an existing 1g file... mount tries to do<br>
IO to the last block, and if it's not truncated out, that will fail<br>
(as the comment says).<br>
<br>
I suppose the simple way to fix it is to only truncate up, never down.<br>
<br>
i.e. truncate to max(dblocks * blocksize, st_size) or<br>
if (xi.disfile && st_size < dblocks * blocksize) { truncate ... }<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">All right, it seems that I should have read the man page, and not just look on the first sentence or two... <emoticon of me hitting a wall with my head repeatedly>. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Now it works, thanks.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Jan</div><br></div><div> </div></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Jan Tulak<br></div><a href="mailto:jtulak@redhat.com" target="_blank">jtulak@redhat.com</a> / <a href="mailto:jan@tulak.me" target="_blank">jan@tulak.me</a></div></div></div></div>
</div></div>