diff options
author | Tejun Heo <tj@kernel.org> | 2009-05-07 09:24:45 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-11 03:50:55 -0400 |
commit | 1011c1b9f2e45ce7c6e38888d2b83936aec38771 (patch) | |
tree | 63f1f8f604631f37df9917a941531de0148f8379 /drivers | |
parent | a2dec7b36364a5cc564c4d76cf16d2e7d33f5c05 (diff) |
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 <tj@kernel.org>
Cc: Paul Clements <paul.clements@steeleye.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: Alex Dubov <oakad@yahoo.com>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/floppy.c | 7 | ||||
-rw-r--r-- | drivers/block/nbd.c | 6 | ||||
-rw-r--r-- | drivers/block/ub.c | 2 | ||||
-rw-r--r-- | drivers/block/z2ram.c | 2 | ||||
-rw-r--r-- | drivers/memstick/core/mspro_block.c | 4 | ||||
-rw-r--r-- | drivers/message/i2o/i2o_block.c | 16 | ||||
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 2 | ||||
-rw-r--r-- | drivers/sbus/char/jsflash.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 7 |
9 files changed, 18 insertions, 30 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 452486283386..1e27ed9208b4 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -2512,8 +2512,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2512 | 2512 | ||
2513 | remaining = current_count_sectors << 9; | 2513 | remaining = current_count_sectors << 9; |
2514 | #ifdef FLOPPY_SANITY_CHECK | 2514 | #ifdef FLOPPY_SANITY_CHECK |
2515 | if ((remaining >> 9) > blk_rq_sectors(current_req) && | 2515 | if (remaining > blk_rq_bytes(current_req) && CT(COMMAND) == FD_WRITE) { |
2516 | CT(COMMAND) == FD_WRITE) { | ||
2517 | DPRINT("in copy buffer\n"); | 2516 | DPRINT("in copy buffer\n"); |
2518 | printk("current_count_sectors=%ld\n", current_count_sectors); | 2517 | printk("current_count_sectors=%ld\n", current_count_sectors); |
2519 | printk("remaining=%d\n", remaining >> 9); | 2518 | printk("remaining=%d\n", remaining >> 9); |
@@ -2530,7 +2529,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) | |||
2530 | 2529 | ||
2531 | dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); | 2530 | dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); |
2532 | 2531 | ||
2533 | size = blk_rq_cur_sectors(current_req) << 9; | 2532 | size = blk_rq_cur_bytes(current_req); |
2534 | 2533 | ||
2535 | rq_for_each_segment(bv, current_req, iter) { | 2534 | rq_for_each_segment(bv, current_req, iter) { |
2536 | if (!remaining) | 2535 | if (!remaining) |
@@ -2879,7 +2878,7 @@ static int make_raw_rw_request(void) | |||
2879 | printk("write\n"); | 2878 | printk("write\n"); |
2880 | return 0; | 2879 | return 0; |
2881 | } | 2880 | } |
2882 | } else if (raw_cmd->length > blk_rq_sectors(current_req) << 9 || | 2881 | } else if (raw_cmd->length > blk_rq_bytes(current_req) || |
2883 | current_count_sectors > blk_rq_sectors(current_req)) { | 2882 | current_count_sectors > blk_rq_sectors(current_req)) { |
2884 | DPRINT("buffer overrun in direct transfer\n"); | 2883 | DPRINT("buffer overrun in direct transfer\n"); |
2885 | return 0; | 2884 | return 0; |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 977a57377930..fad167de23b4 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -110,7 +110,7 @@ static void nbd_end_request(struct request *req) | |||
110 | req, error ? "failed" : "done"); | 110 | req, error ? "failed" : "done"); |
111 | 111 | ||
112 | spin_lock_irqsave(q->queue_lock, flags); | 112 | spin_lock_irqsave(q->queue_lock, flags); |
113 | __blk_end_request(req, error, blk_rq_sectors(req) << 9); | 113 | __blk_end_request_all(req, error); |
114 | spin_unlock_irqrestore(q->queue_lock, flags); | 114 | spin_unlock_irqrestore(q->queue_lock, flags); |
115 | } | 115 | } |
116 | 116 | ||
@@ -231,7 +231,7 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
231 | { | 231 | { |
232 | int result, flags; | 232 | int result, flags; |
233 | struct nbd_request request; | 233 | struct nbd_request request; |
234 | unsigned long size = blk_rq_sectors(req) << 9; | 234 | unsigned long size = blk_rq_bytes(req); |
235 | 235 | ||
236 | request.magic = htonl(NBD_REQUEST_MAGIC); | 236 | request.magic = htonl(NBD_REQUEST_MAGIC); |
237 | request.type = htonl(nbd_cmd(req)); | 237 | request.type = htonl(nbd_cmd(req)); |
@@ -243,7 +243,7 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
243 | lo->disk->disk_name, req, | 243 | lo->disk->disk_name, req, |
244 | nbdcmd_to_ascii(nbd_cmd(req)), | 244 | nbdcmd_to_ascii(nbd_cmd(req)), |
245 | (unsigned long long)blk_rq_pos(req) << 9, | 245 | (unsigned long long)blk_rq_pos(req) << 9, |
246 | blk_rq_sectors(req) << 9); | 246 | blk_rq_bytes(req)); |
247 | result = sock_xmit(lo, 1, &request, sizeof(request), | 247 | result = sock_xmit(lo, 1, &request, sizeof(request), |
248 | (nbd_cmd(req) == NBD_CMD_WRITE) ? MSG_MORE : 0); | 248 | (nbd_cmd(req) == NBD_CMD_WRITE) ? MSG_MORE : 0); |
249 | if (result <= 0) { | 249 | if (result <= 0) { |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 1591f61b6c60..40d03cf63f2e 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -739,7 +739,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, | |||
739 | cmd->cdb[8] = nblks; | 739 | cmd->cdb[8] = nblks; |
740 | cmd->cdb_len = 10; | 740 | cmd->cdb_len = 10; |
741 | 741 | ||
742 | cmd->len = blk_rq_sectors(rq) * 512; | 742 | cmd->len = blk_rq_bytes(rq); |
743 | } | 743 | } |
744 | 744 | ||
745 | static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, | 745 | static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, |
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index d4e6b71f514a..6a1383834ecf 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c | |||
@@ -72,7 +72,7 @@ static void do_z2_request(struct request_queue *q) | |||
72 | struct request *req; | 72 | struct request *req; |
73 | while ((req = elv_next_request(q)) != NULL) { | 73 | while ((req = elv_next_request(q)) != NULL) { |
74 | unsigned long start = blk_rq_pos(req) << 9; | 74 | unsigned long start = blk_rq_pos(req) << 9; |
75 | unsigned long len = blk_rq_cur_sectors(req) << 9; | 75 | unsigned long len = blk_rq_cur_bytes(req); |
76 | 76 | ||
77 | if (start + len > z2ram_size) { | 77 | if (start + len > z2ram_size) { |
78 | printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", | 78 | printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", |
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index 9e600d22f40e..93b2c6185656 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -680,7 +680,7 @@ try_again: | |||
680 | t_sec = blk_rq_pos(msb->block_req) << 9; | 680 | t_sec = blk_rq_pos(msb->block_req) << 9; |
681 | sector_div(t_sec, msb->page_size); | 681 | sector_div(t_sec, msb->page_size); |
682 | 682 | ||
683 | count = blk_rq_sectors(msb->block_req) << 9; | 683 | count = blk_rq_bytes(msb->block_req); |
684 | count /= msb->page_size; | 684 | count /= msb->page_size; |
685 | 685 | ||
686 | param.system = msb->system; | 686 | param.system = msb->system; |
@@ -745,7 +745,7 @@ static int mspro_block_complete_req(struct memstick_dev *card, int error) | |||
745 | t_len *= msb->page_size; | 745 | t_len *= msb->page_size; |
746 | } | 746 | } |
747 | } else | 747 | } else |
748 | t_len = blk_rq_sectors(msb->block_req) << 9; | 748 | t_len = blk_rq_bytes(msb->block_req); |
749 | 749 | ||
750 | dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error); | 750 | dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error); |
751 | 751 | ||
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 6b61d289d6c9..e153f5d5237d 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -426,15 +426,9 @@ static void i2o_block_end_request(struct request *req, int error, | |||
426 | struct request_queue *q = req->q; | 426 | struct request_queue *q = req->q; |
427 | unsigned long flags; | 427 | unsigned long flags; |
428 | 428 | ||
429 | if (blk_end_request(req, error, nr_bytes)) { | 429 | if (blk_end_request(req, error, nr_bytes)) |
430 | int leftover = (blk_rq_sectors(req) << KERNEL_SECTOR_SHIFT); | ||
431 | |||
432 | if (blk_pc_request(req)) | ||
433 | leftover = blk_rq_bytes(req); | ||
434 | |||
435 | if (error) | 430 | if (error) |
436 | blk_end_request(req, -EIO, leftover); | 431 | blk_end_request_all(req, -EIO); |
437 | } | ||
438 | 432 | ||
439 | spin_lock_irqsave(q->queue_lock, flags); | 433 | spin_lock_irqsave(q->queue_lock, flags); |
440 | 434 | ||
@@ -832,15 +826,13 @@ static int i2o_block_transfer(struct request *req) | |||
832 | 826 | ||
833 | memcpy(mptr, cmd, 10); | 827 | memcpy(mptr, cmd, 10); |
834 | mptr += 4; | 828 | mptr += 4; |
835 | *mptr++ = | 829 | *mptr++ = cpu_to_le32(blk_rq_bytes(req)); |
836 | cpu_to_le32(blk_rq_sectors(req) << KERNEL_SECTOR_SHIFT); | ||
837 | } else | 830 | } else |
838 | #endif | 831 | #endif |
839 | { | 832 | { |
840 | msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); | 833 | msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); |
841 | *mptr++ = cpu_to_le32(ctl_flags); | 834 | *mptr++ = cpu_to_le32(ctl_flags); |
842 | *mptr++ = | 835 | *mptr++ = cpu_to_le32(blk_rq_bytes(req)); |
843 | cpu_to_le32(blk_rq_sectors(req) << KERNEL_SECTOR_SHIFT); | ||
844 | *mptr++ = | 836 | *mptr++ = |
845 | cpu_to_le32((u32) (blk_rq_pos(req) << KERNEL_SECTOR_SHIFT)); | 837 | cpu_to_le32((u32) (blk_rq_pos(req) << KERNEL_SECTOR_SHIFT)); |
846 | *mptr++ = | 838 | *mptr++ = |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 4ea2e67ac97c..50c76a2ca76e 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -48,7 +48,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
48 | char *buf; | 48 | char *buf; |
49 | 49 | ||
50 | block = blk_rq_pos(req) << 9 >> tr->blkshift; | 50 | block = blk_rq_pos(req) << 9 >> tr->blkshift; |
51 | nsect = blk_rq_cur_sectors(req) << 9 >> tr->blkshift; | 51 | nsect = blk_rq_cur_bytes(req) >> tr->blkshift; |
52 | 52 | ||
53 | buf = req->buffer; | 53 | buf = req->buffer; |
54 | 54 | ||
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 2132c906e53a..d56ddaa77036 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c | |||
@@ -189,7 +189,7 @@ static void jsfd_do_request(struct request_queue *q) | |||
189 | while ((req = elv_next_request(q)) != NULL) { | 189 | while ((req = elv_next_request(q)) != NULL) { |
190 | struct jsfd_part *jdp = req->rq_disk->private_data; | 190 | struct jsfd_part *jdp = req->rq_disk->private_data; |
191 | unsigned long offset = blk_rq_pos(req) << 9; | 191 | unsigned long offset = blk_rq_pos(req) << 9; |
192 | size_t len = blk_rq_cur_sectors(req) << 9; | 192 | size_t len = blk_rq_cur_bytes(req); |
193 | 193 | ||
194 | if ((offset + len) > jdp->dsize) { | 194 | if ((offset + len) > jdp->dsize) { |
195 | __blk_end_request_cur(req, -EIO); | 195 | __blk_end_request_cur(req, -EIO); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3d16c70fbde0..ee308f6f7982 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -546,7 +546,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error, | |||
546 | * to queue the remainder of them. | 546 | * to queue the remainder of them. |
547 | */ | 547 | */ |
548 | if (blk_end_request(req, error, bytes)) { | 548 | if (blk_end_request(req, error, bytes)) { |
549 | int leftover = blk_rq_sectors(req) << 9; | 549 | int leftover = blk_rq_bytes(req); |
550 | 550 | ||
551 | if (blk_pc_request(req)) | 551 | if (blk_pc_request(req)) |
552 | leftover = req->resid_len; | 552 | leftover = req->resid_len; |
@@ -964,10 +964,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
964 | count = blk_rq_map_sg(req->q, req, sdb->table.sgl); | 964 | count = blk_rq_map_sg(req->q, req, sdb->table.sgl); |
965 | BUG_ON(count > sdb->table.nents); | 965 | BUG_ON(count > sdb->table.nents); |
966 | sdb->table.nents = count; | 966 | sdb->table.nents = count; |
967 | if (blk_pc_request(req)) | 967 | sdb->length = blk_rq_bytes(req); |
968 | sdb->length = blk_rq_bytes(req); | ||
969 | else | ||
970 | sdb->length = blk_rq_sectors(req) << 9; | ||
971 | return BLKPREP_OK; | 968 | return BLKPREP_OK; |
972 | } | 969 | } |
973 | 970 | ||