From: Nikolay Borisov <nborisov@suse.com>
To: Christoph Hellwig <hch@lst.de>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/3] btrfs: pass the btrfs_bio_ctrl to submit_one_bio
Date: Mon, 6 Jun 2022 13:41:50 +0300 [thread overview]
Message-ID: <0eb3ddf9-af5f-e67f-c8f8-17c80c731359@suse.com> (raw)
In-Reply-To: <20220603071103.43440-4-hch@lst.de>
On 3.06.22 г. 10:11 ч., Christoph Hellwig wrote:
> submit_one_bio always works on the bio and compression flags from a
> btrfs_bio_ctrl structure. Pass the explicitly and clean up the the
> calling conventions by handling a NULL bio in submit_one_bio, and
> using the btrfs_bio_ctrl to pass the mirror number as well.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/btrfs/extent_io.c | 82 ++++++++++++++++++++------------------------
> 1 file changed, 37 insertions(+), 45 deletions(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 72a258fa27947..facca7feb9a22 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -144,6 +144,7 @@ struct tree_entry {
> */
> struct btrfs_bio_ctrl {
> struct bio *bio;
> + int mirror_num;
> enum btrfs_compression_type compress_type;
> u32 len_to_stripe_boundary;
> u32 len_to_oe_boundary;
> @@ -178,10 +179,11 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
> return ret;
> }
>
> -static void submit_one_bio(struct bio *bio, int mirror_num,
> - enum btrfs_compression_type compress_type)
> +static void __submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
> {
> + struct bio *bio = bio_ctrl->bio;
> struct inode *inode = bio_first_page_all(bio)->mapping->host;
> + int mirror_num = bio_ctrl->mirror_num;
>
> /* Caller should ensure the bio has at least some range added */
> ASSERT(bio->bi_iter.bi_size);
> @@ -191,14 +193,17 @@ static void submit_one_bio(struct bio *bio, int mirror_num,
> else if (btrfs_op(bio) == BTRFS_MAP_WRITE)
> btrfs_submit_data_write_bio(inode, bio, mirror_num);
> else
> - btrfs_submit_data_read_bio(inode, bio, mirror_num, compress_type);
> + btrfs_submit_data_read_bio(inode, bio, mirror_num,
> + bio_ctrl->compress_type);
>
> - /*
> - * Above submission hooks will handle the error by ending the bio,
> - * which will do the cleanup properly. So here we should not return
> - * any error, or the caller of submit_extent_page() will do cleanup
> - * again, causing problems.
> - */
> + /* The bio is owned by the bi_end_io handler now */
> + bio_ctrl->bio = NULL;
> +}
> +
> +static void submit_one_bio(struct btrfs_bio_ctrl *bio_ctrl)
> +{
> + if (bio_ctrl->bio)
> + __submit_one_bio(bio_ctrl);
> }
Why do you need a function just to put an if in it, just move this atop
__submit_one_bio :
if (!bio_ctrl->bio)
return
and rename it to submit_one_bio.
<snip>
next prev parent reply other threads:[~2022-06-06 10:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 7:11 extent_io bio submission cleanup Christoph Hellwig
2022-06-03 7:11 ` [PATCH 1/3] btrfs: don't use bio->bi_private to pass the inode to submit_one_bio Christoph Hellwig
2022-06-03 10:33 ` Qu Wenruo
2022-06-03 7:11 ` [PATCH 2/3] btrfs: merge end_write_bio and flush_write_bio Christoph Hellwig
2022-06-03 10:40 ` Qu Wenruo
2022-06-03 7:11 ` [PATCH 3/3] btrfs: pass the btrfs_bio_ctrl to submit_one_bio Christoph Hellwig
2022-06-04 22:31 ` Qu Wenruo
2022-06-06 6:30 ` Christoph Hellwig
2022-06-06 10:41 ` Nikolay Borisov [this message]
2022-06-06 16:29 ` Christoph Hellwig
2022-06-06 20:23 ` David Sterba
2022-06-06 20:26 ` extent_io bio submission cleanup David Sterba
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=0eb3ddf9-af5f-e67f-c8f8-17c80c731359@suse.com \
--to=nborisov@suse.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
/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