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: Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v3 2/3] btrfs: remove btrfs_bio_alloc() helper
Date: Fri, 17 Sep 2021 14:43:41 +0200	[thread overview]
Message-ID: <20210917124341.GS9286@twin.jikos.cz> (raw)
In-Reply-To: <a4380e7b-b728-fd85-b6c1-175a53f6a1ce@suse.com>

On Fri, Sep 17, 2021 at 03:27:44PM +0300, Nikolay Borisov wrote:
> > -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;
> 
> hell no! How come passing 0 actually means BIO_MAX_VEC. Instead of
> having 0 everywhere and have the function translate this to
> BIO_MAX_VECS, simply pass BIO_MAX_VECS in every call site where it's
> needed.

I had thought about that before and cocluded that passing BIO_MAX_VECS
everywhere would be the wrong way as it's a detail about how many bio
vecs are allocated. So 0 is a default is ok as any other number means
that it's the exact count.

> David, please either fix the patch in the tree or retract it. Let's try
> and refrain from adding such "gems" to the code base.

So should we add another helper that takes the exact number and drop the
parameter everwhere is 0 so it's just btrfs_io_bio_alloc() with the
fallback?

  parent reply	other threads:[~2021-09-17 12:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  7:17 [PATCH v3 0/3] btrfs: btrfs_bio and btrfs_io_bio rename Qu Wenruo
2021-09-15  7:17 ` [PATCH v3 1/3] btrfs: rename btrfs_bio to btrfs_io_context Qu Wenruo
2021-09-17 11:19   ` David Sterba
2021-09-17 11:24     ` Qu Wenruo
2021-09-17 11:27       ` Qu Wenruo
2021-09-17 11:33         ` David Sterba
2021-09-15  7:17 ` [PATCH v3 2/3] btrfs: remove btrfs_bio_alloc() helper Qu Wenruo
2021-09-17 12:27   ` Nikolay Borisov
2021-09-17 12:33     ` Qu Wenruo
2021-09-17 12:34       ` Nikolay Borisov
2021-09-17 12:43     ` David Sterba [this message]
2021-09-17 12:49       ` Nikolay Borisov
2021-09-20 10:33         ` Qu Wenruo
2021-09-20 12:41           ` David Sterba
2021-09-20 12:42             ` Qu Wenruo
2021-09-23  5:57   ` Qu Wenruo
2021-09-15  7:17 ` [PATCH v3 3/3] btrfs: rename struct btrfs_io_bio to btrfs_logical_bio Qu Wenruo
2021-09-17 11:39   ` David Sterba
2021-09-20  7:04   ` Nikolay Borisov
2021-09-20 12:23     ` David Sterba
2021-09-20 13:10       ` David Sterba
2021-09-17 11:39 ` [PATCH v3 0/3] btrfs: btrfs_bio and btrfs_io_bio rename 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=20210917124341.GS9286@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    --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