block: add rq->resid_len

rq->data_len served two purposes - the length of data buffer on issue
and the residual count on completion.  This duality creates some
headaches.

First of all, block layer and low level drivers can't really determine
what rq->data_len contains while a request is executing.  It could be
the total request length or it coulde be anything else one of the
lower layers is using to keep track of residual count.  This
complicates things because blk_rq_bytes() and thus
[__]blk_end_request_all() relies on rq->data_len for PC commands.
Drivers which want to report residual count should first cache the
total request length, update rq->data_len and then complete the
request with the cached data length.

Secondly, it makes requests default to reporting full residual count,
ie. reporting that no data transfer occurred.  The residual count is
an exception not the norm; however, the driver should clear
rq->data_len to zero to signify the normal cases while leaving it
alone means no data transfer occurred at all.  This reverse default
behavior complicates code unnecessarily and renders block PC on some
drivers (ide-tape/floppy) unuseable.

This patch adds rq->resid_len which is used only for residual count.

While at it, remove now unnecessasry blk_rq_bytes() caching in
ide_pc_intr() as rq->data_len is not changed anymore.

Boaz	: spotted missing conversion in osd
Sergei	: spotted too early conversion to blk_rq_bytes() in ide-tape

[ Impact: cleanup residual count handling, report 0 resid by default ]

Signed-off-by: Tejun Heo <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Sergei Shtylyov <[email protected]>
Cc: Mike Miller <[email protected]>
Cc: Eric Moore <[email protected]>
Cc: Alan Stern <[email protected]>
Cc: FUJITA Tomonori <[email protected]>
Cc: Doug Gilbert <[email protected]>
Cc: Mike Miller <[email protected]>
Cc: Eric Moore <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: Pete Zaitcev <[email protected]>
Cc: Boaz Harrosh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
Tejun Heo 2009-05-07 22:24:37 +09:00 • committed by Jens Axboe
commit c3a4d78c58
16 changed files with 59 additions and 80 deletions

View file

@ -445,14 +445,14 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
}
if (rq->next_rq) {
hdr->dout_resid = rq->data_len;
hdr->din_resid = rq->next_rq->data_len;
hdr->dout_resid = rq->resid_len;
hdr->din_resid = rq->next_rq->resid_len;
blk_rq_unmap_user(bidi_bio);
blk_put_request(rq->next_rq);
} else if (rq_data_dir(rq) == READ)
hdr->din_resid = rq->data_len;
hdr->din_resid = rq->resid_len;
else
hdr->dout_resid = rq->data_len;
hdr->dout_resid = rq->resid_len;
/*
* If the request generated a negative error number, return it