[PATCH 17/19] xfsprogs: disable truncating of files

Jan Tulak jtulak at redhat.com
Fri Apr 8 05:06:35 CDT 2016


On Fri, Apr 8, 2016 at 2:09 AM, Dave Chinner <david at fromorbit.com> wrote:

> On Thu, Mar 24, 2016 at 12:15:34PM +0100, jtulak at redhat.com wrote:
> > From: Jan Tulak <jtulak at redhat.com>
> >
> > Unify mkfs.xfs behaviour a bit and never truncate files. If the user
> > is trying to mkfs an existing file, we don't want to destroy anything
> > he did with the file before (sparse file, allocations...)
>
> Why not? We do that with discard-by-default to block devices,
> O_TRUNC is exactly the same situation with a file - we completely
> re-initialise the file from a known state if mkfs has been asked to
> create the file.
>
> ​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.

I can be missing something, though.


> > @@ -1059,9 +1063,9 @@ check_device_type(
> >       }
> >
> >       /*
> > -      * We only want to completely truncate and recreate an existing
> file if
> > -      * we were specifically told it was a file. Set the create flag
> only in
> > -      * this case to trigger that behaviour.
> > +      * We only want to create a file only if we were specifically told
> > +      * we want a file. Set the create flag only in this case to trigger
> > +      * that behaviour.
> >        */
> >       if (S_ISREG(statbuf.st_mode)) {
> >               if (!*isfile)
>
> i.e. this situation.
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david at fromorbit.com
>



-- 
Jan Tulak
jtulak at redhat.com / jan at tulak.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.sgi.com/pipermail/xfs/attachments/20160408/8b832ba6/attachment-0001.html>


More information about the xfs mailing list