block: implement blk_rq_pos/[cur_]sectors() and convert obvious ones

Implement accessors - blk_rq_pos(), blk_rq_sectors() and
blk_rq_cur_sectors() which return rq->hard_sector, rq->hard_nr_sectors
and rq->hard_cur_sectors respectively and convert direct references of
the said fields to the accessors.

This is in preparation of request data length handling cleanup.

Geert	: suggested adding const to struct request * parameter to accessors
Sergei	: spotted error in patch description

[ Impact: cleanup ]

Signed-off-by: Tejun Heo <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>
Acked-by: Stephen Rothwell <[email protected]>
Tested-by: Grant Likely <[email protected]>
Acked-by: Grant Likely <[email protected]>
Ackec-by: Sergei Shtylyov <[email protected]>
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: James Bottomley <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
Tejun Heo 2009-05-07 22:24:38 +09:00 • committed by Jens Axboe
commit 5b93629b45
12 changed files with 42 additions and 25 deletions

View file

@ -163,7 +163,7 @@ static inline bool start_ordered(struct request_queue *q, struct request **rqp)
* For an empty barrier, there's no actual BAR request, which
* in turn makes POSTFLUSH unnecessary. Mask them off.
*/
if (!rq->hard_nr_sectors) {
if (!blk_rq_sectors(rq)) {
q->ordered &= ~(QUEUE_ORDERED_DO_BAR |
QUEUE_ORDERED_DO_POSTFLUSH);
/*

View file

@ -1683,7 +1683,7 @@ static void blk_account_io_done(struct request *req)
unsigned int blk_rq_bytes(struct request *rq)
{
if (blk_fs_request(rq))
return rq->hard_nr_sectors << 9;
return blk_rq_sectors(rq) << 9;
return rq->data_len;
}

View file

@ -760,7 +760,7 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq)
cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "activate rq, drv=%d",
cfqd->rq_in_driver);
cfqd->last_position = rq->hard_sector + rq->hard_nr_sectors;
cfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq);
}
static void cfq_deactivate_request(struct request_queue *q, struct request *rq)