blk_end_request: changing block layer core (take 4)

This patch converts core parts of block layer to use blk_end_request
interfaces.  Related 'uptodate' arguments are converted to 'error'.

'dequeue' argument was originally introduced for end_dequeued_request(),
where no attempt should be made to dequeue the request as it's already
dequeued.
However, it's not necessary as it can be checked with
list_empty(&rq->queuelist).
(Dequeued request has empty list and queued request doesn't.)
And it has been done in blk_end_request interfaces.

As a result of this patch, end_queued_request() and
end_dequeued_request() become identical.  A future patch will merge
and rename them and change users of those functions.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
Kiyoshi Ueda 2007-12-11 17:41:54 -05:00 committed by Jens Axboe
parent 3b11313a6c
commit 9e6e39f2c4
1 changed files with 15 additions and 20 deletions

View File

@ -347,7 +347,6 @@ unsigned blk_ordered_req_seq(struct request *rq)
void blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error) void blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error)
{ {
struct request *rq; struct request *rq;
int uptodate;
if (error && !q->orderr) if (error && !q->orderr)
q->orderr = error; q->orderr = error;
@ -361,15 +360,11 @@ void blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error)
/* /*
* Okay, sequence complete. * Okay, sequence complete.
*/ */
uptodate = 1;
if (q->orderr)
uptodate = q->orderr;
q->ordseq = 0; q->ordseq = 0;
rq = q->orig_bar_rq; rq = q->orig_bar_rq;
end_that_request_first(rq, uptodate, rq->hard_nr_sectors); if (__blk_end_request(rq, q->orderr, blk_rq_bytes(rq)))
end_that_request_last(rq, uptodate); BUG();
} }
static void pre_flush_end_io(struct request *rq, int error) static void pre_flush_end_io(struct request *rq, int error)
@ -486,9 +481,9 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp)
* ORDERED_NONE while this request is on it. * ORDERED_NONE while this request is on it.
*/ */
blkdev_dequeue_request(rq); blkdev_dequeue_request(rq);
end_that_request_first(rq, -EOPNOTSUPP, if (__blk_end_request(rq, -EOPNOTSUPP,
rq->hard_nr_sectors); blk_rq_bytes(rq)))
end_that_request_last(rq, -EOPNOTSUPP); BUG();
*rqp = NULL; *rqp = NULL;
return 0; return 0;
} }
@ -3713,14 +3708,14 @@ void end_that_request_last(struct request *req, int uptodate)
EXPORT_SYMBOL(end_that_request_last); EXPORT_SYMBOL(end_that_request_last);
static inline void __end_request(struct request *rq, int uptodate, static inline void __end_request(struct request *rq, int uptodate,
unsigned int nr_bytes, int dequeue) unsigned int nr_bytes)
{ {
if (!end_that_request_chunk(rq, uptodate, nr_bytes)) { int error = 0;
if (dequeue)
blkdev_dequeue_request(rq); if (uptodate <= 0)
add_disk_randomness(rq->rq_disk); error = uptodate ? uptodate : -EIO;
end_that_request_last(rq, uptodate);
} __blk_end_request(rq, error, nr_bytes);
} }
/** /**
@ -3763,7 +3758,7 @@ EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);
**/ **/
void end_queued_request(struct request *rq, int uptodate) void end_queued_request(struct request *rq, int uptodate)
{ {
__end_request(rq, uptodate, blk_rq_bytes(rq), 1); __end_request(rq, uptodate, blk_rq_bytes(rq));
} }
EXPORT_SYMBOL(end_queued_request); EXPORT_SYMBOL(end_queued_request);
@ -3780,7 +3775,7 @@ EXPORT_SYMBOL(end_queued_request);
**/ **/
void end_dequeued_request(struct request *rq, int uptodate) void end_dequeued_request(struct request *rq, int uptodate)
{ {
__end_request(rq, uptodate, blk_rq_bytes(rq), 0); __end_request(rq, uptodate, blk_rq_bytes(rq));
} }
EXPORT_SYMBOL(end_dequeued_request); EXPORT_SYMBOL(end_dequeued_request);
@ -3806,7 +3801,7 @@ EXPORT_SYMBOL(end_dequeued_request);
**/ **/
void end_request(struct request *req, int uptodate) void end_request(struct request *req, int uptodate)
{ {
__end_request(req, uptodate, req->hard_cur_sectors << 9, 1); __end_request(req, uptodate, req->hard_cur_sectors << 9);
} }
EXPORT_SYMBOL(end_request); EXPORT_SYMBOL(end_request);