Commit 6ebae79a authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] bio_alloc() cleanup

de-spaghettify this function.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent eb3b83ad
......@@ -137,33 +137,29 @@ inline void bio_init(struct bio *bio)
**/
struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
{
struct bio_vec *bvl = NULL;
unsigned long idx;
struct bio *bio;
struct bio *bio = mempool_alloc(bio_pool, gfp_mask);
bio = mempool_alloc(bio_pool, gfp_mask);
if (unlikely(!bio))
goto out;
if (likely(bio)) {
struct bio_vec *bvl = NULL;
bio_init(bio);
if (unlikely(!nr_iovecs))
goto noiovec;
if (likely(nr_iovecs)) {
unsigned long idx;
bvl = bvec_alloc(gfp_mask, nr_iovecs, &idx);
if (bvl) {
if (unlikely(!bvl)) {
mempool_free(bio, bio_pool);
bio = NULL;
goto out;
}
bio->bi_flags |= idx << BIO_POOL_OFFSET;
bio->bi_max_vecs = bvec_array[idx].nr_vecs;
noiovec:
}
bio->bi_io_vec = bvl;
bio->bi_destructor = bio_destructor;
}
out:
return bio;
}
mempool_free(bio, bio_pool);
bio = NULL;
goto out;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment