diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2009-05-17 18:57:15 +0300 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-19 12:14:56 +0200 |
commit | 79eb63e9e5875b84341a3a05f8e6ae9cdb4bb6f6 (patch) | |
tree | bdadc2037c1d0f24c6c73b71ae82fdd7b907e610 /block | |
parent | bc38bf106c967389a465d926be22c7371abba69d (diff) | |
download | linux-stable-79eb63e9e5875b84341a3a05f8e6ae9cdb4bb6f6.tar.gz linux-stable-79eb63e9e5875b84341a3a05f8e6ae9cdb4bb6f6.tar.bz2 linux-stable-79eb63e9e5875b84341a3a05f8e6ae9cdb4bb6f6.zip |
block: Add blk_make_request(), takes bio, returns a request
New block API:
given a struct bio allocates a new request. This is the parallel of
generic_make_request for BLOCK_PC commands users.
The passed bio may be a chained-bio. The bio is bounced if needed
inside the call to this member.
This is in the effort of un-exporting blk_rq_append_bio().
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
CC: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index e3f7e6a3a095..bec1d69952d0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -891,6 +891,51 @@ struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask) EXPORT_SYMBOL(blk_get_request); /** + * blk_make_request - given a bio, allocate a corresponding struct request. + * + * @bio: The bio describing the memory mappings that will be submitted for IO. + * It may be a chained-bio properly constructed by block/bio layer. + * + * blk_make_request is the parallel of generic_make_request for BLOCK_PC + * type commands. Where the struct request needs to be farther initialized by + * the caller. It is passed a &struct bio, which describes the memory info of + * the I/O transfer. + * + * The caller of blk_make_request must make sure that bi_io_vec + * are set to describe the memory buffers. That bio_data_dir() will return + * the needed direction of the request. (And all bio's in the passed bio-chain + * are properly set accordingly) + * + * If called under none-sleepable conditions, mapped bio buffers must not + * need bouncing, by calling the appropriate masked or flagged allocator, + * suitable for the target device. Otherwise the call to blk_queue_bounce will + * BUG. + */ +struct request *blk_make_request(struct request_queue *q, struct bio *bio, + gfp_t gfp_mask) +{ + struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask); + + if (unlikely(!rq)) + return ERR_PTR(-ENOMEM); + + for_each_bio(bio) { + struct bio *bounce_bio = bio; + int ret; + + blk_queue_bounce(q, &bounce_bio); + ret = blk_rq_append_bio(q, rq, bounce_bio); + if (unlikely(ret)) { + blk_put_request(rq); + return ERR_PTR(ret); + } + } + + return rq; +} +EXPORT_SYMBOL(blk_make_request); + +/** * blk_requeue_request - put a request back on queue * @q: request queue where request should be inserted * @rq: request to be inserted |