All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH v2 1/2] fiemap: Factor out actual fiemap call code
Date: Tue, 31 Oct 2017 13:29:37 -0700	[thread overview]
Message-ID: <20171031202937.GH4911@magnolia> (raw)
In-Reply-To: <1509459011-7398-1-git-send-email-nborisov@suse.com>

> Subject: Re: [PATCH v2 1/2] fiemap: Factor out actual fiemap call code

I thought this was v3....

On Tue, Oct 31, 2017 at 04:10:10PM +0200, Nikolay Borisov wrote:
> This will be needed to in a subsequent patch to avoid code duplication
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> v2:
>  * Incorporated Daricks feedback - removed variables which weren't introduced
>  until the next patch as a result the build with this patch was broken. This is 
>  fixed now
>  io/fiemap.c | 39 ++++++++++++++++++++++++++++-----------
>  1 file changed, 28 insertions(+), 11 deletions(-)
> 
> diff --git a/io/fiemap.c b/io/fiemap.c
> index e6fd66da753d..08391f69d9bd 100644
> --- a/io/fiemap.c
> +++ b/io/fiemap.c
> @@ -211,6 +211,31 @@ calc_print_format(
>  	}
>  }
>  
> +static int
> +__fiemap(
> +	 struct fiemap * fiemap,

	struct fiemap	*fiemap,

> +	 int		 mapsize,
> +	 __u32		 flags,
> +	 __u64		 start,
> +	 __u64		 length) {
> +
> +	int ret;

	int		ret;

(Yeah, I know...)

> +
> +	memset(fiemap, 0, mapsize);
> +	fiemap->fm_flags = flags;
> +	fiemap->fm_start = start;
> +	fiemap->fm_length = length;
> +	fiemap->fm_extent_count = EXTENT_BATCH;

It's odd that we pass in both the struct* and its initializers here, but
we still have to have a way to pass fm_flags and fm_mapped_extents back
to the __fiemap() caller.

(TBH I'm wondering if this patch is necessary...)

--D

> +	ret = ioctl(file->fd, FS_IOC_FIEMAP, fiemap);
> +	if (ret < 0) {
> +	        fprintf(stderr, "%s: ioctl(FS_IOC_FIEMAP) [\"%s\"]: "
> +	                "%s\n", progname, file->name, strerror(errno));
> +	        return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  int
>  fiemap_f(
>  	int		argc,
> @@ -266,19 +291,11 @@ fiemap_f(
>  
>  	while (!last && (cur_extent != max_extents)) {
>  
> -		memset(fiemap, 0, map_size);
> -		fiemap->fm_flags = fiemap_flags;
> -		fiemap->fm_start = last_logical;
> -		fiemap->fm_length = -1LL;
> -		fiemap->fm_extent_count = EXTENT_BATCH;
> -
> -		ret = ioctl(file->fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
> +		ret = __fiemap(fiemap, map_size, fiemap_flags, last_logical,
> +			       -1LL);
>  		if (ret < 0) {
> -			fprintf(stderr, "%s: ioctl(FS_IOC_FIEMAP) [\"%s\"]: "
> -				"%s\n", progname, file->name, strerror(errno));
> -			free(fiemap);
>  			exitcode = 1;
> -			return 0;
> +			goto out;
>  		}
>  
>  		/* No more extents to map, exit */
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-10-31 20:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27 12:37 [PATCH v2 0/2] Fiemap's range query Nikolay Borisov
2017-10-27 12:37 ` [PATCH 1/2] fiemap: Factor out actual fiemap call code Nikolay Borisov
2017-10-27 16:33   ` Darrick J. Wong
2017-10-27 16:37     ` Darrick J. Wong
2017-10-27 12:37 ` [PATCH 1/2] initial fiemap test Nikolay Borisov
2017-10-27 12:44   ` Eryu Guan
2017-10-31  9:22     ` Nikolay Borisov
2017-10-31  9:32       ` Eryu Guan
2017-10-31 12:27         ` Nikolay Borisov
2017-10-27 12:37 ` [PATCH 2/2] fiemap: Implement ranged query Nikolay Borisov
2017-10-27 12:37 ` [PATCH 2/2] generic: Adjust generic test ouputs for new fiemap implementation Nikolay Borisov
2017-10-27 12:46   ` Eryu Guan
2017-10-27 12:48     ` Nikolay Borisov
2017-10-31 14:10 ` [PATCH v2 1/2] fiemap: Factor out actual fiemap call code Nikolay Borisov
2017-10-31 14:10   ` [PATCH v2 2/2] fiemap: Implement ranged query Nikolay Borisov
2017-10-31 14:11   ` [PATCH v2 1/4] common: Check for fiemap range argument support Nikolay Borisov
2017-10-31 14:11     ` [PATCH v2 2/4] punch: Implement fixup for fiemap range queries Nikolay Borisov
2017-11-07  5:18       ` Eryu Guan
2017-10-31 14:11     ` [PATCH v2 3/4] generic: Adjust generic test ouputs for new fiemap implementation Nikolay Borisov
2017-11-07  5:15       ` Eryu Guan
2017-10-31 14:11     ` [PATCH v2 4/4] xfs: initial fiemap range query test Nikolay Borisov
2017-11-02  3:16     ` [PATCH v2 1/4] common: Check for fiemap range argument support Eryu Guan
2017-11-02  6:59       ` Nikolay Borisov
2017-11-02  8:13       ` [PATCH v3] " Nikolay Borisov
2017-11-02 21:12         ` Dave Chinner
2017-11-03 14:05           ` Nikolay Borisov
2017-11-03 16:28             ` Darrick J. Wong
2017-11-14 15:09         ` Eric Sandeen
2017-11-15  7:41           ` Eryu Guan
2017-10-31 20:29   ` Darrick J. Wong [this message]
2017-10-31 20:32     ` [PATCH v2 1/2] fiemap: Factor out actual fiemap call code Nikolay Borisov

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=20171031202937.GH4911@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nborisov@suse.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.