Re: [PATCH v6 06/13] block: Consolidate bio_alloc_bioset(),bio_kmalloc()
From: Tejun Heo
Date: Fri Aug 24 2012 - 16:08:35 EST
Hello,
On Thu, Aug 23, 2012 at 10:04:00PM -0700, Kent Overstreet wrote:
> > > 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.
>
> Having arbitrary limits that are different for kmalloced bios and bioset
> allocated bios seems _very_ sketchy to me. I tend to think that
> UIO_MAXIOV check shouldn't be there at all... but if it is IMO it makes
> slightly more sense for it to apply to all bio allocations.
>
> As you mentioned it doesn't affect the behaviour of the code, but
> supposing UIO_MAXIOV was less than BIO_MAX_PAGES, whatever was depending
> on that check would then implicitly depend on the bios not being
> allocated from a bioset. Ugly.
Please keep UIO_MAXIOV test on kmalloc case only. If you want to
change that, please do that in a separate patch with its own
justification.
> > 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.
>
> So if I follow you, you're fine with dropping the comments from the
> single line wrappers provided their information is rolled into
> bio_alloc_bioset()'s documentation? That's what I should have done,
> I'll do that now.
Not really, for example, if you had
/* explain A in detail */
a() {};
and if you introduce __a() which does __A and make a its wrapper.
/* explain __A in detail */
__a() {};
/* explain A briefly and refer to __a() for details */
a() {};
Thanks.
--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/