aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2007-09-25 06:35:59 -0400
committerJens Axboe <axboe@carl.home.kernel.dk>2007-10-10 03:25:56 -0400
commit5705f7021748a69d84d6567e68e8851dab551464 (patch)
tree5a6dbc8fc6055c0334f4a97540e36a7844b9c482 /drivers
parent9dfa52831e96194b8649613e3131baa2c109f7dc (diff)
Introduce rq_for_each_segment replacing rq_for_each_bio
Every usage of rq_for_each_bio wraps a usage of bio_for_each_segment, so these can be combined into rq_for_each_segment. We define "struct req_iterator" to hold the 'bio' and 'index' that are needed for the double iteration. Signed-off-by: Neil Brown <neilb@suse.de> Various compile fixes by me... Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/floppy.c81
-rw-r--r--drivers/block/lguest_blk.c10
-rw-r--r--drivers/block/nbd.c22
-rw-r--r--drivers/block/ps3disk.c31
-rw-r--r--drivers/block/xen-blkfront.c7
-rw-r--r--drivers/ide/ide-floppy.c16
-rw-r--r--drivers/s390/block/dasd_diag.c11
-rw-r--r--drivers/s390/block/dasd_eckd.c15
-rw-r--r--drivers/s390/block/dasd_fba.c15
-rw-r--r--drivers/s390/char/tape_34xx.c15
-rw-r--r--drivers/s390/char/tape_3590.c16
11 files changed, 101 insertions, 138 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 085b7794fb3e..f0a86e201b44 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2437,22 +2437,19 @@ static void rw_interrupt(void)
2437/* Compute maximal contiguous buffer size. */ 2437/* Compute maximal contiguous buffer size. */
2438static int buffer_chain_size(void) 2438static int buffer_chain_size(void)
2439{ 2439{
2440 struct bio *bio;
2441 struct bio_vec *bv; 2440 struct bio_vec *bv;
2442 int size, i; 2441 int size;
2442 struct req_iterator iter;
2443 char *base; 2443 char *base;
2444 2444
2445 base = bio_data(current_req->bio); 2445 base = bio_data(current_req->bio);
2446 size = 0; 2446 size = 0;
2447 2447
2448 rq_for_each_bio(bio, current_req) { 2448 rq_for_each_segment(bv, current_req, iter) {
2449 bio_for_each_segment(bv, bio, i) { 2449 if (page_address(bv->bv_page) + bv->bv_offset != base + size)
2450 if (page_address(bv->bv_page) + bv->bv_offset != 2450 break;
2451 base + size)
2452 break;
2453 2451
2454 size += bv->bv_len; 2452 size += bv->bv_len;
2455 }
2456 } 2453 }
2457 2454
2458 return size >> 9; 2455 return size >> 9;
@@ -2479,9 +2476,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
2479{ 2476{
2480 int remaining; /* number of transferred 512-byte sectors */ 2477 int remaining; /* number of transferred 512-byte sectors */
2481 struct bio_vec *bv; 2478 struct bio_vec *bv;
2482 struct bio *bio;
2483 char *buffer, *dma_buffer; 2479 char *buffer, *dma_buffer;
2484 int size, i; 2480 int size;
2481 struct req_iterator iter;
2485 2482
2486 max_sector = transfer_size(ssize, 2483 max_sector = transfer_size(ssize,
2487 min(max_sector, max_sector_2), 2484 min(max_sector, max_sector_2),
@@ -2514,43 +2511,41 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
2514 2511
2515 size = current_req->current_nr_sectors << 9; 2512 size = current_req->current_nr_sectors << 9;
2516 2513
2517 rq_for_each_bio(bio, current_req) { 2514 rq_for_each_segment(bv, current_req, iter) {
2518 bio_for_each_segment(bv, bio, i) { 2515 if (!remaining)
2519 if (!remaining) 2516 break;
2520 break;
2521 2517
2522 size = bv->bv_len; 2518 size = bv->bv_len;
2523 SUPBOUND(size, remaining); 2519 SUPBOUND(size, remaining);
2524 2520
2525 buffer = page_address(bv->bv_page) + bv->bv_offset; 2521 buffer = page_address(bv->bv_page) + bv->bv_offset;
2526#ifdef FLOPPY_SANITY_CHECK 2522#ifdef FLOPPY_SANITY_CHECK
2527 if (dma_buffer + size > 2523 if (dma_buffer + size >
2528 floppy_track_buffer + (max_buffer_sectors << 10) || 2524 floppy_track_buffer + (max_buffer_sectors << 10) ||
2529 dma_buffer < floppy_track_buffer) { 2525 dma_buffer < floppy_track_buffer) {
2530 DPRINT("buffer overrun in copy buffer %d\n", 2526 DPRINT("buffer overrun in copy buffer %d\n",
2531 (int)((floppy_track_buffer - 2527 (int)((floppy_track_buffer -
2532 dma_buffer) >> 9)); 2528 dma_buffer) >> 9));
2533 printk("fsector_t=%d buffer_min=%d\n", 2529 printk("fsector_t=%d buffer_min=%d\n",
2534 fsector_t, buffer_min); 2530 fsector_t, buffer_min);
2535 printk("current_count_sectors=%ld\n", 2531 printk("current_count_sectors=%ld\n",
2536 current_count_sectors); 2532 current_count_sectors);
2537 if (CT(COMMAND) == FD_READ)
2538 printk("read\n");
2539 if (CT(COMMAND) == FD_WRITE)
2540 printk("write\n");
2541 break;
2542 }
2543 if (((unsigned long)buffer) % 512)
2544 DPRINT("%p buffer not aligned\n", buffer);
2545#endif
2546 if (CT(COMMAND) == FD_READ) 2533 if (CT(COMMAND) == FD_READ)
2547 memcpy(buffer, dma_buffer, size); 2534 printk("read\n");
2548 else 2535 if (CT(COMMAND) == FD_WRITE)
2549 memcpy(dma_buffer, buffer, size); 2536 printk("write\n");
2550 2537 break;
2551 remaining -= size;
2552 dma_buffer += size;
2553 } 2538 }
2539 if (((unsigned long)buffer) % 512)
2540 DPRINT("%p buffer not aligned\n", buffer);
2541#endif
2542 if (CT(COMMAND) == FD_READ)
2543 memcpy(buffer, dma_buffer, size);
2544 else
2545 memcpy(dma_buffer, buffer, size);
2546
2547 remaining -= size;
2548 dma_buffer += size;
2554 } 2549 }
2555#ifdef FLOPPY_SANITY_CHECK 2550#ifdef FLOPPY_SANITY_CHECK
2556 if (remaining) { 2551 if (remaining) {
diff --git a/drivers/block/lguest_blk.c b/drivers/block/lguest_blk.c
index 160cf14431ac..1e838ae60a60 100644
--- a/drivers/block/lguest_blk.c
+++ b/drivers/block/lguest_blk.c
@@ -142,12 +142,11 @@ static irqreturn_t lgb_irq(int irq, void *_bd)
142 * return the total length. */ 142 * return the total length. */
143static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) 143static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma)
144{ 144{
145 unsigned int i = 0, idx, len = 0; 145 unsigned int i = 0, len = 0;
146 struct bio *bio; 146 struct req_iterator iter;
147 struct bio_vec *bvec;
147 148
148 rq_for_each_bio(bio, req) { 149 rq_for_each_segment(bvec, req, iter) {
149 struct bio_vec *bvec;
150 bio_for_each_segment(bvec, bio, idx) {
151 /* We told the block layer not to give us too many. */ 150 /* We told the block layer not to give us too many. */
152 BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); 151 BUG_ON(i == LGUEST_MAX_DMA_SECTIONS);
153 /* If we had a zero-length segment, it would look like 152 /* If we had a zero-length segment, it would look like
@@ -160,7 +159,6 @@ static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma)
160 dma->len[i] = bvec->bv_len; 159 dma->len[i] = bvec->bv_len;
161 len += bvec->bv_len; 160 len += bvec->bv_len;
162 i++; 161 i++;
163 }
164 } 162 }
165 /* If the array isn't full, we mark the end with a 0 length */ 163 /* If the array isn't full, we mark the end with a 0 length */
166 if (i < LGUEST_MAX_DMA_SECTIONS) 164 if (i < LGUEST_MAX_DMA_SECTIONS)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index be92c658f06e..228b2ff577aa 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -180,7 +180,7 @@ static inline int sock_send_bvec(struct socket *sock, struct bio_vec *bvec,
180 180
181static int nbd_send_req(struct nbd_device *lo, struct request *req) 181static int nbd_send_req(struct nbd_device *lo, struct request *req)
182{ 182{
183 int result, i, flags; 183 int result, flags;
184 struct nbd_request request; 184 struct nbd_request request;
185 unsigned long size = req->nr_sectors << 9; 185 unsigned long size = req->nr_sectors << 9;
186 struct socket *sock = lo->sock; 186 struct socket *sock = lo->sock;
@@ -205,16 +205,15 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
205 } 205 }
206 206
207 if (nbd_cmd(req) == NBD_CMD_WRITE) { 207 if (nbd_cmd(req) == NBD_CMD_WRITE) {
208 struct bio *bio; 208 struct req_iterator iter;
209 struct bio_vec *bvec;
209 /* 210 /*
210 * we are really probing at internals to determine 211 * we are really probing at internals to determine
211 * whether to set MSG_MORE or not... 212 * whether to set MSG_MORE or not...
212 */ 213 */
213 rq_for_each_bio(bio, req) { 214 rq_for_each_segment(bvec, req, iter) {
214 struct bio_vec *bvec;
215 bio_for_each_segment(bvec, bio, i) {
216 flags = 0; 215 flags = 0;
217 if ((i < (bio->bi_vcnt - 1)) || bio->bi_next) 216 if (!rq_iter_last(req, iter))
218 flags = MSG_MORE; 217 flags = MSG_MORE;
219 dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", 218 dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n",
220 lo->disk->disk_name, req, 219 lo->disk->disk_name, req,
@@ -226,7 +225,6 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
226 result); 225 result);
227 goto error_out; 226 goto error_out;
228 } 227 }
229 }
230 } 228 }
231 } 229 }
232 return 0; 230 return 0;
@@ -321,11 +319,10 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
321 dprintk(DBG_RX, "%s: request %p: got reply\n", 319 dprintk(DBG_RX, "%s: request %p: got reply\n",
322 lo->disk->disk_name, req); 320 lo->disk->disk_name, req);
323 if (nbd_cmd(req) == NBD_CMD_READ) { 321 if (nbd_cmd(req) == NBD_CMD_READ) {
324 int i; 322 struct req_iterator iter;
325 struct bio *bio; 323 struct bio_vec *bvec;
326 rq_for_each_bio(bio, req) { 324
327 struct bio_vec *bvec; 325 rq_for_each_segment(bvec, req, iter) {
328 bio_for_each_segment(bvec, bio, i) {
329 result = sock_recv_bvec(sock, bvec); 326 result = sock_recv_bvec(sock, bvec);
330 if (result <= 0) { 327 if (result <= 0) {
331 printk(KERN_ERR "%s: Receive data failed (result %d)\n", 328 printk(KERN_ERR "%s: Receive data failed (result %d)\n",
@@ -336,7 +333,6 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
336 } 333 }
337 dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", 334 dprintk(DBG_RX, "%s: request %p: got %d bytes data\n",
338 lo->disk->disk_name, req, bvec->bv_len); 335 lo->disk->disk_name, req, bvec->bv_len);
339 }
340 } 336 }
341 } 337 }
342 return req; 338 return req;
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index aa8b890c80d7..8953e7ce0016 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -91,30 +91,30 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev,
91 struct request *req, int gather) 91 struct request *req, int gather)
92{ 92{
93 unsigned int offset = 0; 93 unsigned int offset = 0;
94 struct bio *bio; 94 struct req_iterator iter;
95 sector_t sector;
96 struct bio_vec *bvec; 95 struct bio_vec *bvec;
97 unsigned int i = 0, j; 96 unsigned int i = 0;
98 size_t size; 97 size_t size;
99 void *buf; 98 void *buf;
100 99
101 rq_for_each_bio(bio, req) { 100 rq_for_each_segment(bvec, req, iter) {
102 sector = bio->bi_sector; 101 unsigned long flags;
103 dev_dbg(&dev->sbd.core, 102 dev_dbg(&dev->sbd.core,
104 "%s:%u: bio %u: %u segs %u sectors from %lu\n", 103 "%s:%u: bio %u: %u segs %u sectors from %lu\n",
105 __func__, __LINE__, i, bio_segments(bio), 104 __func__, __LINE__, i, bio_segments(iter.bio),
106 bio_sectors(bio), sector); 105 bio_sectors(iter.bio),
107 bio_for_each_segment(bvec, bio, j) { 106 (unsigned long)iter.bio->bi_sector);
107
108 size = bvec->bv_len; 108 size = bvec->bv_len;
109 buf = __bio_kmap_atomic(bio, j, KM_IRQ0); 109 buf = bvec_kmap_irq(bvec, &flags);
110 if (gather) 110 if (gather)
111 memcpy(dev->bounce_buf+offset, buf, size); 111 memcpy(dev->bounce_buf+offset, buf, size);
112 else 112 else
113 memcpy(buf, dev->bounce_buf+offset, size); 113 memcpy(buf, dev->bounce_buf+offset, size);
114 offset += size; 114 offset += size;
115 flush_kernel_dcache_page(bio_iovec_idx(bio, j)->bv_page); 115 flush_kernel_dcache_page(bvec->bv_page);
116 __bio_kunmap_atomic(bio, KM_IRQ0); 116 bvec_kunmap_irq(bvec, &flags);
117 } 117
118 i++; 118 i++;
119 } 119 }
120} 120}
@@ -130,12 +130,13 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
130 130
131#ifdef DEBUG 131#ifdef DEBUG
132 unsigned int n = 0; 132 unsigned int n = 0;
133 struct bio *bio; 133 struct bio_vec *bv;
134 struct req_iterator iter;
134 135
135 rq_for_each_bio(bio, req) 136 rq_for_each_segment(bv, req, iter)
136 n++; 137 n++;
137 dev_dbg(&dev->sbd.core, 138 dev_dbg(&dev->sbd.core,
138 "%s:%u: %s req has %u bios for %lu sectors %lu hard sectors\n", 139 "%s:%u: %s req has %u bvecs for %lu sectors %lu hard sectors\n",
139 __func__, __LINE__, op, n, req->nr_sectors, 140 __func__, __LINE__, op, n, req->nr_sectors,
140 req->hard_nr_sectors); 141 req->hard_nr_sectors);
141#endif 142#endif
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 964e51634f2d..6af250113c2a 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -150,9 +150,8 @@ static int blkif_queue_request(struct request *req)
150 struct blkfront_info *info = req->rq_disk->private_data; 150 struct blkfront_info *info = req->rq_disk->private_data;
151 unsigned long buffer_mfn; 151 unsigned long buffer_mfn;
152 struct blkif_request *ring_req; 152 struct blkif_request *ring_req;
153 struct bio *bio; 153 struct req_iterator iter;
154 struct bio_vec *bvec; 154 struct bio_vec *bvec;
155 int idx;
156 unsigned long id; 155 unsigned long id;
157 unsigned int fsect, lsect; 156 unsigned int fsect, lsect;
158 int ref; 157 int ref;
@@ -186,8 +185,7 @@ static int blkif_queue_request(struct request *req)
186 ring_req->operation = BLKIF_OP_WRITE_BARRIER; 185 ring_req->operation = BLKIF_OP_WRITE_BARRIER;
187 186
188 ring_req->nr_segments = 0; 187 ring_req->nr_segments = 0;
189 rq_for_each_bio (bio, req) { 188 rq_for_each_segment(bvec, req, iter) {
190 bio_for_each_segment (bvec, bio, idx) {
191 BUG_ON(ring_req->nr_segments 189 BUG_ON(ring_req->nr_segments
192 == BLKIF_MAX_SEGMENTS_PER_REQUEST); 190 == BLKIF_MAX_SEGMENTS_PER_REQUEST);
193 buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page)); 191 buffer_mfn = pfn_to_mfn(page_to_pfn(bvec->bv_page));
@@ -213,7 +211,6 @@ static int blkif_queue_request(struct request *req)
213 .last_sect = lsect }; 211 .last_sect = lsect };
214 212
215 ring_req->nr_segments++; 213 ring_req->nr_segments++;
216 }
217 } 214 }
218 215
219 info->ring.req_prod_pvt++; 216 info->ring.req_prod_pvt++;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index ae8e1a64b8ad..a775450d7a38 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -606,13 +606,12 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
606{ 606{
607 struct request *rq = pc->rq; 607 struct request *rq = pc->rq;
608 struct bio_vec *bvec; 608 struct bio_vec *bvec;
609 struct bio *bio; 609 struct req_iterator iter;
610 unsigned long flags; 610 unsigned long flags;
611 char *data; 611 char *data;
612 int count, i, done = 0; 612 int count, done = 0;
613 613
614 rq_for_each_bio(bio, rq) { 614 rq_for_each_segment(bvec, rq, iter) {
615 bio_for_each_segment(bvec, bio, i) {
616 if (!bcount) 615 if (!bcount)
617 break; 616 break;
618 617
@@ -625,7 +624,6 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
625 bcount -= count; 624 bcount -= count;
626 pc->b_count += count; 625 pc->b_count += count;
627 done += count; 626 done += count;
628 }
629 } 627 }
630 628
631 idefloppy_do_end_request(drive, 1, done >> 9); 629 idefloppy_do_end_request(drive, 1, done >> 9);
@@ -639,14 +637,13 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
639static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) 637static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
640{ 638{
641 struct request *rq = pc->rq; 639 struct request *rq = pc->rq;
642 struct bio *bio; 640 struct req_iterator iter;
643 struct bio_vec *bvec; 641 struct bio_vec *bvec;
644 unsigned long flags; 642 unsigned long flags;
645 int count, i, done = 0; 643 int count, done = 0;
646 char *data; 644 char *data;
647 645
648 rq_for_each_bio(bio, rq) { 646 rq_for_each_segment(bvec, rq, iter) {
649 bio_for_each_segment(bvec, bio, i) {
650 if (!bcount) 647 if (!bcount)
651 break; 648 break;
652 649
@@ -659,7 +656,6 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
659 bcount -= count; 656 bcount -= count;
660 pc->b_count += count; 657 pc->b_count += count;
661 done += count; 658 done += count;
662 }
663 } 659 }
664 660
665 idefloppy_do_end_request(drive, 1, done >> 9); 661 idefloppy_do_end_request(drive, 1, done >> 9);
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index d32c60dbdd82..6bb9676f203e 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -472,14 +472,13 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
472 struct dasd_ccw_req *cqr; 472 struct dasd_ccw_req *cqr;
473 struct dasd_diag_req *dreq; 473 struct dasd_diag_req *dreq;
474 struct dasd_diag_bio *dbio; 474 struct dasd_diag_bio *dbio;
475 struct bio *bio; 475 struct req_iterator iter;
476 struct bio_vec *bv; 476 struct bio_vec *bv;
477 char *dst; 477 char *dst;
478 unsigned int count, datasize; 478 unsigned int count, datasize;
479 sector_t recid, first_rec, last_rec; 479 sector_t recid, first_rec, last_rec;
480 unsigned int blksize, off; 480 unsigned int blksize, off;
481 unsigned char rw_cmd; 481 unsigned char rw_cmd;
482 int i;
483 482
484 if (rq_data_dir(req) == READ) 483 if (rq_data_dir(req) == READ)
485 rw_cmd = MDSK_READ_REQ; 484 rw_cmd = MDSK_READ_REQ;
@@ -493,13 +492,11 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
493 last_rec = (req->sector + req->nr_sectors - 1) >> device->s2b_shift; 492 last_rec = (req->sector + req->nr_sectors - 1) >> device->s2b_shift;
494 /* Check struct bio and count the number of blocks for the request. */ 493 /* Check struct bio and count the number of blocks for the request. */
495 count = 0; 494 count = 0;
496 rq_for_each_bio(bio, req) { 495 rq_for_each_segment(bv, req, iter) {
497 bio_for_each_segment(bv, bio, i) {
498 if (bv->bv_len & (blksize - 1)) 496 if (bv->bv_len & (blksize - 1))
499 /* Fba can only do full blocks. */ 497 /* Fba can only do full blocks. */
500 return ERR_PTR(-EINVAL); 498 return ERR_PTR(-EINVAL);
501 count += bv->bv_len >> (device->s2b_shift + 9); 499 count += bv->bv_len >> (device->s2b_shift + 9);
502 }
503 } 500 }
504 /* Paranoia. */ 501 /* Paranoia. */
505 if (count != last_rec - first_rec + 1) 502 if (count != last_rec - first_rec + 1)
@@ -516,8 +513,7 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
516 dreq->block_count = count; 513 dreq->block_count = count;
517 dbio = dreq->bio; 514 dbio = dreq->bio;
518 recid = first_rec; 515 recid = first_rec;
519 rq_for_each_bio(bio, req) { 516 rq_for_each_segment(bv, req, iter) {
520 bio_for_each_segment(bv, bio, i) {
521 dst = page_address(bv->bv_page) + bv->bv_offset; 517 dst = page_address(bv->bv_page) + bv->bv_offset;
522 for (off = 0; off < bv->bv_len; off += blksize) { 518 for (off = 0; off < bv->bv_len; off += blksize) {
523 memset(dbio, 0, sizeof (struct dasd_diag_bio)); 519 memset(dbio, 0, sizeof (struct dasd_diag_bio));
@@ -528,7 +524,6 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
528 dst += blksize; 524 dst += blksize;
529 recid++; 525 recid++;
530 } 526 }
531 }
532 } 527 }
533 cqr->retries = DIAG_MAX_RETRIES; 528 cqr->retries = DIAG_MAX_RETRIES;
534 cqr->buildclk = get_clock(); 529 cqr->buildclk = get_clock();
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index ea63ba7828f9..36ba45849874 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1176,7 +1176,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1176 struct LO_eckd_data *LO_data; 1176 struct LO_eckd_data *LO_data;
1177 struct dasd_ccw_req *cqr; 1177 struct dasd_ccw_req *cqr;
1178 struct ccw1 *ccw; 1178 struct ccw1 *ccw;
1179 struct bio *bio; 1179 struct req_iterator iter;
1180 struct bio_vec *bv; 1180 struct bio_vec *bv;
1181 char *dst; 1181 char *dst;
1182 unsigned int blksize, blk_per_trk, off; 1182 unsigned int blksize, blk_per_trk, off;
@@ -1185,7 +1185,6 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1185 sector_t first_trk, last_trk; 1185 sector_t first_trk, last_trk;
1186 unsigned int first_offs, last_offs; 1186 unsigned int first_offs, last_offs;
1187 unsigned char cmd, rcmd; 1187 unsigned char cmd, rcmd;
1188 int i;
1189 1188
1190 private = (struct dasd_eckd_private *) device->private; 1189 private = (struct dasd_eckd_private *) device->private;
1191 if (rq_data_dir(req) == READ) 1190 if (rq_data_dir(req) == READ)
@@ -1206,8 +1205,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1206 /* Check struct bio and count the number of blocks for the request. */ 1205 /* Check struct bio and count the number of blocks for the request. */
1207 count = 0; 1206 count = 0;
1208 cidaw = 0; 1207 cidaw = 0;
1209 rq_for_each_bio(bio, req) { 1208 rq_for_each_segment(bv, req, iter) {
1210 bio_for_each_segment(bv, bio, i) {
1211 if (bv->bv_len & (blksize - 1)) 1209 if (bv->bv_len & (blksize - 1))
1212 /* Eckd can only do full blocks. */ 1210 /* Eckd can only do full blocks. */
1213 return ERR_PTR(-EINVAL); 1211 return ERR_PTR(-EINVAL);
@@ -1217,7 +1215,6 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1217 bv->bv_len)) 1215 bv->bv_len))
1218 cidaw += bv->bv_len >> (device->s2b_shift + 9); 1216 cidaw += bv->bv_len >> (device->s2b_shift + 9);
1219#endif 1217#endif
1220 }
1221 } 1218 }
1222 /* Paranoia. */ 1219 /* Paranoia. */
1223 if (count != last_rec - first_rec + 1) 1220 if (count != last_rec - first_rec + 1)
@@ -1257,7 +1254,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1257 locate_record(ccw++, LO_data++, first_trk, first_offs + 1, 1254 locate_record(ccw++, LO_data++, first_trk, first_offs + 1,
1258 last_rec - recid + 1, cmd, device, blksize); 1255 last_rec - recid + 1, cmd, device, blksize);
1259 } 1256 }
1260 rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) { 1257 rq_for_each_segment(bv, req, iter) {
1261 dst = page_address(bv->bv_page) + bv->bv_offset; 1258 dst = page_address(bv->bv_page) + bv->bv_offset;
1262 if (dasd_page_cache) { 1259 if (dasd_page_cache) {
1263 char *copy = kmem_cache_alloc(dasd_page_cache, 1260 char *copy = kmem_cache_alloc(dasd_page_cache,
@@ -1328,12 +1325,12 @@ dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
1328{ 1325{
1329 struct dasd_eckd_private *private; 1326 struct dasd_eckd_private *private;
1330 struct ccw1 *ccw; 1327 struct ccw1 *ccw;
1331 struct bio *bio; 1328 struct req_iterator iter;
1332 struct bio_vec *bv; 1329 struct bio_vec *bv;
1333 char *dst, *cda; 1330 char *dst, *cda;
1334 unsigned int blksize, blk_per_trk, off; 1331 unsigned int blksize, blk_per_trk, off;
1335 sector_t recid; 1332 sector_t recid;
1336 int i, status; 1333 int status;
1337 1334
1338 if (!dasd_page_cache) 1335 if (!dasd_page_cache)
1339 goto out; 1336 goto out;
@@ -1346,7 +1343,7 @@ dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
1346 ccw++; 1343 ccw++;
1347 if (private->uses_cdl == 0 || recid > 2*blk_per_trk) 1344 if (private->uses_cdl == 0 || recid > 2*blk_per_trk)
1348 ccw++; 1345 ccw++;
1349 rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) { 1346 rq_for_each_segment(bv, req, iter) {
1350 dst = page_address(bv->bv_page) + bv->bv_offset; 1347 dst = page_address(bv->bv_page) + bv->bv_offset;
1351 for (off = 0; off < bv->bv_len; off += blksize) { 1348 for (off = 0; off < bv->bv_len; off += blksize) {
1352 /* Skip locate record. */ 1349 /* Skip locate record. */
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index da16ead8aff2..119b8d2d5f17 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -234,14 +234,13 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
234 struct LO_fba_data *LO_data; 234 struct LO_fba_data *LO_data;
235 struct dasd_ccw_req *cqr; 235 struct dasd_ccw_req *cqr;
236 struct ccw1 *ccw; 236 struct ccw1 *ccw;
237 struct bio *bio; 237 struct req_iterator iter;
238 struct bio_vec *bv; 238 struct bio_vec *bv;
239 char *dst; 239 char *dst;
240 int count, cidaw, cplength, datasize; 240 int count, cidaw, cplength, datasize;
241 sector_t recid, first_rec, last_rec; 241 sector_t recid, first_rec, last_rec;
242 unsigned int blksize, off; 242 unsigned int blksize, off;
243 unsigned char cmd; 243 unsigned char cmd;
244 int i;
245 244
246 private = (struct dasd_fba_private *) device->private; 245 private = (struct dasd_fba_private *) device->private;
247 if (rq_data_dir(req) == READ) { 246 if (rq_data_dir(req) == READ) {
@@ -257,8 +256,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
257 /* Check struct bio and count the number of blocks for the request. */ 256 /* Check struct bio and count the number of blocks for the request. */
258 count = 0; 257 count = 0;
259 cidaw = 0; 258 cidaw = 0;
260 rq_for_each_bio(bio, req) { 259 rq_for_each_segment(bv, req, iter) {
261 bio_for_each_segment(bv, bio, i) {
262 if (bv->bv_len & (blksize - 1)) 260 if (bv->bv_len & (blksize - 1))
263 /* Fba can only do full blocks. */ 261 /* Fba can only do full blocks. */
264 return ERR_PTR(-EINVAL); 262 return ERR_PTR(-EINVAL);
@@ -268,7 +266,6 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
268 bv->bv_len)) 266 bv->bv_len))
269 cidaw += bv->bv_len / blksize; 267 cidaw += bv->bv_len / blksize;
270#endif 268#endif
271 }
272 } 269 }
273 /* Paranoia. */ 270 /* Paranoia. */
274 if (count != last_rec - first_rec + 1) 271 if (count != last_rec - first_rec + 1)
@@ -304,7 +301,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
304 locate_record(ccw++, LO_data++, rq_data_dir(req), 0, count); 301 locate_record(ccw++, LO_data++, rq_data_dir(req), 0, count);
305 } 302 }
306 recid = first_rec; 303 recid = first_rec;
307 rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) { 304 rq_for_each_segment(bv, req, iter) {
308 dst = page_address(bv->bv_page) + bv->bv_offset; 305 dst = page_address(bv->bv_page) + bv->bv_offset;
309 if (dasd_page_cache) { 306 if (dasd_page_cache) {
310 char *copy = kmem_cache_alloc(dasd_page_cache, 307 char *copy = kmem_cache_alloc(dasd_page_cache,
@@ -359,11 +356,11 @@ dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req)
359{ 356{
360 struct dasd_fba_private *private; 357 struct dasd_fba_private *private;
361 struct ccw1 *ccw; 358 struct ccw1 *ccw;
362 struct bio *bio; 359 struct req_iterator iter;
363 struct bio_vec *bv; 360 struct bio_vec *bv;
364 char *dst, *cda; 361 char *dst, *cda;
365 unsigned int blksize, off; 362 unsigned int blksize, off;
366 int i, status; 363 int status;
367 364
368 if (!dasd_page_cache) 365 if (!dasd_page_cache)
369 goto out; 366 goto out;
@@ -374,7 +371,7 @@ dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req)
374 ccw++; 371 ccw++;
375 if (private->rdc_data.mode.bits.data_chain != 0) 372 if (private->rdc_data.mode.bits.data_chain != 0)
376 ccw++; 373 ccw++;
377 rq_for_each_bio(bio, req) bio_for_each_segment(bv, bio, i) { 374 rq_for_each_segment(bv, req, iter) {
378 dst = page_address(bv->bv_page) + bv->bv_offset; 375 dst = page_address(bv->bv_page) + bv->bv_offset;
379 for (off = 0; off < bv->bv_len; off += blksize) { 376 for (off = 0; off < bv->bv_len; off += blksize) {
380 /* Skip locate record. */ 377 /* Skip locate record. */
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 80e7a537e7d2..ea3e6a345c89 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -1134,21 +1134,18 @@ tape_34xx_bread(struct tape_device *device, struct request *req)
1134{ 1134{
1135 struct tape_request *request; 1135 struct tape_request *request;
1136 struct ccw1 *ccw; 1136 struct ccw1 *ccw;
1137 int count = 0, i; 1137 int count = 0;
1138 unsigned off; 1138 unsigned off;
1139 char *dst; 1139 char *dst;
1140 struct bio_vec *bv; 1140 struct bio_vec *bv;
1141 struct bio *bio; 1141 struct req_iterator iter;
1142 struct tape_34xx_block_id * start_block; 1142 struct tape_34xx_block_id * start_block;
1143 1143
1144 DBF_EVENT(6, "xBREDid:"); 1144 DBF_EVENT(6, "xBREDid:");
1145 1145
1146 /* Count the number of blocks for the request. */ 1146 /* Count the number of blocks for the request. */
1147 rq_for_each_bio(bio, req) { 1147 rq_for_each_segment(bv, req, iter)
1148 bio_for_each_segment(bv, bio, i) { 1148 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
1149 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
1150 }
1151 }
1152 1149
1153 /* Allocate the ccw request. */ 1150 /* Allocate the ccw request. */
1154 request = tape_alloc_request(3+count+1, 8); 1151 request = tape_alloc_request(3+count+1, 8);
@@ -1175,8 +1172,7 @@ tape_34xx_bread(struct tape_device *device, struct request *req)
1175 ccw = tape_ccw_cc(ccw, NOP, 0, NULL); 1172 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
1176 ccw = tape_ccw_cc(ccw, NOP, 0, NULL); 1173 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
1177 1174
1178 rq_for_each_bio(bio, req) { 1175 rq_for_each_segment(bv, req, iter) {
1179 bio_for_each_segment(bv, bio, i) {
1180 dst = kmap(bv->bv_page) + bv->bv_offset; 1176 dst = kmap(bv->bv_page) + bv->bv_offset;
1181 for (off = 0; off < bv->bv_len; 1177 for (off = 0; off < bv->bv_len;
1182 off += TAPEBLOCK_HSEC_SIZE) { 1178 off += TAPEBLOCK_HSEC_SIZE) {
@@ -1187,7 +1183,6 @@ tape_34xx_bread(struct tape_device *device, struct request *req)
1187 ccw++; 1183 ccw++;
1188 dst += TAPEBLOCK_HSEC_SIZE; 1184 dst += TAPEBLOCK_HSEC_SIZE;
1189 } 1185 }
1190 }
1191 } 1186 }
1192 1187
1193 ccw = tape_ccw_end(ccw, NOP, 0, NULL); 1188 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index 7e2b2ab49264..b16ad7a7631d 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -623,21 +623,19 @@ tape_3590_bread(struct tape_device *device, struct request *req)
623{ 623{
624 struct tape_request *request; 624 struct tape_request *request;
625 struct ccw1 *ccw; 625 struct ccw1 *ccw;
626 int count = 0, start_block, i; 626 int count = 0, start_block;
627 unsigned off; 627 unsigned off;
628 char *dst; 628 char *dst;
629 struct bio_vec *bv; 629 struct bio_vec *bv;
630 struct bio *bio; 630 struct req_iterator iter;
631 631
632 DBF_EVENT(6, "xBREDid:"); 632 DBF_EVENT(6, "xBREDid:");
633 start_block = req->sector >> TAPEBLOCK_HSEC_S2B; 633 start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
634 DBF_EVENT(6, "start_block = %i\n", start_block); 634 DBF_EVENT(6, "start_block = %i\n", start_block);
635 635
636 rq_for_each_bio(bio, req) { 636 rq_for_each_segment(bv, req, iter)
637 bio_for_each_segment(bv, bio, i) { 637 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
638 count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9); 638
639 }
640 }
641 request = tape_alloc_request(2 + count + 1, 4); 639 request = tape_alloc_request(2 + count + 1, 4);
642 if (IS_ERR(request)) 640 if (IS_ERR(request))
643 return request; 641 return request;
@@ -653,8 +651,7 @@ tape_3590_bread(struct tape_device *device, struct request *req)
653 */ 651 */
654 ccw = tape_ccw_cc(ccw, NOP, 0, NULL); 652 ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
655 653
656 rq_for_each_bio(bio, req) { 654 rq_for_each_segment(bv, req, iter) {
657 bio_for_each_segment(bv, bio, i) {
658 dst = page_address(bv->bv_page) + bv->bv_offset; 655 dst = page_address(bv->bv_page) + bv->bv_offset;
659 for (off = 0; off < bv->bv_len; 656 for (off = 0; off < bv->bv_len;
660 off += TAPEBLOCK_HSEC_SIZE) { 657 off += TAPEBLOCK_HSEC_SIZE) {
@@ -667,7 +664,6 @@ tape_3590_bread(struct tape_device *device, struct request *req)
667 } 664 }
668 if (off > bv->bv_len) 665 if (off > bv->bv_len)
669 BUG(); 666 BUG();
670 }
671 } 667 }
672 ccw = tape_ccw_end(ccw, NOP, 0, NULL); 668 ccw = tape_ccw_end(ccw, NOP, 0, NULL);
673 DBF_EVENT(6, "xBREDccwg\n"); 669 DBF_EVENT(6, "xBREDccwg\n");