diff options
author | NeilBrown <neilb@suse.de> | 2007-09-25 06:35:59 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:25:56 -0400 |
commit | 5705f7021748a69d84d6567e68e8851dab551464 (patch) | |
tree | 5a6dbc8fc6055c0334f4a97540e36a7844b9c482 /drivers/s390 | |
parent | 9dfa52831e96194b8649613e3131baa2c109f7dc (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/s390')
-rw-r--r-- | drivers/s390/block/dasd_diag.c | 11 | ||||
-rw-r--r-- | drivers/s390/block/dasd_eckd.c | 15 | ||||
-rw-r--r-- | drivers/s390/block/dasd_fba.c | 15 | ||||
-rw-r--r-- | drivers/s390/char/tape_34xx.c | 15 | ||||
-rw-r--r-- | drivers/s390/char/tape_3590.c | 16 |
5 files changed, 26 insertions, 46 deletions
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"); |