public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/6] libfrog: refactor open-coded bulkstat calls
Date: Tue, 27 Aug 2019 17:25:16 +1000	[thread overview]
Message-ID: <20190827072516.GE1119@dread.disaster.area> (raw)
In-Reply-To: <156633306332.1215733.6520962409761161178.stgit@magnolia>

On Tue, Aug 20, 2019 at 01:31:03PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Refactor the BULKSTAT_SINGLE and BULKSTAT ioctl callsites into helper
> functions.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
.....
> ---
> @@ -617,25 +592,27 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)
>  		return -1;
>  	}
>  
> -	if ((fsfd = open(mntdir, O_RDONLY)) < 0) {
> +	if ((fsxfd.fd = open(mntdir, O_RDONLY)) < 0) {
>  		fsrprintf(_("unable to open: %s: %s\n"),
>  		          mntdir, strerror( errno ));
>  		free(fshandlep);
>  		return -1;
>  	}
>  
> -	if (xfrog_geometry(fsfd, &fsgeom) < 0 ) {
> +	ret = xfrog_prepare_geometry(&fsxfd);
> +	if (ret) {
>  		fsrprintf(_("Skipping %s: could not get XFS geometry\n"),
>  			  mntdir);
> -		close(fsfd);
> +		xfrog_close(&fsxfd);
>  		free(fshandlep);
>  		return -1;
>  	}

/me wonders if this would be better wrapped as xfd_open(&xfd, path, flags,
mode) ?

> @@ -684,16 +661,16 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)
>  		}
>  		if (endtime && endtime < time(NULL)) {
>  			tmp_close(mntdir);
> -			close(fsfd);
> +			xfrog_close(&fsxfd);
>  			fsrall_cleanup(1);
>  			exit(1);
>  		}
>  	}
>  	if (ret < 0)
> -		fsrprintf(_("%s: xfs_bulkstat: %s\n"), progname, strerror(errno));
> +		fsrprintf(_("%s: xfrog_bulkstat: %s\n"), progname, strerror(errno));

It'd change this to just "bulkstat" - it's a user facing error, and
they aren't going to know what "xfrog" means...

> @@ -745,14 +725,21 @@ fsrfile(char *fname, xfs_ino_t ino)
>  	 * Need to open something on the same filesystem as the
>  	 * file.  Open the parent.
>  	 */
> -	fsfd = open(getparent(fname), O_RDONLY);
> -	if (fsfd < 0) {
> +	fsxfd.fd = open(getparent(fname), O_RDONLY);
> +	if (fsxfd.fd < 0) {
>  		fsrprintf(_("unable to open sys handle for %s: %s\n"),
>  			fname, strerror(errno));
>  		goto out;
>  	}
>  
> -	if ((xfs_bulkstat_single(fsfd, &ino, &statbuf)) < 0) {
> +	error = xfrog_prepare_geometry(&fsxfd);
> +	if (error) {
> +		fsrprintf(_("Unable to get geom on fs for: %s\n"), fname);
> +		goto out;
> +	}
> +

same xfd_open() code here.

> diff --git a/io/open.c b/io/open.c
> index e70c8cb0..67976f7f 100644
> --- a/io/open.c
> +++ b/io/open.c
....
> @@ -767,35 +766,36 @@ inode_f(
>  			exitcode = 1;
>  			return 0;
>  		}
> +	} else if (ret_next) {
> +		struct xfs_fd	xfd = XFS_FD_INIT(file->fd);
> +
> +		/* get next inode */
> +		ret = xfrog_bulkstat(&xfd, &userino, 1, &bstat, &count);
> +		if (ret) {
> +			perror("xfsctl");

perror("bulkstat");

....

Otherwise looks ok.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2019-08-27  7:25 UTC|newest]

Thread overview: 16+ 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
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 [this message]
2019-08-20 20:31 ` [PATCH 6/6] libfrog: refactor open-coded INUMBERS calls Darrick J. Wong
2019-08-27  7:26   ` Dave Chinner

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=20190827072516.GE1119@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=darrick.wong@oracle.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