aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@suse.de>2010-07-01 06:49:17 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:23:47 -0400
commit28018c242a4ec7017bbbf81d2d3952f820a27118 (patch)
tree03732bef20d0e4dad30d81d9b9ad9ffcf5a2e41c /block
parente597cd09f711b28b8466ebdc2f12e55b44fa81e4 (diff)
block: implement an unprep function corresponding directly to prep
Reviewed-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-core.c25
-rw-r--r--block/blk-settings.c17
2 files changed, 42 insertions, 0 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 3c3789492c10..5ab3ac22930c 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -608,6 +608,7 @@ blk_init_allocated_queue_node(struct request_queue *q, request_fn_proc *rfn,
608 608
609 q->request_fn = rfn; 609 q->request_fn = rfn;
610 q->prep_rq_fn = NULL; 610 q->prep_rq_fn = NULL;
611 q->unprep_rq_fn = NULL;
611 q->unplug_fn = generic_unplug_device; 612 q->unplug_fn = generic_unplug_device;
612 q->queue_flags = QUEUE_FLAG_DEFAULT; 613 q->queue_flags = QUEUE_FLAG_DEFAULT;
613 q->queue_lock = lock; 614 q->queue_lock = lock;
@@ -2133,6 +2134,26 @@ static bool blk_update_bidi_request(struct request *rq, int error,
2133 return false; 2134 return false;
2134} 2135}
2135 2136
2137/**
2138 * blk_unprep_request - unprepare a request
2139 * @req: the request
2140 *
2141 * This function makes a request ready for complete resubmission (or
2142 * completion). It happens only after all error handling is complete,
2143 * so represents the appropriate moment to deallocate any resources
2144 * that were allocated to the request in the prep_rq_fn. The queue
2145 * lock is held when calling this.
2146 */
2147void blk_unprep_request(struct request *req)
2148{
2149 struct request_queue *q = req->q;
2150
2151 req->cmd_flags &= ~REQ_DONTPREP;
2152 if (q->unprep_rq_fn)
2153 q->unprep_rq_fn(q, req);
2154}
2155EXPORT_SYMBOL_GPL(blk_unprep_request);
2156
2136/* 2157/*
2137 * queue lock must be held 2158 * queue lock must be held
2138 */ 2159 */
@@ -2148,6 +2169,10 @@ static void blk_finish_request(struct request *req, int error)
2148 2169
2149 blk_delete_timer(req); 2170 blk_delete_timer(req);
2150 2171
2172 if (req->cmd_flags & REQ_DONTPREP)
2173 blk_unprep_request(req);
2174
2175
2151 blk_account_io_done(req); 2176 blk_account_io_done(req);
2152 2177
2153 if (req->end_io) 2178 if (req->end_io)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index f5ed5a1187ba..a234f4bf1d6f 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -37,6 +37,23 @@ void blk_queue_prep_rq(struct request_queue *q, prep_rq_fn *pfn)
37EXPORT_SYMBOL(blk_queue_prep_rq); 37EXPORT_SYMBOL(blk_queue_prep_rq);
38 38
39/** 39/**
40 * blk_queue_unprep_rq - set an unprepare_request function for queue
41 * @q: queue
42 * @ufn: unprepare_request function
43 *
44 * It's possible for a queue to register an unprepare_request callback
45 * which is invoked before the request is finally completed. The goal
46 * of the function is to deallocate any data that was allocated in the
47 * prepare_request callback.
48 *
49 */
50void blk_queue_unprep_rq(struct request_queue *q, unprep_rq_fn *ufn)
51{
52 q->unprep_rq_fn = ufn;
53}
54EXPORT_SYMBOL(blk_queue_unprep_rq);
55
56/**
40 * blk_queue_merge_bvec - set a merge_bvec function for queue 57 * blk_queue_merge_bvec - set a merge_bvec function for queue
41 * @q: queue 58 * @q: queue
42 * @mbfn: merge_bvec_fn 59 * @mbfn: merge_bvec_fn