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 3/4] xfs_spaceman: embed struct xfs_fd in struct fileio
Date: Tue, 27 Aug 2019 17:51:01 +1000	[thread overview]
Message-ID: <20190827075101.GG1119@dread.disaster.area> (raw)
In-Reply-To: <156685443883.2839773.16670488313525688465.stgit@magnolia>

On Mon, Aug 26, 2019 at 02:20:38PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Replace the open-coded fd and geometry fields of struct fileio with a
> single xfs_fd, which will enable us to use it natively throughout
> xfs_spaceman in upcoming patches.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  spaceman/file.c     |   27 +++++++++++++--------------
>  spaceman/freesp.c   |   30 +++++++++++++++++-------------
>  spaceman/info.c     |   18 ++----------------
>  spaceman/init.c     |   11 +++++++----
>  spaceman/prealloc.c |   15 ++++++++-------
>  spaceman/space.h    |    9 +++++----
>  spaceman/trim.c     |   40 +++++++++++++++++++++-------------------
>  7 files changed, 73 insertions(+), 77 deletions(-)
> 
> 
> diff --git a/spaceman/file.c b/spaceman/file.c
> index 5665da7d..9d550274 100644
> --- a/spaceman/file.c
> +++ b/spaceman/file.c
> @@ -45,26 +45,27 @@ print_f(
>  int
>  openfile(
>  	char		*path,
> -	struct xfs_fsop_geom *geom,
> +	struct xfs_fd	*xfd,
>  	struct fs_path	*fs_path)
>  {
>  	struct fs_path	*fsp;
> -	int		fd;
> +	int		ret;
>  
> -	fd = open(path, 0);
> -	if (fd < 0) {
> +	xfd->fd = open(path, 0);
> +	if (xfd->fd < 0) {
>  		perror(path);
>  		return -1;
>  	}
>  
> -	if (xfrog_geometry(fd, geom) < 0) {
> +	ret = xfrog_prepare_geometry(xfd);
> +	if (ret < 0) {
>  		if (errno == ENOTTY)
>  			fprintf(stderr,
>  _("%s: Not on a mounted XFS filesystem.\n"),
>  					path);
>  		else
>  			perror("XFS_IOC_FSGEOMETRY");
> -		close(fd);
> +		xfrog_close(xfd);
>  		return -1;
>  	}

There's that xfd_open() pattern again :P

> --- a/spaceman/init.c
> +++ b/spaceman/init.c
> @@ -5,6 +5,7 @@
>   */
>  
>  #include "libxfs.h"
> +#include "xfrog.h"
>  #include "command.h"
>  #include "input.h"
>  #include "init.h"
> @@ -60,7 +61,7 @@ init(
>  	char		**argv)
>  {
>  	int		c;
> -	struct xfs_fsop_geom geometry = { 0 };
> +	struct xfs_fd	xfd = XFS_FD_INIT(-1);

XFS_FD_INIT_EMPTY()

Otherwise looks good.

-- 
Dave Chinner
david@fromorbit.com

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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 21:20 [PATCH 0/4] xfs_spaceman: use runtime support library Darrick J. Wong
2019-08-26 21:20 ` [PATCH 1/4] xfs_spaceman: remove typedef usage Darrick J. Wong
2019-08-27  5:01   ` Dave Chinner
2019-08-26 21:20 ` [PATCH 2/4] xfs_spaceman: remove unnecessary test in openfile() Darrick J. Wong
2019-08-27  5:02   ` Dave Chinner
2019-08-26 21:20 ` [PATCH 3/4] xfs_spaceman: embed struct xfs_fd in struct fileio Darrick J. Wong
2019-08-27  5:06   ` Dave Chinner
2019-08-27  5:12     ` Darrick J. Wong
2019-08-27  7:51   ` Dave Chinner [this message]
2019-08-26 21:20 ` [PATCH 4/4] xfs_spaceman: convert open-coded unit conversions to helpers Darrick J. Wong
2019-08-27  8:15   ` Dave Chinner
2019-08-29  3:48     ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2019-09-04  4:38 [PATCH v2 0/4] xfs_spaceman: use runtime support library Darrick J. Wong
2019-09-04  4:38 ` [PATCH 3/4] xfs_spaceman: embed struct xfs_fd in struct fileio Darrick J. Wong
2019-09-04 23:59   ` 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=20190827075101.GG1119@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