public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/6] libfrog: refactor online geometry queries
Date: Wed, 28 Aug 2019 10:08:58 -0700	[thread overview]
Message-ID: <20190828170858.GE1037350@magnolia> (raw)
In-Reply-To: <20190827063054.GA1119@dread.disaster.area>

On Tue, Aug 27, 2019 at 04:30:54PM +1000, Dave Chinner wrote:
> On Tue, Aug 20, 2019 at 01:30:38PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Refactor all the open-coded XFS_IOC_FSGEOMETRY queries into a single
> > helper that we can use to standardize behaviors across mixed xfslibs
> > versions.  This is the prelude to introducing a new FSGEOMETRY version
> > in 5.2 and needing to fix the (relatively few) client programs.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  Makefile            |    1 +
> >  fsr/xfs_fsr.c       |   26 ++++----------------------
> 
> Ok.
> 
> >  growfs/xfs_growfs.c |   25 +++++++++----------------
> 
> Nit.
> 
> >  include/xfrog.h     |   22 ++++++++++++++++++++++
> 
> Copyright issue.
> 
> >  io/bmap.c           |    3 ++-
> >  io/fsmap.c          |    3 ++-
> >  io/open.c           |    3 ++-
> >  io/stat.c           |    5 +++--
> 
> ok.
> 
> >  libfrog/fsgeom.c    |   18 ++++++++++++++++++
> 
> fallback question.
> 
> >  quota/free.c        |    6 +++---
> >  repair/xfs_repair.c |    5 +++--
> >  rtcp/Makefile       |    3 +++
> 
> Linker question
> 
> >  rtcp/xfs_rtcp.c     |    7 ++++---
> >  scrub/phase1.c      |    5 +++--
> >  spaceman/file.c     |    3 ++-
> >  spaceman/info.c     |   27 +++++++++------------------
> 
> OK.
> 
> 
> > diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c
> > index 20089d2b..86b1d542 100644
> > --- a/growfs/xfs_growfs.c
> > +++ b/growfs/xfs_growfs.c
> > @@ -7,6 +7,7 @@
> >  #include "libxfs.h"
> >  #include "path.h"
> >  #include "fsgeom.h"
> > +#include "xfrog.h"
> >  
> >  static void
> >  usage(void)
> > @@ -165,22 +166,14 @@ main(int argc, char **argv)
> >  	}
> >  
> >  	/* get the current filesystem size & geometry */
> > -	if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY, &geo) < 0) {
> > -		/*
> > -		 * OK, new xfsctl barfed - back off and try earlier version
> > -		 * as we're probably running an older kernel version.
> > -		 * Only field added in the v2 geometry xfsctl is "logsunit"
> > -		 * so we'll zero that out for later display (as zero).
> > -		 */
> > -		geo.logsunit = 0;
> > -		if (xfsctl(fname, ffd, XFS_IOC_FSGEOMETRY_V1, &geo) < 0) {
> > -			fprintf(stderr, _(
> > -				"%s: cannot determine geometry of filesystem"
> > -				" mounted at %s: %s\n"),
> > -				progname, fname, strerror(errno));
> > -			exit(1);
> > -		}
> > +	if (xfrog_geometry(ffd, &geo) < 0) {
> > +		fprintf(stderr, _(
> > +			"%s: cannot determine geometry of filesystem"
> > +			" mounted at %s: %s\n"),
> > +			progname, fname, strerror(errno));
> > +		exit(1);
> 
> Can you run the format string into a single line?

ok.

> > diff --git a/include/xfrog.h b/include/xfrog.h
> > new file mode 100644
> > index 00000000..5420b47c
> > --- /dev/null
> > +++ b/include/xfrog.h
> > @@ -0,0 +1,22 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2000-2002 Silicon Graphics, Inc.
> > + * All Rights Reserved.
> > + */
> 
> I don't think that copyright is valid/appropriate for a new header
> file with new contents.

Hrmmm ok I'll uhh fix it.

> ...
> 
> > @@ -67,3 +68,20 @@ xfs_report_geom(
> >  		geo->rtextsize * geo->blocksize, (unsigned long long)geo->rtblocks,
> >  			(unsigned long long)geo->rtextents);
> >  }
> > +
> > +/* Try to obtain the xfs geometry. */
> > +int
> > +xfrog_geometry(
> > +	int			fd,
> > +	struct xfs_fsop_geom	*fsgeo)
> > +{
> > +	int			ret;
> > +
> > +	memset(fsgeo, 0, sizeof(*fsgeo));
> > +
> > +	ret = ioctl(fd, XFS_IOC_FSGEOMETRY, fsgeo);
> > +	if (!ret)
> > +		return 0;
> > +
> > +	return ioctl(fd, XFS_IOC_FSGEOMETRY_V1, fsgeo);
> > +}
> 
> Should this fall back to XFS_IOC_FSGEOMETRY_V4, then V1 if that
> fails (which it shouldn't on any supported kernel)?

It should; there's a patch in the next series to do that, but I might as
well merge them (this series was originally targeting 5.1).

> 
> > diff --git a/rtcp/Makefile b/rtcp/Makefile
> > index 808b5378..264b4f27 100644
> > --- a/rtcp/Makefile
> > +++ b/rtcp/Makefile
> > @@ -9,6 +9,9 @@ LTCOMMAND = xfs_rtcp
> >  CFILES = xfs_rtcp.c
> >  LLDFLAGS = -static
> >  
> > +LLDLIBS = $(LIBFROG)
> > +LTDEPENDENCIES = $(LIBFROG)
> 
> Does this work correctly given LLDFLAGS sets -static and not
> -libtools-static-libs?

It seems to, at least on Ubuntu 18.04.

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com

  reply	other threads:[~2019-08-28 17:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 20:30 [PATCH 0/6] libxfrog: wrap version ioctl calls Darrick J. Wong
2019-08-20 20:30 ` [PATCH 1/6] libfrog: refactor online geometry queries Darrick J. Wong
2019-08-27  6:30   ` Dave Chinner
2019-08-28 17:08     ` Darrick J. Wong [this message]
2019-08-20 20:30 ` [PATCH 2/6] libfrog: introduce xfs_fd to wrap an fd to a file on an xfs filesystem Darrick J. Wong
2019-08-27  6:41   ` Dave Chinner
2019-08-28 17:15     ` Darrick J. Wong
2019-08-20 20:30 ` [PATCH 3/6] libfrog: store more inode and block geometry in struct xfs_fd Darrick J. Wong
2019-08-27  7:00   ` Dave Chinner
2019-08-20 20:30 ` [PATCH 4/6] libfrog: create online fs geometry converters Darrick J. Wong
2019-08-27  7:11   ` Dave Chinner
2019-08-28 17:35     ` Darrick J. Wong
2019-08-20 20:31 ` [PATCH 5/6] libfrog: refactor open-coded bulkstat calls Darrick J. Wong
2019-08-27  7:25   ` Dave Chinner
2019-08-20 20:31 ` [PATCH 6/6] libfrog: refactor open-coded INUMBERS calls Darrick J. Wong
2019-08-27  7:26   ` Dave Chinner
  -- strict thread matches above, loose matches on Subject: below --
2019-06-07 19:28 [PATCH v2 0/6] xfsprogs-5.1: fix various problems Darrick J. Wong
2019-06-07 19:28 ` [PATCH 1/6] libfrog: refactor online geometry queries 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=20190828170858.GE1037350@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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