From: Tejun Heo <tj@kernel.org>
To: Kent Overstreet <koverstreet@google.com>
Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
dm-devel@redhat.com, vgoyal@redhat.com, mpatocka@redhat.com,
bharrosh@panasas.com, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v6 06/13] block: Consolidate bio_alloc_bioset(), bio_kmalloc()
Date: Wed, 22 Aug 2012 13:17:30 -0700 [thread overview]
Message-ID: <20120822201730.GI19212@google.com> (raw)
In-Reply-To: <1345655050-28199-7-git-send-email-koverstreet@google.com>
Hello,
On Wed, Aug 22, 2012 at 10:04:03AM -0700, Kent Overstreet wrote:
> Previously, bio_kmalloc() and bio_alloc_bioset() behaved slightly
> different because there was some almost-duplicated code - this fixes
> that issue.
What were those slight differences? Why is it safe to change the
behaviors to match each other?
> struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
> {
> + unsigned front_pad;
> + unsigned inline_vecs;
> unsigned long idx = BIO_POOL_NONE;
> struct bio_vec *bvl = NULL;
> struct bio *bio;
> void *p;
>
> - p = mempool_alloc(bs->bio_pool, gfp_mask);
> + if (nr_iovecs > UIO_MAXIOV)
> + return NULL;
This test used to only happen for bio_kmalloc(). If I follow the code
I can see that UIO_MAXIOV is larger than BIOVEC_MAX_IDX, so this
doesn't really affect the capability of bioset allocs; however, given
that bioset allocation already checks against BIOVEC_MAX_IDX, I don't
see why this test is now also applied to them.
> + if (bs == BIO_KMALLOC_POOL) {
> + p = kmalloc(sizeof(struct bio) +
> + nr_iovecs * sizeof(struct bio_vec),
> + gfp_mask);
> + front_pad = 0;
> + inline_vecs = nr_iovecs;
> + } else {
> + p = mempool_alloc(bs->bio_pool, gfp_mask);
> + front_pad = bs->front_pad;
> + inline_vecs = BIO_INLINE_VECS;
> + }
> +
> if (unlikely(!p))
> return NULL;
> - bio = p + bs->front_pad;
>
> + bio = p + front_pad;
> bio_init(bio);
> - bio->bi_pool = bs;
>
> - if (unlikely(!nr_iovecs))
> - goto out_set;
> -
> - if (nr_iovecs <= BIO_INLINE_VECS) {
> - bvl = bio->bi_inline_vecs;
> - nr_iovecs = BIO_INLINE_VECS;
> - } else {
> + if (nr_iovecs > inline_vecs) {
> bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
> if (unlikely(!bvl))
> goto err_free;
> -
> - nr_iovecs = bvec_nr_vecs(idx);
> + } else if (nr_iovecs) {
> + bvl = bio->bi_inline_vecs;
> }
> -out_set:
> +
> + bio->bi_pool = bs;
> bio->bi_flags |= idx << BIO_POOL_OFFSET;
> bio->bi_max_vecs = nr_iovecs;
> bio->bi_io_vec = bvl;
> @@ -331,63 +340,6 @@ err_free:
> }
> EXPORT_SYMBOL(bio_alloc_bioset);
> +extern struct bio_set *fs_bio_set;
> +
> +static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
> +{
> + return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
> +}
> +
> +#define BIO_KMALLOC_POOL NULL
> +
> +static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs)
> +{
> + return bio_alloc_bioset(gfp_mask, nr_iovecs, BIO_KMALLOC_POOL);
> +}
And we lose /** comments on two exported functions and
bio_alloc_bioset() comment doesn't explain that it now also handles
NULL bioset case. Now that they share common implementation, you can
update bio_alloc_bioset() and refer to it from its wrappers but please
don't drop them like this.
Thanks.
--
tejun
next prev parent reply other threads:[~2012-08-22 20:17 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-22 17:03 [PATCH v6 00/13] Block cleanups Kent Overstreet
2012-08-22 17:03 ` [PATCH v6 01/13] block: Generalized bio pool freeing Kent Overstreet
2012-08-22 21:27 ` Nicholas A. Bellinger
2012-08-22 17:03 ` [PATCH v6 02/13] dm: Use bioset's front_pad for dm_rq_clone_bio_info Kent Overstreet
2012-08-22 18:32 ` Tejun Heo
2012-08-22 21:30 ` Vivek Goyal
2012-08-24 7:14 ` Kent Overstreet
2012-08-24 18:40 ` Vivek Goyal
2012-08-22 17:04 ` [PATCH v6 03/13] block: Add bio_reset() Kent Overstreet
2012-08-22 18:34 ` Tejun Heo
2012-08-22 19:51 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 04/13] pktcdvd: Switch to bio_kmalloc() Kent Overstreet
2012-08-22 19:55 ` Tejun Heo
2012-08-28 23:19 ` Jiri Kosina
2012-08-29 4:35 ` Peter Osterlund
2012-09-03 16:15 ` Jiri Kosina
2012-08-22 17:04 ` [PATCH v6 05/13] block: Kill bi_destructor Kent Overstreet
2012-08-22 20:00 ` Tejun Heo
2012-08-24 5:09 ` Kent Overstreet
2012-08-22 17:04 ` [PATCH v6 06/13] block: Consolidate bio_alloc_bioset(), bio_kmalloc() Kent Overstreet
2012-08-22 20:17 ` Tejun Heo [this message]
2012-08-24 5:04 ` Kent Overstreet
2012-08-24 20:08 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 07/13] block: Avoid deadlocks with bio allocation by stacking drivers Kent Overstreet
2012-08-22 20:30 ` Tejun Heo
2012-08-24 5:55 ` Kent Overstreet
2012-08-24 20:28 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 08/13] block: Add an explicit bio flag for bios that own their bvec Kent Overstreet
2012-08-22 17:43 ` Adrian Bunk
2012-08-22 19:22 ` Kent Overstreet
2012-08-22 20:00 ` Adrian Bunk
2012-08-28 17:23 ` Kent Overstreet
2012-08-22 17:04 ` [PATCH v6 09/13] block: Rename bio_split() -> bio_pair_split() Kent Overstreet
2012-08-22 17:04 ` [PATCH v6 10/13] block: Introduce new bio_split() Kent Overstreet
2012-08-22 20:46 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 11/13] block: Rework bio_pair_split() Kent Overstreet
2012-08-22 21:04 ` Tejun Heo
2012-08-24 2:25 ` Martin K. Petersen
2012-08-24 10:37 ` Kent Overstreet
2012-08-24 20:58 ` Tejun Heo
2012-08-24 10:30 ` Kent Overstreet
2012-08-24 20:53 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 12/13] block: Add bio_clone_bioset(), bio_clone_kmalloc() Kent Overstreet
2012-08-22 17:13 ` Jeff Garzik
2012-08-22 21:07 ` Tejun Heo
2012-08-24 6:24 ` Kent Overstreet
2012-08-24 20:36 ` Tejun Heo
2012-08-22 17:04 ` [PATCH v6 13/13] block: Only clone bio vecs that are in use Kent Overstreet
2012-08-22 21:10 ` Tejun Heo
2012-08-24 7:05 ` Kent Overstreet
2012-08-24 20:42 ` Tejun Heo
2012-08-23 18:00 ` [PATCH v6 00/13] Block cleanups Vivek Goyal
2012-08-24 12:46 ` Kent Overstreet
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=20120822201730.GI19212@google.com \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=bharrosh@panasas.com \
--cc=dm-devel@redhat.com \
--cc=koverstreet@google.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=vgoyal@redhat.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;
as well as URLs for NNTP newsgroup(s).