From: "Darrick J. Wong" <djwong@kernel.org>
To: Eryu Guan <guan@eryu.me>
Cc: guaneryu@gmail.com, linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH 7/8] iogen: upgrade to fallocate
Date: Mon, 17 Jan 2022 09:15:16 -0800 [thread overview]
Message-ID: <20220117171516.GB13514@magnolia> (raw)
In-Reply-To: <YePCz96eXSb66ppd@desktop>
On Sun, Jan 16, 2022 at 03:01:35PM +0800, Eryu Guan wrote:
> On Tue, Jan 11, 2022 at 01:50:46PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Update this utility to use fallocate to preallocate/reserve space to a
> > file so that we're not so dependent on legacy XFS ioctls.
> >
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> > ltp/iogen.c | 32 ++++++++++++++++++++++----------
> > 1 file changed, 22 insertions(+), 10 deletions(-)
> >
> >
> > diff --git a/ltp/iogen.c b/ltp/iogen.c
> > index 2b6644d5..6c2c1534 100644
> > --- a/ltp/iogen.c
> > +++ b/ltp/iogen.c
> > @@ -928,7 +928,15 @@ bozo!
> > fd, f.l_whence, (long long)f.l_start, (long long)f.l_len);*/
> >
> > /* non-zeroing reservation */
> > -#ifdef XFS_IOC_RESVSP
> > +#if defined(HAVE_FALLOCATE)
> > + if (fallocate(fd, 0, 0, nbytes) == -1) {
>
> Seems this is not a identical replacement for XFS_IOC_RESVSP (is that
> what we want here?), as fallocate(2) here zeros space and change i_size
> as well.
Doh, you're right, the second parameter should follow what the kernel
does and specify FALLOC_FL_KEEP_SIZE. I'll fix that and resubmit.
Thanks for taking the rest of the series. :)
--D
> And from xfsctl(3), after XFS_IOC_RESVSP "The blocks are allocated, but
> not zeroed, and the file size does not change." And the comments above
> indicates "non-zeroing reservation" as well.
>
> If identical replacement is not required, we could drop "non-zeroing"
> part, but add FALLOC_FL_KEEP_SIZE?
>
> Thanks,
> Eryu
>
> > + fprintf(stderr,
> > + "iogen%s: Could not fallocate %d bytes in file %s: %s (%d)\n",
> > + TagName, nbytes, path, SYSERR, errno);
> > + close(fd);
> > + return -1;
> > + }
> > +#elif defined(XFS_IOC_RESVSP)
> > if( xfsctl( path, fd, XFS_IOC_RESVSP, &f ) == -1) {
> > fprintf(stderr,
> > "iogen%s: Could not xfsctl(XFS_IOC_RESVSP) %d bytes in file %s: %s (%d)\n",
> > @@ -936,8 +944,7 @@ bozo!
> > close(fd);
> > return -1;
> > }
> > -#else
> > -#ifdef F_RESVSP
> > +#elif defined(F_RESVSP)
> > if( fcntl( fd, F_RESVSP, &f ) == -1) {
> > fprintf(stderr,
> > "iogen%s: Could not fcntl(F_RESVSP) %d bytes in file %s: %s (%d)\n",
> > @@ -946,8 +953,7 @@ bozo!
> > return -1;
> > }
> > #else
> > -bozo!
> > -#endif
> > +# error Dont know how to reserve space!
> > #endif
> > }
> >
> > @@ -962,7 +968,15 @@ bozo!
> > (long long)f.l_len);*/
> >
> > /* zeroing reservation */
> > -#ifdef XFS_IOC_ALLOCSP
> > +#if defined(HAVE_FALLOCATE)
> > + if (fallocate(fd, 0, sbuf.st_size, nbytes - sbuf.st_size) == -1) {
> > + fprintf(stderr,
> > + "iogen%s: Could not fallocate %d bytes in file %s: %s (%d)\n",
> > + TagName, nbytes, path, SYSERR, errno);
> > + close(fd);
> > + return -1;
> > + }
> > +#elif defined(XFS_IOC_ALLOCSP)
> > if( xfsctl( path, fd, XFS_IOC_ALLOCSP, &f ) == -1) {
> > fprintf(stderr,
> > "iogen%s: Could not xfsctl(XFS_IOC_ALLOCSP) %d bytes in file %s: %s (%d)\n",
> > @@ -970,8 +984,7 @@ bozo!
> > close(fd);
> > return -1;
> > }
> > -#else
> > -#ifdef F_ALLOCSP
> > +#elif defined(F_ALLOCSP)
> > if ( fcntl(fd, F_ALLOCSP, &f) < 0) {
> > fprintf(stderr,
> > "iogen%s: Could not fcntl(F_ALLOCSP) %d bytes in file %s: %s (%d)\n",
> > @@ -980,8 +993,7 @@ bozo!
> > return -1;
> > }
> > #else
> > -bozo!
> > -#endif
> > +# error Dont know how to (pre)allocate space!
> > #endif
> > }
> > #endif
next prev parent reply other threads:[~2022-01-17 17:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 21:50 [PATCHSET 0/8] fstests: random fixes Darrick J. Wong
2022-01-11 21:50 ` [PATCH 1/8] common/rc: fix _check_xfs_scrub_does_unicode on newer versions of libc-bin Darrick J. Wong
2022-01-11 21:50 ` [PATCH 2/8] common/rc: fix unicode checker detection in xfs_scrub Darrick J. Wong
2022-01-11 21:50 ` [PATCH 3/8] xfs/220: fix quotarm syscall test Darrick J. Wong
2022-01-12 1:14 ` xuyang2018.jy
2022-01-14 3:23 ` xuyang2018.jy
2022-01-14 17:08 ` Darrick J. Wong
2022-01-17 1:06 ` xuyang2018.jy
2022-01-11 21:50 ` [PATCH 4/8] xfs: test fixes for new 5.17 behaviors Darrick J. Wong
2022-01-11 21:50 ` [PATCH 5/8] xfs: regression test for allocsp handing out stale disk contents Darrick J. Wong
2022-01-16 7:12 ` Eryu Guan
2022-01-18 3:37 ` Zorro Lang
2022-01-18 18:09 ` Darrick J. Wong
2022-01-19 4:07 ` Zorro Lang
2022-01-19 4:52 ` Darrick J. Wong
2022-01-11 21:50 ` [PATCH 6/8] fsx: add support for XFS_IOC_ALLOCSP Darrick J. Wong
2022-01-11 21:50 ` [PATCH 7/8] iogen: upgrade to fallocate Darrick J. Wong
2022-01-16 7:01 ` Eryu Guan
2022-01-17 17:15 ` Darrick J. Wong [this message]
2022-01-11 21:50 ` [PATCH 8/8] alloc: " Darrick J. Wong
2022-01-16 7:16 ` [PATCHSET 0/8] fstests: random fixes Eryu Guan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220117171516.GB13514@magnolia \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=guaneryu@gmail.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox