[PATCH 2/5] block: add a bio_chain_and_submit helper
Christoph Hellwig
hch at lst.de
Tue Mar 12 14:06:05 PDT 2024
On Tue, Mar 12, 2024 at 08:51:35AM -0600, Keith Busch wrote:
> > +
> > +struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev,
> > + unsigned int nr_pages, blk_opf_t opf, gfp_t gfp)
> > +{
> > + return bio_chain_and_submit(bio, bio_alloc(bdev, nr_pages, opf, gfp));
> > +}
>
> I realize you're not changing any behavior here, but I want to ask, is
> bio_alloc() always guaranteed to return a valid bio? It sure looks like
> it can return NULL under some uncommon conditions, but I can't find
> anyone checking the result. So I guess it's safe?
bio_alloc can only fail if we don't wait for allocations, that is if
__GFP_DIRECT_RECLAIM isn't set.
We could an assert here. Or work on killing the gfp_flags argument
and just add a bio_alloc_nowait for the few cases that need it.
More information about the Linux-nvme
mailing list