Re: [PATCH 1/2] mkfs: discard only after all validations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 19, 2018 at 4:44 PM Darrick J. Wong <darrick.wong@xxxxxxxxxx> wrote:

snip

> > @@ -2419,8 +2418,16 @@ open_devices(
> >       xi->dsize &= sector_mask;
> >       xi->rtsize &= sector_mask;
> >       xi->logBBsize &= (uint64_t)-1 << (max(cfg->lsectorlog, 10) - BBSHIFT);
> > +}
> >
> > -
> > +static void
> > +discard_data(
>
> Perhaps discard_devices(), since this function can DISCARD more than
> just the data device.

Agreed.


>
> > +     struct libxfs_xinit     *xi,
> > +     bool                    discard)
> > +{
> > +     /*
> > +      * This function has to be called after libxfs has been initialized.
> > +      */
> >       if (!discard)
> >               return;
> >
>
> While we're on the topic, I notice that we skip discard for any device
> that's actually a file.  Seeing as fallocate(PUNCH_HOLE) works on files
> (and block devices), is there a reason why we avoid punching out fs
> image files?
>

>From what I remember, it went along this: If the user is trying to
mkfs an existing file, we don't want to destroy anything they did with
the file before (sparse file, allocations...).

> > @@ -3901,7 +3908,7 @@ main(
> >       /*
> >        * Open and validate the device configurations
> >        */
> > -     open_devices(&cfg, &xi, (discard && !dry_run));
> > +     open_devices(&cfg, &xi);
> >       validate_datadev(&cfg, &cli);
> >       validate_logdev(&cfg, &cli, &logfile);
> >       validate_rtdev(&cfg, &cli, &rtfile);
> > @@ -3952,6 +3959,11 @@ main(
> >                       exit(0);
> >       }
> >
> > +     /*
> > +      * All values have been validated, discard the old device layout.
> > +      */
> > +     discard_data(&xi, (discard && !dry_run));
>
> if (discard && !dry_run)
>         discard_devices(&xi);
>
> ?

Yes, this makes more sense.

Jan

--
Jan Tulak
jtulak@xxxxxxxxxx / jan@xxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux