From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: Re: [Bcache v13 02/16] Bio pool freeing Date: Tue, 15 May 2012 09:25:25 -0700 Message-ID: <20120515162525.GC17216@google.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-bcache-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Kent Overstreet Cc: linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org List-Id: linux-bcache@vger.kernel.org On Wed, May 09, 2012 at 11:08:34PM -0400, Kent Overstreet wrote: > When you allocate a bio from a bio pool, to free it you have to know > where it came from; this adds a flag which, if set, means bi_destructor > is the pointer to the pool and bio_put() can do the right thing. > > This is used in bcache, so we can cleanly use per device bio pools. > > Signed-off-by: Kent Overstreet > --- > fs/bio.c | 9 +++++++-- > include/linux/blk_types.h | 2 ++ > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/fs/bio.c b/fs/bio.c > index a965b89..6a967fc 100644 > --- a/fs/bio.c > +++ b/fs/bio.c > @@ -417,7 +418,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_flagged(bio, BIO_HAS_POOL)) > + bio_free(bio, (void *) bio->bi_destructor); > + else > + bio->bi_destructor(bio); Ummm... this is way too cryptic. Please just add another field to bio. Thanks. -- tejun