Re: What am I doing wrong? submit_bio() suddenly stops working...

From: Peter Zijlstra
Date: Fri Oct 22 2010 - 09:04:35 EST


On Thu, 2010-10-21 at 20:07 +0200, Jens Axboe wrote:
>
> >> + do {
> >> + bio = bio_alloc(GFP_NOIO, nvecs);
> >> + nvecs >>= 1;
> >> + } while (bio == NULL);
> >
> > This is surly bad. bio_alloc must be allowed to fail
> > (Specially with GFP_NOIO). You should only loop down to
> > 1 and then prepare to return -ENOMEM from this function
> > and handle it properly in callers. (Or schedule and wait
> > like below)
>
> Since __GFP_WAIT is set, it'll never return NULL. And as long as you
> don't allocate more than 1 before doing you submit_bio(), it should be
> OK in this case.

__GFP_WAIT can return NULL, on OOM and when the size is over a magic
threshold.

I find it bad form to rely on any allocation not failing.
--
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/