All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: "liuyd.fnst@fujitsu.com" <liuyd.fnst@fujitsu.com>
Cc: "guaneryu@gmail.com" <guaneryu@gmail.com>,
	"zlang@redhat.com" <zlang@redhat.com>,
	"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
	"fstests@vger.kernel.org" <fstests@vger.kernel.org>,
	"guan@eryu.me" <guan@eryu.me>
Subject: Re: [PATCH 1/9] seek_sanity_test: fix allocation unit detection on XFS realtime
Date: Wed, 27 Jul 2022 20:54:19 -0700	[thread overview]
Message-ID: <YuIIa2EboQGTeNo1@magnolia> (raw)
In-Reply-To: <45012000-087a-e98d-7322-4f1079bbb1d8@fujitsu.com>

On Thu, Jul 28, 2022 at 03:38:38AM +0000, liuyd.fnst@fujitsu.com wrote:
> Hi, Darrick.
> 
> 
> On 7/28/22 10:37, Darrick J. Wong wrote:
> > Does this patch fix NFS for you?
> 
> It works for me. Thanks.
> BTW. It has conflict during "git am". Looks like your branch are ahead 
> of master.

Yes, I base my development branch off of for-next nowadays.  Thanks for
the report, I'll add a tested-by if that's ok and send it out as a bug
fix.

--D

