block: blk_rq_[cur_]_{sectors|bytes}() usage cleanup

With the previous changes, the followings are now guaranteed for all
requests in any valid state.

* blk_rq_sectors() == blk_rq_bytes() >> 9
* blk_rq_cur_sectors() == blk_rq_cur_bytes() >> 9

Clean up accessor usages.  Notable changes are

* nbd,i2o_block: end_all used instead of explicit byte count
* scsi_lib: unnecessary conditional on request type removed

[ Impact: cleanup ]

Signed-off-by: Tejun Heo <[email protected]>
Cc: Paul Clements <[email protected]>
Cc: Pete Zaitcev <[email protected]>
Cc: Alex Dubov <[email protected]>
Cc: Markus Lidel <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: James Bottomley <[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:45 +09:00 • committed by Jens Axboe
commit 1011c1b9f2
9 changed files with 18 additions and 30 deletions

View file

@ -2512,8 +2512,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
remaining = current_count_sectors << 9;
#ifdef FLOPPY_SANITY_CHECK
if ((remaining >> 9) > blk_rq_sectors(current_req) &&
CT(COMMAND) == FD_WRITE) {
if (remaining > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) {
DPRINT("in copy buffer\n");
printk("current_count_sectors=%ld\n", current_count_sectors);
printk("remaining=%d\n", remaining >> 9);
@ -2530,7 +2529,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
size = blk_rq_cur_sectors(current_req) << 9;
size = blk_rq_cur_bytes(current_req);
rq_for_each_segment(bv, current_req, iter) {
if (!remaining)
@ -2879,7 +2878,7 @@ static int make_raw_rw_request(void)
printk("write\n");
return 0;
}
} else if (raw_cmd->length > blk_rq_sectors(current_req) << 9 ||
} else if (raw_cmd->length > blk_rq_bytes(current_req) ||
current_count_sectors > blk_rq_sectors(current_req)) {
DPRINT("buffer overrun in direct transfer\n");
return 0;

View file

@ -110,7 +110,7 @@ static void nbd_end_request(struct request *req)
req, error ? "failed" : "done");
spin_lock_irqsave(q->queue_lock, flags);
__blk_end_request(req, error, blk_rq_sectors(req) << 9);
__blk_end_request_all(req, error);
spin_unlock_irqrestore(q->queue_lock, flags);
}
@ -231,7 +231,7 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
{
int result, flags;
struct nbd_request request;
unsigned long size = blk_rq_sectors(req) << 9;
unsigned long size = blk_rq_bytes(req);
request.magic = htonl(NBD_REQUEST_MAGIC);
request.type = htonl(nbd_cmd(req));
@ -243,7 +243,7 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
lo->disk->disk_name, req,
nbdcmd_to_ascii(nbd_cmd(req)),
(unsigned long long)blk_rq_pos(req) << 9,
blk_rq_sectors(req) << 9);
blk_rq_bytes(req));
result = sock_xmit(lo, 1, &request, sizeof(request),
(nbd_cmd(req) == NBD_CMD_WRITE) ? MSG_MORE : 0);
if (result <= 0) {

View file

@ -739,7 +739,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
cmd->cdb[8] = nblks;
cmd->cdb_len = 10;
cmd->len = blk_rq_sectors(rq) * 512;
cmd->len = blk_rq_bytes(rq);
}
static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,

View file

@ -72,7 +72,7 @@ static void do_z2_request(struct request_queue *q)
struct request *req;
while ((req = elv_next_request(q)) != NULL) {
unsigned long start = blk_rq_pos(req) << 9;
unsigned long len = blk_rq_cur_sectors(req) << 9;
unsigned long len = blk_rq_cur_bytes(req);
if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",