public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/3] btrfs: Use btrfs_io_geometry appropriately
Date: Wed, 12 Jun 2019 18:29:56 +0200	[thread overview]
Message-ID: <20190612162956.GR3563@twin.jikos.cz> (raw)
In-Reply-To: <20190603090505.16800-4-nborisov@suse.com>

On Mon, Jun 03, 2019 at 12:05:05PM +0300, Nikolay Borisov wrote:
> Presently btrfs_map_block is used not only to do everything necessary
> to map a bio to the underlying allocation profile but it's also used to
> identify how much data could be written based on btrfs' stripe logic
> without actually submitting anything. This is achieved by passing NULL
> for 'bbio_ret' parameter.
> 
> This patch refactors all callers that require just the mapping length
> by switching them to using btrfs_io_geometry instead of calling
> btrfs_map_block with a special NULL value for 'bbio_ret'. No functional
> change.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/inode.c   | 25 +++++++--------
>  fs/btrfs/volumes.c | 77 +++++++++-------------------------------------
>  2 files changed, 27 insertions(+), 75 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 80fdf6f21f74..a3abba4c2e2c 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -1932,17 +1932,19 @@ int btrfs_bio_fits_in_stripe(struct page *page, size_t size, struct bio *bio,
>  	u64 length = 0;
>  	u64 map_length;
>  	int ret;
> +	struct btrfs_io_geometry geom;

Stack bloatometer does not like it:

__btrfs_map_block                                                 +56 (200 -> 256)
btrfs_submit_direct                                               +40 (176 -> 216)
btrfs_bio_fits_in_stripe                                          +40 (40 -> 80)

OLD/NEW DELTA:     +104
PRE/POST DELTA:     +240

>  
>  	if (bio_flags & EXTENT_BIO_COMPRESSED)
>  		return 0;
>  
>  	length = bio->bi_iter.bi_size;
>  	map_length = length;
> -	ret = btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length,
> -			      NULL, 0);
> +	ret = btrfs_io_geometry(fs_info, btrfs_op(bio), logical, map_length,
> +				&geom);
>  	if (ret < 0)
>  		return ret;
> -	if (map_length < length + size)
> +
> +	if (geom.len < length + size)

All the function needs from the geometry is one member 'len'.

>  		return 1;
>  	return 0;
>  }
> @@ -8331,15 +8333,15 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip)
>  	int clone_len;
>  	int ret;
>  	blk_status_t status;
> +	struct btrfs_io_geometry geom;

And btrfs_submit_direct_hook does not seem to use the geom members at
all, which looks like the parameters are only validated in some way.

      reply	other threads:[~2019-06-12 16:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03  9:05 [PATCH 0/3] refactoring __btrfs_map_block Nikolay Borisov
2019-06-03  9:05 ` [PATCH 1/3] btrfs: Introduce struct btrfs_io_geometry Nikolay Borisov
2019-06-05  7:35   ` Johannes Thumshirn
2019-06-05 12:37     ` David Sterba
2019-06-03  9:05 ` [PATCH 2/3] btrfs: Introduce btrfs_io_geometry Nikolay Borisov
2019-06-05  8:01   ` Johannes Thumshirn
2019-06-12 16:31   ` David Sterba
2019-06-03  9:05 ` [PATCH 3/3] btrfs: Use btrfs_io_geometry appropriately Nikolay Borisov
2019-06-12 16:29   ` David Sterba [this message]

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=20190612162956.GR3563@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox