<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,sans-serif">On Fri, Apr 8, 2016 at 2:09 AM, Dave Chinner </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:david@fromorbit.com" target="_blank">david@fromorbit.com</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"><span class="">On Thu, Mar 24, 2016 at 12:15:34PM +0100, <a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a> wrote:<br>
> From: Jan Tulak <<a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a>><br>
><br>
> Unify mkfs.xfs behaviour a bit and never truncate files. If the user<br>
> is trying to mkfs an existing file, we don't want to destroy anything<br>
> he did with the file before (sparse file, allocations...)<br>
<br>
</span>Why not? We do that with discard-by-default to block devices,<br>
O_TRUNC is exactly the same situation with a file - we completely<br>
re-initialise the file from a known state if mkfs has been asked to<br>
create the file.<br>
<span class=""><br></span></blockquote><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​But AFAIK, we don't zero-out entire spindle devices, we don't ask if the drive skips some blocks (i.e. because they are bad),​ and we don't care about what an underlaying layer (like LVM) did with the block device. From this point of view, we shouldn't care about the file either.</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">I can be missing something, though.</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
> @@ -1059,9 +1063,9 @@ check_device_type(<br>
>       }<br>
><br>
>       /*<br>
> -      * We only want to completely truncate and recreate an existing file if<br>
> -      * we were specifically told it was a file. Set the create flag only in<br>
> -      * this case to trigger that behaviour.<br>
> +      * We only want to create a file only if we were specifically told<br>
> +      * we want a file. Set the create flag only in this case to trigger<br>
> +      * that behaviour.<br>
>        */<br>
>       if (S_ISREG(statbuf.st_mode)) {<br>
>               if (!*isfile)<br>
<br>
</span>i.e. this situation.<br>
<br>
Cheers,<br>
<br>
Dave.<br>
<span class="HOEnZb"><font color="#888888">--<br>
Dave Chinner<br>
<a href="mailto:david@fromorbit.com">david@fromorbit.com</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></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>