From: Boaz Harrosh <bharrosh@panasas.com>
To: Kent Overstreet <koverstreet@google.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-bcache@vger.kernel.org>,
<dm-devel@redhat.com>, <linux-fsdevel@vger.kernel.org>,
<tj@kernel.org>, <axboe@kernel.dk>, <agk@redhat.com>,
<neilb@suse.de>, <drbd-dev@lists.linbit.com>, <vgoyal@redhat.com>,
<mpatocka@redhat.com>, <sage@newdream.net>,
<yehuda@hq.newdream.net>
Subject: Re: [PATCH v3 01/16] block: Generalized bio pool freeing
Date: Mon, 28 May 2012 13:04:06 +0300 [thread overview]
Message-ID: <4FC34D96.30402@panasas.com> (raw)
In-Reply-To: <1337977539-16977-2-git-send-email-koverstreet@google.com>
On 05/25/2012 11:25 PM, Kent Overstreet wrote:
<snip>
> diff --git a/fs/bio.c b/fs/bio.c
> index e453924..3667cef 100644
> --- a/fs/bio.c
> +++ b/fs/bio.c
> @@ -269,10 +269,6 @@ EXPORT_SYMBOL(bio_init);
> * bio_alloc_bioset will try its own mempool to satisfy the allocation.
> * If %__GFP_WAIT is set then we will block on the internal pool waiting
> * for a &struct bio to become free.
> - *
> - * Note that the caller must set ->bi_destructor on successful return
> - * of a bio, to do the appropriate freeing of the bio once the reference
> - * count drops to zero.
> **/
> struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
> {
> @@ -287,6 +283,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
> bio = p + bs->front_pad;
>
> bio_init(bio);
> + bio->bi_pool = bs;
>
I really hate it that people in the Kernel at some point decided
to name bio_set(s) "pool". This is against Kernel style guide.
You don't overload the namespace and you don't call one-thing
another-thing.
For one "pool"s are already another thing. And for-most the struct
is bio_set a pointer to it should be called bio_set or in short
bs.
The original bio_set code kept the "bio_set" and/or "bs" naming
conventions. But later code. Kept breaking it with "pool". In
code and in comments.
But this Patch is the most blasphemous of all because it's
the first instance of block core code that calls it a "pool".
Up to now bio core kept the bio_set naming.
Please change the name to bi_bs so we can have:
+ bio->bi_bs = bs;
For me above code is an immediate alarm in my mind. Rrrr
false alarm. Please don't let my poor old mind Jump
unnecessarily.
> if (unlikely(!nr_iovecs))
> goto out_set;
> @@ -313,11 +310,6 @@ err_free:
> }
> EXPORT_SYMBOL(bio_alloc_bioset);
>
> -static void bio_fs_destructor(struct bio *bio)
> -{
> - bio_free(bio, fs_bio_set);
> -}
> -
> /**
> * bio_alloc - allocate a new bio, memory pool backed
> * @gfp_mask: allocation mask to use
> @@ -339,12 +331,7 @@ static void bio_fs_destructor(struct bio *bio)
> */
> struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
> {
> - struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
> -
> - if (bio)
> - bio->bi_destructor = bio_fs_destructor;
> -
> - return bio;
> + return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
> }
> EXPORT_SYMBOL(bio_alloc);
>
> @@ -419,7 +406,11 @@ void bio_put(struct bio *bio)
> */
> if (atomic_dec_and_test(&bio->bi_cnt)) {
> bio->bi_next = NULL;
> - bio->bi_destructor(bio);
> +
> + if (bio->bi_pool)
> + bio_free(bio, bio->bi_pool);
> + else
> + bio->bi_destructor(bio);
> }
> }
> EXPORT_SYMBOL(bio_put);
> @@ -470,12 +461,11 @@ EXPORT_SYMBOL(__bio_clone);
> */
> struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
> {
> - struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set);
> + struct bio *b = bio_alloc(gfp_mask, bio->bi_max_vecs);
>
> if (!b)
> return NULL;
>
> - b->bi_destructor = bio_fs_destructor;
> __bio_clone(b, bio);
>
> if (bio_integrity(bio)) {
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 4053cbd..dc0e399 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -70,6 +70,9 @@ struct bio {
> struct bio_integrity_payload *bi_integrity; /* data integrity */
> #endif
>
> + /* If bi_pool is non NULL, bi_destructor is not called */
> + struct bio_set *bi_pool;
> +
Please, Please , Please Don't forget this time.
bi_bs.
Pools are something a bit different (though related) in the
Kernel.
> bio_destructor_t *bi_destructor; /* destructor */
>
> /*
BTW: I would have loved it if some brave sole would go and
rename struct bio_set => bio_pool. Because when we speak
about them they are pools. (And very much related to memory pools)
And actually a set is something else. This here is definitely
a pool. Because a set is a group of objects that have a relating
trait, a relationship, a uniting factor. Its when we want to act
on a group of objects as one unit.
Thanks
Boaz
next prev parent reply other threads:[~2012-05-28 10:04 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-25 20:25 [PATCH v3 00/16] Block cleanups Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 01/16] block: Generalized bio pool freeing Kent Overstreet
2012-05-28 1:15 ` Tejun Heo
2012-05-28 10:04 ` Boaz Harrosh [this message]
2012-05-25 20:25 ` [PATCH v3 02/16] dm: Use bioset's front_pad for dm_rq_clone_bio_info Kent Overstreet
2012-05-28 0:57 ` [dm-devel] " Jun'ichi Nomura
2012-05-28 11:41 ` Jun'ichi Nomura
2012-05-28 1:21 ` Tejun Heo
2012-05-25 20:25 ` [PATCH v3 03/16] block: Add bio_reset() Kent Overstreet
2012-05-28 1:23 ` Tejun Heo
2012-05-28 10:02 ` Boaz Harrosh
2012-05-25 20:25 ` [PATCH v3 04/16] pktcdvd: Switch to bio_kmalloc() Kent Overstreet
2012-05-28 1:30 ` Tejun Heo
2012-05-25 20:25 ` [PATCH v3 05/16] block: Kill bi_destructor Kent Overstreet
2012-05-28 1:36 ` Tejun Heo
2012-05-29 2:10 ` Kent Overstreet
2012-05-29 2:20 ` Tejun Heo
2012-05-25 20:25 ` [PATCH v3 06/16] block: Add an explicit bio flag for bios that own their bvec Kent Overstreet
2012-05-28 1:52 ` Tejun Heo
2012-05-25 20:25 ` [PATCH v3 07/16] block: Rename bio_split() -> bio_pair_split() Kent Overstreet
2012-05-28 10:15 ` Boaz Harrosh
2012-05-29 2:15 ` Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 08/16] block: Rework bio splitting Kent Overstreet
2012-05-28 16:12 ` Mikulas Patocka
2012-05-25 20:25 ` [PATCH v3 09/16] block: Add bio_clone_kmalloc() Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 10/16] block: Add bio_clone_bioset() Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 11/16] block: Only clone bio vecs that are in use Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 12/16] Closures Kent Overstreet
2012-05-25 20:57 ` Joe Perches
2012-05-25 21:35 ` Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 13/16] Make generic_make_request handle arbitrarily large bios Kent Overstreet
2012-05-25 22:58 ` Alasdair G Kergon
2012-05-25 23:12 ` Alasdair G Kergon
2012-05-26 0:18 ` Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 14/16] Gut bio_add_page() Kent Overstreet
2012-05-25 20:46 ` Mike Snitzer
2012-05-25 21:09 ` Kent Overstreet
2012-05-25 22:39 ` Alasdair G Kergon
2012-05-28 16:07 ` Mikulas Patocka
2012-05-28 20:28 ` Tejun Heo
2012-05-28 21:27 ` Mikulas Patocka
2012-05-28 21:38 ` Tejun Heo
2012-05-28 23:02 ` Tejun Heo
2012-05-29 2:08 ` Dave Chinner
2012-05-29 2:15 ` Tejun Heo
2012-05-29 3:36 ` Kent Overstreet
2012-05-29 2:07 ` Dave Chinner
2012-05-29 1:54 ` Dave Chinner
2012-05-29 3:34 ` Kent Overstreet
2012-06-05 0:33 ` Dave Chinner
2012-05-25 20:25 ` [PATCH v3 15/16] md: Kill merge_bvec_fn()s Kent Overstreet
2012-05-25 20:25 ` [PATCH v3 16/16] dm: Kill merge_bvec_fn() 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=4FC34D96.30402@panasas.com \
--to=bharrosh@panasas.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=koverstreet@google.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=neilb@suse.de \
--cc=sage@newdream.net \
--cc=tj@kernel.org \
--cc=vgoyal@redhat.com \
--cc=yehuda@hq.newdream.net \
/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