From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 2/3] btrfs: remove btrfs_bio_alloc() helper
Date: Tue, 14 Sep 2021 18:45:46 +0200 [thread overview]
Message-ID: <20210914164546.GG9286@twin.jikos.cz> (raw)
In-Reply-To: <20210914012543.12746-3-wqu@suse.com>
On Tue, Sep 14, 2021 at 09:25:42AM +0800, Qu Wenruo wrote:
> comp_bio->bi_end_io = end_compressed_bio_read;
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 1aed03ef5f49..5ef7c506aee6 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -3121,16 +3121,19 @@ static inline void btrfs_io_bio_init(struct btrfs_io_bio *btrfs_bio)
> }
>
> /*
> - * The following helpers allocate a bio. As it's backed by a bioset, it'll
> - * never fail.
This note should stay, it's not obvious why we don't need to handle the
allocation failure.
> We're returning a bio right now but you can call btrfs_io_bio
> - * for the appropriate container_of magic
> + * Allocate a btrfs_io_bio, with @nr_iovecs as maxinum iovecs.
maximum
> + *
> + * If @nr_iovecs is 0, it will use BIO_MAX_VECS as @nr_iovces instead.
> + * This behavior is to provide a fail-safe default value.
> */
> -struct bio *btrfs_bio_alloc(u64 first_byte)
> +struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs)
> {
> struct bio *bio;
>
> - bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_VECS, &btrfs_bioset);
> - bio->bi_iter.bi_sector = first_byte >> 9;
> + ASSERT(nr_iovecs <= BIO_MAX_VECS);
> + if (nr_iovecs == 0)
> + nr_iovecs = BIO_MAX_VECS;
> + bio = bio_alloc_bioset(GFP_NOFS, nr_iovecs, &btrfs_bioset);
> btrfs_io_bio_init(btrfs_io_bio(bio));
> return bio;
> }
next prev parent reply other threads:[~2021-09-14 16:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 1:25 [PATCH v2 0/3] btrfs: btrfs_bio and btrfs_io_bio rename Qu Wenruo
2021-09-14 1:25 ` [PATCH v2 1/3] btrfs: rename btrfs_bio to btrfs_io_context Qu Wenruo
2021-09-14 16:42 ` David Sterba
2021-09-15 6:02 ` Qu Wenruo
2021-09-14 1:25 ` [PATCH v2 2/3] btrfs: remove btrfs_bio_alloc() helper Qu Wenruo
2021-09-14 16:45 ` David Sterba [this message]
2021-09-14 1:25 ` [PATCH v2 3/3] btrfs: rename struct btrfs_io_bio to btrfs_bio Qu Wenruo
2021-09-14 16:49 ` David Sterba
2021-09-14 16:25 ` [PATCH v2 0/3] btrfs: btrfs_bio and btrfs_io_bio rename David Sterba
2021-09-14 22:20 ` Qu Wenruo
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=20210914164546.GG9286@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@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