diff options
author | Tejun Heo <tj@kernel.org> | 2009-05-07 09:24:41 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-11 03:50:54 -0400 |
commit | 2e46e8b27aa57c6bd34b3102b40ee4d0144b4fab (patch) | |
tree | 134f560f66c2af277f0f25e5b85f6c1acaddfc06 /kernel/trace | |
parent | 9780e2dd8254351f6cbe11304849126b51dbd561 (diff) |
block: drop request->hard_* and *nr_sectors
struct request has had a few different ways to represent some
properties of a request. ->hard_* represent block layer's view of the
request progress (completion cursor) and the ones without the prefix
are supposed to represent the issue cursor and allowed to be updated
as necessary by the low level drivers. The thing is that as block
layer supports partial completion, the two cursors really aren't
necessary and only cause confusion. In addition, manual management of
request detail from low level drivers is cumbersome and error-prone at
the very least.
Another interesting duplicate fields are rq->[hard_]nr_sectors and
rq->{hard_cur|current}_nr_sectors against rq->data_len and
rq->bio->bi_size. This is more convoluted than the hard_ case.
rq->[hard_]nr_sectors are initialized for requests with bio but
blk_rq_bytes() uses it only for !pc requests. rq->data_len is
initialized for all request but blk_rq_bytes() uses it only for pc
requests. This causes good amount of confusion throughout block layer
and its drivers and determining the request length has been a bit of
black magic which may or may not work depending on circumstances and
what the specific LLD is actually doing.
rq->{hard_cur|current}_nr_sectors represent the number of sectors in
the contiguous data area at the front. This is mainly used by drivers
which transfers data by walking request segment-by-segment. This
value always equals rq->bio->bi_size >> 9. However, data length for
pc requests may not be multiple of 512 bytes and using this field
becomes a bit confusing.
In general, having multiple fields to represent the same property
leads only to confusion and subtle bugs. With recent block low level
driver cleanups, no driver is accessing or manipulating these
duplicate fields directly. Drop all the duplicates. Now rq->sector
means the current sector, rq->data_len the current total length and
rq->bio->bi_size the current segment length. Everything else is
defined in terms of these three and available only through accessors.
* blk_recalc_rq_sectors() is collapsed into blk_update_request() and
now handles pc and fs requests equally other than rq->sector update.
This means that now pc requests can use partial completion too (no
in-kernel user yet tho).
* bio_cur_sectors() is replaced with bio_cur_bytes() as block layer
now uses byte count as the primary data length.
* blk_rq_pos() is now guranteed to be always correct. In-block users
converted.
* blk_rq_bytes() is now guaranteed to be always valid as is
blk_rq_sectors(). In-block users converted.
* blk_rq_sectors() is now guaranteed to equal blk_rq_bytes() >> 9.
More convenient one is used.
* blk_rq_bytes() and blk_rq_cur_bytes() are now inlined and take const
pointer to request.
[ Impact: API cleanup, single way to represent one property of a request ]
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/blktrace.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 42f1c11e754c..5708a14bee54 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -642,12 +642,12 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, | |||
642 | 642 | ||
643 | if (blk_pc_request(rq)) { | 643 | if (blk_pc_request(rq)) { |
644 | what |= BLK_TC_ACT(BLK_TC_PC); | 644 | what |= BLK_TC_ACT(BLK_TC_PC); |
645 | __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, | 645 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), rw, |
646 | rq->cmd_len, rq->cmd); | 646 | what, rq->errors, rq->cmd_len, rq->cmd); |
647 | } else { | 647 | } else { |
648 | what |= BLK_TC_ACT(BLK_TC_FS); | 648 | what |= BLK_TC_ACT(BLK_TC_FS); |
649 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_sectors(rq) << 9, | 649 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), rw, |
650 | rw, what, rq->errors, 0, NULL); | 650 | what, rq->errors, 0, NULL); |
651 | } | 651 | } |
652 | } | 652 | } |
653 | 653 | ||
@@ -854,11 +854,11 @@ void blk_add_driver_data(struct request_queue *q, | |||
854 | return; | 854 | return; |
855 | 855 | ||
856 | if (blk_pc_request(rq)) | 856 | if (blk_pc_request(rq)) |
857 | __blk_add_trace(bt, 0, rq->data_len, 0, BLK_TA_DRV_DATA, | 857 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), 0, |
858 | rq->errors, len, data); | 858 | BLK_TA_DRV_DATA, rq->errors, len, data); |
859 | else | 859 | else |
860 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_sectors(rq) << 9, | 860 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), 0, |
861 | 0, BLK_TA_DRV_DATA, rq->errors, len, data); | 861 | BLK_TA_DRV_DATA, rq->errors, len, data); |
862 | } | 862 | } |
863 | EXPORT_SYMBOL_GPL(blk_add_driver_data); | 863 | EXPORT_SYMBOL_GPL(blk_add_driver_data); |
864 | 864 | ||