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) ...@@ -137,33 +137,29 @@ inline void bio_init(struct bio *bio)
**/ **/
struct bio *bio_alloc(int gfp_mask, int nr_iovecs) struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
{ {
struct bio_vec *bvl = NULL; struct bio *bio = mempool_alloc(bio_pool, gfp_mask);
unsigned long idx;
struct bio *bio;
bio = mempool_alloc(bio_pool, gfp_mask); if (likely(bio)) {
if (unlikely(!bio)) struct bio_vec *bvl = NULL;
goto out;
bio_init(bio); bio_init(bio);
if (likely(nr_iovecs)) {
if (unlikely(!nr_iovecs)) unsigned long idx;
goto noiovec;
bvl = bvec_alloc(gfp_mask, nr_iovecs, &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_flags |= idx << BIO_POOL_OFFSET;
bio->bi_max_vecs = bvec_array[idx].nr_vecs; bio->bi_max_vecs = bvec_array[idx].nr_vecs;
noiovec: }
bio->bi_io_vec = bvl; bio->bi_io_vec = bvl;
bio->bi_destructor = bio_destructor; bio->bi_destructor = bio_destructor;
}
out: out:
return bio; 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