> > 
> > --D
> > ---
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > seek_sanity_test: use XFS ioctls to determine file allocation unit size
> > 
> > liuyd.fnst@fujitsu.com reported that my recent change to the seek sanity
> > test broke NFS.  I foolishly thought that st_blksize was sufficient to
> > find the file allocation unit size so that applications could figure out
> > the SEEK_HOLE granularity.  Replace that with an explicit callout to XFS
> > ioctls so that xfs realtime will work again.
> > 
> > Fixes: e861a302 ("seek_sanity_test: fix allocation unit detection on XFS realtime")
> > Reported-by: liuyd.fnst@fujitsu.com
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >   src/Makefile           |    4 ++++
> >   src/seek_sanity_test.c |   40 +++++++++++++++++++++++++++++++---------
> >   2 files changed, 35 insertions(+), 9 deletions(-)
> > 
> > diff --git a/src/Makefile b/src/Makefile
> > index 38628a22..b89a7a5e 100644
> > --- a/src/Makefile
> > +++ b/src/Makefile
> > @@ -82,6 +82,10 @@ ifeq ($(HAVE_LIBCAP), true)
> >   LLDLIBS += -lcap
> >   endif
> >   
> > +ifeq ($(HAVE_FSXATTR_XFLAG_HASATTR), yes)
> > +LCFLAGS += -DHAVE_FSXATTR_XFLAG_HASATTR
> > +endif
> > +
> >   ifeq ($(HAVE_SEEK_DATA), yes)
> >    ifeq ($(HAVE_FSXATTR_XFLAG_HASATTR), yes)
> >     ifeq ($(HAVE_NFTW), yes)
> > diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> > index 1030d0c5..b53f4862 100644
> > --- a/src/seek_sanity_test.c
> > +++ b/src/seek_sanity_test.c
> > @@ -40,6 +40,32 @@ static void get_file_system(int fd)
> >   	}
> >   }
> >   
> > +#ifdef HAVE_FSXATTR_XFLAG_HASATTR
> > +/* Compute the file allocation unit size for an XFS file. */
> > +static int detect_xfs_alloc_unit(int fd)
> > +{
> > +	struct fsxattr fsx;
> > +	struct xfs_fsop_geom fsgeom;
> > +	int ret;
> > +
> > +	ret = ioctl(fd, XFS_IOC_FSGEOMETRY, &fsgeom);
> > +	if (ret)
> > +		return -1;
> > +
> > +	ret = ioctl(fd, FS_IOC_FSGETXATTR, &fsx);
> > +	if (ret)
> > +		return -1;
> > +
> > +	alloc_size = fsgeom.blocksize;
> > +	if (fsx.fsx_xflags & FS_XFLAG_REALTIME)
> > +		alloc_size *= fsgeom.rtextsize;
> > +
> > +	return 0;
> > +}
> > +#else
> > +# define detect_xfs_alloc_unit(fd) (-1)
> > +#endif
> > +
> >   static int get_io_sizes(int fd)
> >   {
> >   	off_t pos = 0, offset = 1;
> > @@ -47,6 +73,10 @@ static int get_io_sizes(int fd)
> >   	int shift, ret;
> >   	int pagesz = sysconf(_SC_PAGE_SIZE);
> >   
> > +	ret = detect_xfs_alloc_unit(fd);
> > +	if (!ret)
> > +		goto done;
> > +
> >   	ret = fstat(fd, &buf);
> >   	if (ret) {
> >   		fprintf(stderr, "  ERROR %d: Failed to find io blocksize\n",
> > @@ -54,16 +84,8 @@ static int get_io_sizes(int fd)
> >   		return ret;
> >   	}
> >   
> > -	/*
> > -	 * st_blksize is typically also the allocation size.  However, XFS
> > -	 * rounds this up to the page size, so if the stat blocksize is exactly
> > -	 * one page, use this iterative algorithm to see if SEEK_DATA will hint
> > -	 * at a more precise answer based on the filesystem's (pre)allocation
> > -	 * decisions.
> > -	 */
> > +	/* st_blksize is typically also the allocation size */
> >   	alloc_size = buf.st_blksize;
> > -	if (alloc_size != pagesz)
> > -		goto done;
> >   
> >   	/* try to discover the actual alloc size */
> >   	while (pos == 0 && offset < alloc_size) {

  reply	other threads:[~2022-07-28  3:54 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 20:21 [PATCHSET 0/9] fstests: random fixes Darrick J. Wong
2022-06-28 20:21 ` [PATCH 1/9] seek_sanity_test: fix allocation unit detection on XFS realtime Darrick J. Wong
2022-06-29  7:41   ` Christoph Hellwig
2022-07-28  1:37   ` liuyd.fnst
2022-07-28  2:31     ` Darrick J. Wong
2022-07-28  2:37     ` Darrick J. Wong
2022-07-28  3:38       ` liuyd.fnst
2022-07-28  3:54         ` Darrick J. Wong [this message]
2022-06-28 20:21 ` [PATCH 2/9] xfs/070: filter new superblock verifier messages Darrick J. Wong
2022-06-29  4:15   ` Dave Chinner
2022-06-29  9:12     ` Zorro Lang
2022-06-29 22:41       ` Darrick J. Wong
2022-06-30  2:18         ` Zorro Lang
2022-06-28 20:21 ` [PATCH 3/9] xfs: test mkfs.xfs sizing of internal logs that Darrick J. Wong
2022-06-29  4:18   ` Dave Chinner
2022-06-29 22:43     ` Darrick J. Wong
2022-06-30  6:37       ` Zorro Lang
2022-06-30 19:32         ` Darrick J. Wong
2022-06-28 20:21 ` [PATCH 4/9] xfs: test xfs_copy doesn't do cached read before libxfs_mount Darrick J. Wong
2022-06-29  4:20   ` Dave Chinner
2022-06-29 22:46     ` Darrick J. Wong
2022-06-30  0:48   ` [PATCH v2.1 " Darrick J. Wong
2022-07-01  1:06     ` Dave Chinner
2022-06-28 20:21 ` [PATCH 5/9] check: document mkfs.xfs reliance on fstests exports Darrick J. Wong
2022-06-29  4:22   ` Dave Chinner
2022-06-28 20:21 ` [PATCH 6/9] xfs/109: handle larger minimum filesystem size Darrick J. Wong
2022-06-29  4:22   ` Dave Chinner
2022-06-28 20:21 ` [PATCH 7/9] xfs/018: fix LARP testing for small block sizes Darrick J. Wong
2022-06-28 20:22 ` [PATCH 8/9] xfs/166: fix golden output failures when multipage folios enabled Darrick J. Wong
2022-06-29  4:23   ` Dave Chinner
2022-06-28 20:22 ` [PATCH 9/9] xfs/547: fix problems with realtime Darrick J. Wong
2022-07-05 14:28 ` [PATCHSET 0/9] fstests: random fixes Zorro Lang
2022-07-05 22:04   ` Darrick J. Wong

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=YuIIa2EboQGTeNo1@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=liuyd.fnst@fujitsu.com \
    --cc=zlang@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.