diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-08 13:13:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-08 13:13:35 -0400 |
commit | 4de13d7aa8f4d02f4dc99d4609575659f92b3c5a (patch) | |
tree | 3bc9729eabe79c6164cd29a5d605000bc82bf837 /drivers | |
parent | 5af43c24ca59a448c9312dd4a4a51d27ec3b9a73 (diff) | |
parent | b8d4a5bf6a049303a29a3275f463f09a490b50ea (diff) |
Merge branch 'for-3.10/core' of git://git.kernel.dk/linux-block
Pull block core updates from Jens Axboe:
- Major bit is Kents prep work for immutable bio vecs.
- Stable candidate fix for a scheduling-while-atomic in the queue
bypass operation.
- Fix for the hang on exceeded rq->datalen 32-bit unsigned when merging
discard bios.
- Tejuns changes to convert the writeback thread pool to the generic
workqueue mechanism.
- Runtime PM framework, SCSI patches exists on top of these in James'
tree.
- A few random fixes.
* 'for-3.10/core' of git://git.kernel.dk/linux-block: (40 commits)
relay: move remove_buf_file inside relay_close_buf
partitions/efi.c: replace useless kzalloc's by kmalloc's
fs/block_dev.c: fix iov_shorten() criteria in blkdev_aio_read()
block: fix max discard sectors limit
blkcg: fix "scheduling while atomic" in blk_queue_bypass_start
Documentation: cfq-iosched: update documentation help for cfq tunables
writeback: expose the bdi_wq workqueue
writeback: replace custom worker pool implementation with unbound workqueue
writeback: remove unused bdi_pending_list
aoe: Fix unitialized var usage
bio-integrity: Add explicit field for owner of bip_buf
block: Add an explicit bio flag for bios that own their bvec
block: Add bio_alloc_pages()
block: Convert some code to bio_for_each_segment_all()
block: Add bio_for_each_segment_all()
bounce: Refactor __blk_queue_bounce to not use bi_io_vec
raid1: use bio_copy_data()
pktcdvd: Use bio_reset() in disabled code to kill bi_idx usage
pktcdvd: use bio_copy_data()
block: Add bio_copy_data()
...
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/aoe/aoecmd.c | 2 | ||||
-rw-r--r-- | drivers/block/brd.c | 3 | ||||
-rw-r--r-- | drivers/block/floppy.c | 1 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 102 | ||||
-rw-r--r-- | drivers/block/rbd.c | 2 | ||||
-rw-r--r-- | drivers/md/dm-crypt.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-raid1.c | 2 | ||||
-rw-r--r-- | drivers/md/dm-stripe.c | 2 | ||||
-rw-r--r-- | drivers/md/dm-verity.c | 4 | ||||
-rw-r--r-- | drivers/md/faulty.c | 6 | ||||
-rw-r--r-- | drivers/md/linear.c | 3 | ||||
-rw-r--r-- | drivers/md/md.c | 17 | ||||
-rw-r--r-- | drivers/md/raid0.c | 9 | ||||
-rw-r--r-- | drivers/md/raid1.c | 133 | ||||
-rw-r--r-- | drivers/md/raid10.c | 78 | ||||
-rw-r--r-- | drivers/md/raid5.c | 49 | ||||
-rw-r--r-- | drivers/message/fusion/mptsas.c | 6 | ||||
-rw-r--r-- | drivers/s390/block/dcssblk.c | 3 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 6 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_transport.c | 10 |
20 files changed, 142 insertions, 299 deletions
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 92b6d7c51e39..5efed089a702 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -928,7 +928,7 @@ bufinit(struct buf *buf, struct request *rq, struct bio *bio) | |||
928 | buf->resid = bio->bi_size; | 928 | buf->resid = bio->bi_size; |
929 | buf->sector = bio->bi_sector; | 929 | buf->sector = bio->bi_sector; |
930 | bio_pageinc(bio); | 930 | bio_pageinc(bio); |
931 | buf->bv = bv = &bio->bi_io_vec[bio->bi_idx]; | 931 | buf->bv = bv = bio_iovec(bio); |
932 | buf->bv_resid = bv->bv_len; | 932 | buf->bv_resid = bv->bv_len; |
933 | WARN_ON(buf->bv_resid == 0); | 933 | WARN_ON(buf->bv_resid == 0); |
934 | } | 934 | } |
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 531ceb31d0ff..f1a29f8e9d33 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -334,8 +334,7 @@ static void brd_make_request(struct request_queue *q, struct bio *bio) | |||
334 | int err = -EIO; | 334 | int err = -EIO; |
335 | 335 | ||
336 | sector = bio->bi_sector; | 336 | sector = bio->bi_sector; |
337 | if (sector + (bio->bi_size >> SECTOR_SHIFT) > | 337 | if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) |
338 | get_capacity(bdev->bd_disk)) | ||
339 | goto out; | 338 | goto out; |
340 | 339 | ||
341 | if (unlikely(bio->bi_rw & REQ_DISCARD)) { | 340 | if (unlikely(bio->bi_rw & REQ_DISCARD)) { |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index c49e85608101..04ceb7e2fadd 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -3775,7 +3775,6 @@ static int __floppy_read_block_0(struct block_device *bdev) | |||
3775 | bio_vec.bv_len = size; | 3775 | bio_vec.bv_len = size; |
3776 | bio_vec.bv_offset = 0; | 3776 | bio_vec.bv_offset = 0; |
3777 | bio.bi_vcnt = 1; | 3777 | bio.bi_vcnt = 1; |
3778 | bio.bi_idx = 0; | ||
3779 | bio.bi_size = size; | 3778 | bio.bi_size = size; |
3780 | bio.bi_bdev = bdev; | 3779 | bio.bi_bdev = bdev; |
3781 | bio.bi_sector = 0; | 3780 | bio.bi_sector = 0; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 9f2d348f7115..3c08983e600a 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -901,7 +901,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd) | |||
901 | pd->iosched.successive_reads += bio->bi_size >> 10; | 901 | pd->iosched.successive_reads += bio->bi_size >> 10; |
902 | else { | 902 | else { |
903 | pd->iosched.successive_reads = 0; | 903 | pd->iosched.successive_reads = 0; |
904 | pd->iosched.last_write = bio->bi_sector + bio_sectors(bio); | 904 | pd->iosched.last_write = bio_end_sector(bio); |
905 | } | 905 | } |
906 | if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) { | 906 | if (pd->iosched.successive_reads >= HI_SPEED_SWITCH) { |
907 | if (pd->read_speed == pd->write_speed) { | 907 | if (pd->read_speed == pd->write_speed) { |
@@ -948,31 +948,6 @@ static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_que | |||
948 | } | 948 | } |
949 | 949 | ||
950 | /* | 950 | /* |
951 | * Copy CD_FRAMESIZE bytes from src_bio into a destination page | ||
952 | */ | ||
953 | static void pkt_copy_bio_data(struct bio *src_bio, int seg, int offs, struct page *dst_page, int dst_offs) | ||
954 | { | ||
955 | unsigned int copy_size = CD_FRAMESIZE; | ||
956 | |||
957 | while (copy_size > 0) { | ||
958 | struct bio_vec *src_bvl = bio_iovec_idx(src_bio, seg); | ||
959 | void *vfrom = kmap_atomic(src_bvl->bv_page) + | ||
960 | src_bvl->bv_offset + offs; | ||
961 | void *vto = page_address(dst_page) + dst_offs; | ||
962 | int len = min_t(int, copy_size, src_bvl->bv_len - offs); | ||
963 | |||
964 | BUG_ON(len < 0); | ||
965 | memcpy(vto, vfrom, len); | ||
966 | kunmap_atomic(vfrom); | ||
967 | |||
968 | seg++; | ||
969 | offs = 0; | ||
970 | dst_offs += len; | ||
971 | copy_size -= len; | ||
972 | } | ||
973 | } | ||
974 | |||
975 | /* | ||
976 | * Copy all data for this packet to pkt->pages[], so that | 951 | * Copy all data for this packet to pkt->pages[], so that |
977 | * a) The number of required segments for the write bio is minimized, which | 952 | * a) The number of required segments for the write bio is minimized, which |
978 | * is necessary for some scsi controllers. | 953 | * is necessary for some scsi controllers. |
@@ -1181,16 +1156,15 @@ static int pkt_start_recovery(struct packet_data *pkt) | |||
1181 | new_sector = new_block * (CD_FRAMESIZE >> 9); | 1156 | new_sector = new_block * (CD_FRAMESIZE >> 9); |
1182 | pkt->sector = new_sector; | 1157 | pkt->sector = new_sector; |
1183 | 1158 | ||
1159 | bio_reset(pkt->bio); | ||
1160 | pkt->bio->bi_bdev = pd->bdev; | ||
1161 | pkt->bio->bi_rw = REQ_WRITE; | ||
1184 | pkt->bio->bi_sector = new_sector; | 1162 | pkt->bio->bi_sector = new_sector; |
1185 | pkt->bio->bi_next = NULL; | 1163 | pkt->bio->bi_size = pkt->frames * CD_FRAMESIZE; |
1186 | pkt->bio->bi_flags = 1 << BIO_UPTODATE; | 1164 | pkt->bio->bi_vcnt = pkt->frames; |
1187 | pkt->bio->bi_idx = 0; | ||
1188 | 1165 | ||
1189 | BUG_ON(pkt->bio->bi_rw != REQ_WRITE); | 1166 | pkt->bio->bi_end_io = pkt_end_io_packet_write; |
1190 | BUG_ON(pkt->bio->bi_vcnt != pkt->frames); | 1167 | pkt->bio->bi_private = pkt; |
1191 | BUG_ON(pkt->bio->bi_size != pkt->frames * CD_FRAMESIZE); | ||
1192 | BUG_ON(pkt->bio->bi_end_io != pkt_end_io_packet_write); | ||
1193 | BUG_ON(pkt->bio->bi_private != pkt); | ||
1194 | 1168 | ||
1195 | drop_super(sb); | 1169 | drop_super(sb); |
1196 | return 1; | 1170 | return 1; |
@@ -1325,55 +1299,35 @@ try_next_bio: | |||
1325 | */ | 1299 | */ |
1326 | static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) | 1300 | static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) |
1327 | { | 1301 | { |
1328 | struct bio *bio; | ||
1329 | int f; | 1302 | int f; |
1330 | int frames_write; | ||
1331 | struct bio_vec *bvec = pkt->w_bio->bi_io_vec; | 1303 | struct bio_vec *bvec = pkt->w_bio->bi_io_vec; |
1332 | 1304 | ||
1305 | bio_reset(pkt->w_bio); | ||
1306 | pkt->w_bio->bi_sector = pkt->sector; | ||
1307 | pkt->w_bio->bi_bdev = pd->bdev; | ||
1308 | pkt->w_bio->bi_end_io = pkt_end_io_packet_write; | ||
1309 | pkt->w_bio->bi_private = pkt; | ||
1310 | |||
1311 | /* XXX: locking? */ | ||
1333 | for (f = 0; f < pkt->frames; f++) { | 1312 | for (f = 0; f < pkt->frames; f++) { |
1334 | bvec[f].bv_page = pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE]; | 1313 | bvec[f].bv_page = pkt->pages[(f * CD_FRAMESIZE) / PAGE_SIZE]; |
1335 | bvec[f].bv_offset = (f * CD_FRAMESIZE) % PAGE_SIZE; | 1314 | bvec[f].bv_offset = (f * CD_FRAMESIZE) % PAGE_SIZE; |
1315 | if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset)) | ||
1316 | BUG(); | ||
1336 | } | 1317 | } |
1318 | VPRINTK(DRIVER_NAME": vcnt=%d\n", pkt->w_bio->bi_vcnt); | ||
1337 | 1319 | ||
1338 | /* | 1320 | /* |
1339 | * Fill-in bvec with data from orig_bios. | 1321 | * Fill-in bvec with data from orig_bios. |
1340 | */ | 1322 | */ |
1341 | frames_write = 0; | ||
1342 | spin_lock(&pkt->lock); | 1323 | spin_lock(&pkt->lock); |
1343 | bio_list_for_each(bio, &pkt->orig_bios) { | 1324 | bio_copy_data(pkt->w_bio, pkt->orig_bios.head); |
1344 | int segment = bio->bi_idx; | ||
1345 | int src_offs = 0; | ||
1346 | int first_frame = (bio->bi_sector - pkt->sector) / (CD_FRAMESIZE >> 9); | ||
1347 | int num_frames = bio->bi_size / CD_FRAMESIZE; | ||
1348 | BUG_ON(first_frame < 0); | ||
1349 | BUG_ON(first_frame + num_frames > pkt->frames); | ||
1350 | for (f = first_frame; f < first_frame + num_frames; f++) { | ||
1351 | struct bio_vec *src_bvl = bio_iovec_idx(bio, segment); | ||
1352 | |||
1353 | while (src_offs >= src_bvl->bv_len) { | ||
1354 | src_offs -= src_bvl->bv_len; | ||
1355 | segment++; | ||
1356 | BUG_ON(segment >= bio->bi_vcnt); | ||
1357 | src_bvl = bio_iovec_idx(bio, segment); | ||
1358 | } | ||
1359 | 1325 | ||
1360 | if (src_bvl->bv_len - src_offs >= CD_FRAMESIZE) { | ||
1361 | bvec[f].bv_page = src_bvl->bv_page; | ||
1362 | bvec[f].bv_offset = src_bvl->bv_offset + src_offs; | ||
1363 | } else { | ||
1364 | pkt_copy_bio_data(bio, segment, src_offs, | ||
1365 | bvec[f].bv_page, bvec[f].bv_offset); | ||
1366 | } | ||
1367 | src_offs += CD_FRAMESIZE; | ||
1368 | frames_write++; | ||
1369 | } | ||
1370 | } | ||
1371 | pkt_set_state(pkt, PACKET_WRITE_WAIT_STATE); | 1326 | pkt_set_state(pkt, PACKET_WRITE_WAIT_STATE); |
1372 | spin_unlock(&pkt->lock); | 1327 | spin_unlock(&pkt->lock); |
1373 | 1328 | ||
1374 | VPRINTK("pkt_start_write: Writing %d frames for zone %llx\n", | 1329 | VPRINTK("pkt_start_write: Writing %d frames for zone %llx\n", |
1375 | frames_write, (unsigned long long)pkt->sector); | 1330 | pkt->write_size, (unsigned long long)pkt->sector); |
1376 | BUG_ON(frames_write != pkt->write_size); | ||
1377 | 1331 | ||
1378 | if (test_bit(PACKET_MERGE_SEGS, &pd->flags) || (pkt->write_size < pkt->frames)) { | 1332 | if (test_bit(PACKET_MERGE_SEGS, &pd->flags) || (pkt->write_size < pkt->frames)) { |
1379 | pkt_make_local_copy(pkt, bvec); | 1333 | pkt_make_local_copy(pkt, bvec); |
@@ -1383,16 +1337,6 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) | |||
1383 | } | 1337 | } |
1384 | 1338 | ||
1385 | /* Start the write request */ | 1339 | /* Start the write request */ |
1386 | bio_reset(pkt->w_bio); | ||
1387 | pkt->w_bio->bi_sector = pkt->sector; | ||
1388 | pkt->w_bio->bi_bdev = pd->bdev; | ||
1389 | pkt->w_bio->bi_end_io = pkt_end_io_packet_write; | ||
1390 | pkt->w_bio->bi_private = pkt; | ||
1391 | for (f = 0; f < pkt->frames; f++) | ||
1392 | if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset)) | ||
1393 | BUG(); | ||
1394 | VPRINTK(DRIVER_NAME": vcnt=%d\n", pkt->w_bio->bi_vcnt); | ||
1395 | |||
1396 | atomic_set(&pkt->io_wait, 1); | 1340 | atomic_set(&pkt->io_wait, 1); |
1397 | pkt->w_bio->bi_rw = WRITE; | 1341 | pkt->w_bio->bi_rw = WRITE; |
1398 | pkt_queue_bio(pd, pkt->w_bio); | 1342 | pkt_queue_bio(pd, pkt->w_bio); |
@@ -2431,7 +2375,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2431 | cloned_bio->bi_bdev = pd->bdev; | 2375 | cloned_bio->bi_bdev = pd->bdev; |
2432 | cloned_bio->bi_private = psd; | 2376 | cloned_bio->bi_private = psd; |
2433 | cloned_bio->bi_end_io = pkt_end_io_read_cloned; | 2377 | cloned_bio->bi_end_io = pkt_end_io_read_cloned; |
2434 | pd->stats.secs_r += bio->bi_size >> 9; | 2378 | pd->stats.secs_r += bio_sectors(bio); |
2435 | pkt_queue_bio(pd, cloned_bio); | 2379 | pkt_queue_bio(pd, cloned_bio); |
2436 | return; | 2380 | return; |
2437 | } | 2381 | } |
@@ -2452,7 +2396,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2452 | zone = ZONE(bio->bi_sector, pd); | 2396 | zone = ZONE(bio->bi_sector, pd); |
2453 | VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n", | 2397 | VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n", |
2454 | (unsigned long long)bio->bi_sector, | 2398 | (unsigned long long)bio->bi_sector, |
2455 | (unsigned long long)(bio->bi_sector + bio_sectors(bio))); | 2399 | (unsigned long long)bio_end_sector(bio)); |
2456 | 2400 | ||
2457 | /* Check if we have to split the bio */ | 2401 | /* Check if we have to split the bio */ |
2458 | { | 2402 | { |
@@ -2460,7 +2404,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2460 | sector_t last_zone; | 2404 | sector_t last_zone; |
2461 | int first_sectors; | 2405 | int first_sectors; |
2462 | 2406 | ||
2463 | last_zone = ZONE(bio->bi_sector + bio_sectors(bio) - 1, pd); | 2407 | last_zone = ZONE(bio_end_sector(bio) - 1, pd); |
2464 | if (last_zone != zone) { | 2408 | if (last_zone != zone) { |
2465 | BUG_ON(last_zone != zone + pd->settings.size); | 2409 | BUG_ON(last_zone != zone + pd->settings.size); |
2466 | first_sectors = last_zone - bio->bi_sector; | 2410 | first_sectors = last_zone - bio->bi_sector; |
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 22ffd5dcb168..ca63104136e0 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1143,7 +1143,7 @@ static struct bio *bio_clone_range(struct bio *bio_src, | |||
1143 | /* Find first affected segment... */ | 1143 | /* Find first affected segment... */ |
1144 | 1144 | ||
1145 | resid = offset; | 1145 | resid = offset; |
1146 | __bio_for_each_segment(bv, bio_src, idx, 0) { | 1146 | bio_for_each_segment(bv, bio_src, idx) { |
1147 | if (resid < bv->bv_len) | 1147 | if (resid < bv->bv_len) |
1148 | break; | 1148 | break; |
1149 | resid -= bv->bv_len; | 1149 | resid -= bv->bv_len; |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 13c15480d940..6d2d41ae9e32 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -858,8 +858,7 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) | |||
858 | unsigned int i; | 858 | unsigned int i; |
859 | struct bio_vec *bv; | 859 | struct bio_vec *bv; |
860 | 860 | ||
861 | for (i = 0; i < clone->bi_vcnt; i++) { | 861 | bio_for_each_segment_all(bv, clone, i) { |
862 | bv = bio_iovec_idx(clone, i); | ||
863 | BUG_ON(!bv->bv_page); | 862 | BUG_ON(!bv->bv_page); |
864 | mempool_free(bv->bv_page, cc->page_pool); | 863 | mempool_free(bv->bv_page, cc->page_pool); |
865 | bv->bv_page = NULL; | 864 | bv->bv_page = NULL; |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index d053098c6a91..699b5be68d31 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -458,7 +458,7 @@ static void map_region(struct dm_io_region *io, struct mirror *m, | |||
458 | { | 458 | { |
459 | io->bdev = m->dev->bdev; | 459 | io->bdev = m->dev->bdev; |
460 | io->sector = map_sector(m, bio); | 460 | io->sector = map_sector(m, bio); |
461 | io->count = bio->bi_size >> 9; | 461 | io->count = bio_sectors(bio); |
462 | } | 462 | } |
463 | 463 | ||
464 | static void hold_bio(struct mirror_set *ms, struct bio *bio) | 464 | static void hold_bio(struct mirror_set *ms, struct bio *bio) |
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index d8837d313f54..ea5e878a30b9 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c | |||
@@ -258,7 +258,7 @@ static int stripe_map_range(struct stripe_c *sc, struct bio *bio, | |||
258 | sector_t begin, end; | 258 | sector_t begin, end; |
259 | 259 | ||
260 | stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin); | 260 | stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin); |
261 | stripe_map_range_sector(sc, bio->bi_sector + bio_sectors(bio), | 261 | stripe_map_range_sector(sc, bio_end_sector(bio), |
262 | target_stripe, &end); | 262 | target_stripe, &end); |
263 | if (begin < end) { | 263 | if (begin < end) { |
264 | bio->bi_bdev = sc->stripe[target_stripe].dev->bdev; | 264 | bio->bi_bdev = sc->stripe[target_stripe].dev->bdev; |
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c index a746f1d21c66..b948fd864d45 100644 --- a/drivers/md/dm-verity.c +++ b/drivers/md/dm-verity.c | |||
@@ -501,7 +501,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio) | |||
501 | return -EIO; | 501 | return -EIO; |
502 | } | 502 | } |
503 | 503 | ||
504 | if ((bio->bi_sector + bio_sectors(bio)) >> | 504 | if (bio_end_sector(bio) >> |
505 | (v->data_dev_block_bits - SECTOR_SHIFT) > v->data_blocks) { | 505 | (v->data_dev_block_bits - SECTOR_SHIFT) > v->data_blocks) { |
506 | DMERR_LIMIT("io out of range"); | 506 | DMERR_LIMIT("io out of range"); |
507 | return -EIO; | 507 | return -EIO; |
@@ -519,7 +519,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio) | |||
519 | 519 | ||
520 | bio->bi_end_io = verity_end_io; | 520 | bio->bi_end_io = verity_end_io; |
521 | bio->bi_private = io; | 521 | bio->bi_private = io; |
522 | io->io_vec_size = bio->bi_vcnt - bio->bi_idx; | 522 | io->io_vec_size = bio_segments(bio); |
523 | if (io->io_vec_size < DM_VERITY_IO_VEC_INLINE) | 523 | if (io->io_vec_size < DM_VERITY_IO_VEC_INLINE) |
524 | io->io_vec = io->io_vec_inline; | 524 | io->io_vec = io->io_vec_inline; |
525 | else | 525 | else |
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c index 5e7dc772f5de..3193aefe982b 100644 --- a/drivers/md/faulty.c +++ b/drivers/md/faulty.c | |||
@@ -185,8 +185,7 @@ static void make_request(struct mddev *mddev, struct bio *bio) | |||
185 | return; | 185 | return; |
186 | } | 186 | } |
187 | 187 | ||
188 | if (check_sector(conf, bio->bi_sector, bio->bi_sector+(bio->bi_size>>9), | 188 | if (check_sector(conf, bio->bi_sector, bio_end_sector(bio), WRITE)) |
189 | WRITE)) | ||
190 | failit = 1; | 189 | failit = 1; |
191 | if (check_mode(conf, WritePersistent)) { | 190 | if (check_mode(conf, WritePersistent)) { |
192 | add_sector(conf, bio->bi_sector, WritePersistent); | 191 | add_sector(conf, bio->bi_sector, WritePersistent); |
@@ -196,8 +195,7 @@ static void make_request(struct mddev *mddev, struct bio *bio) | |||
196 | failit = 1; | 195 | failit = 1; |
197 | } else { | 196 | } else { |
198 | /* read request */ | 197 | /* read request */ |
199 | if (check_sector(conf, bio->bi_sector, bio->bi_sector + (bio->bi_size>>9), | 198 | if (check_sector(conf, bio->bi_sector, bio_end_sector(bio), READ)) |
200 | READ)) | ||
201 | failit = 1; | 199 | failit = 1; |
202 | if (check_mode(conf, ReadTransient)) | 200 | if (check_mode(conf, ReadTransient)) |
203 | failit = 1; | 201 | failit = 1; |
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 21014836bdbf..f03fabd2b37b 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -317,8 +317,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio) | |||
317 | bio_io_error(bio); | 317 | bio_io_error(bio); |
318 | return; | 318 | return; |
319 | } | 319 | } |
320 | if (unlikely(bio->bi_sector + (bio->bi_size >> 9) > | 320 | if (unlikely(bio_end_sector(bio) > tmp_dev->end_sector)) { |
321 | tmp_dev->end_sector)) { | ||
322 | /* This bio crosses a device boundary, so we have to | 321 | /* This bio crosses a device boundary, so we have to |
323 | * split it. | 322 | * split it. |
324 | */ | 323 | */ |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 6330c727396c..681d1099a2d5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -197,21 +197,12 @@ void md_trim_bio(struct bio *bio, int offset, int size) | |||
197 | if (offset == 0 && size == bio->bi_size) | 197 | if (offset == 0 && size == bio->bi_size) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | bio->bi_sector += offset; | ||
201 | bio->bi_size = size; | ||
202 | offset <<= 9; | ||
203 | clear_bit(BIO_SEG_VALID, &bio->bi_flags); | 200 | clear_bit(BIO_SEG_VALID, &bio->bi_flags); |
204 | 201 | ||
205 | while (bio->bi_idx < bio->bi_vcnt && | 202 | bio_advance(bio, offset << 9); |
206 | bio->bi_io_vec[bio->bi_idx].bv_len <= offset) { | 203 | |
207 | /* remove this whole bio_vec */ | 204 | bio->bi_size = size; |
208 | offset -= bio->bi_io_vec[bio->bi_idx].bv_len; | 205 | |
209 | bio->bi_idx++; | ||
210 | } | ||
211 | if (bio->bi_idx < bio->bi_vcnt) { | ||
212 | bio->bi_io_vec[bio->bi_idx].bv_offset += offset; | ||
213 | bio->bi_io_vec[bio->bi_idx].bv_len -= offset; | ||
214 | } | ||
215 | /* avoid any complications with bi_idx being non-zero*/ | 206 | /* avoid any complications with bi_idx being non-zero*/ |
216 | if (bio->bi_idx) { | 207 | if (bio->bi_idx) { |
217 | memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx, | 208 | memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx, |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 0505452de8d6..fcf65e512cf5 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -502,11 +502,11 @@ static inline int is_io_in_chunk_boundary(struct mddev *mddev, | |||
502 | { | 502 | { |
503 | if (likely(is_power_of_2(chunk_sects))) { | 503 | if (likely(is_power_of_2(chunk_sects))) { |
504 | return chunk_sects >= ((bio->bi_sector & (chunk_sects-1)) | 504 | return chunk_sects >= ((bio->bi_sector & (chunk_sects-1)) |
505 | + (bio->bi_size >> 9)); | 505 | + bio_sectors(bio)); |
506 | } else{ | 506 | } else{ |
507 | sector_t sector = bio->bi_sector; | 507 | sector_t sector = bio->bi_sector; |
508 | return chunk_sects >= (sector_div(sector, chunk_sects) | 508 | return chunk_sects >= (sector_div(sector, chunk_sects) |
509 | + (bio->bi_size >> 9)); | 509 | + bio_sectors(bio)); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
@@ -527,8 +527,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio) | |||
527 | sector_t sector = bio->bi_sector; | 527 | sector_t sector = bio->bi_sector; |
528 | struct bio_pair *bp; | 528 | struct bio_pair *bp; |
529 | /* Sanity check -- queue functions should prevent this happening */ | 529 | /* Sanity check -- queue functions should prevent this happening */ |
530 | if ((bio->bi_vcnt != 1 && bio->bi_vcnt != 0) || | 530 | if (bio_segments(bio) > 1) |
531 | bio->bi_idx != 0) | ||
532 | goto bad_map; | 531 | goto bad_map; |
533 | /* This is a one page bio that upper layers | 532 | /* This is a one page bio that upper layers |
534 | * refuse to split for us, so we need to split it. | 533 | * refuse to split for us, so we need to split it. |
@@ -567,7 +566,7 @@ bad_map: | |||
567 | printk("md/raid0:%s: make_request bug: can't convert block across chunks" | 566 | printk("md/raid0:%s: make_request bug: can't convert block across chunks" |
568 | " or bigger than %dk %llu %d\n", | 567 | " or bigger than %dk %llu %d\n", |
569 | mdname(mddev), chunk_sects / 2, | 568 | mdname(mddev), chunk_sects / 2, |
570 | (unsigned long long)bio->bi_sector, bio->bi_size >> 10); | 569 | (unsigned long long)bio->bi_sector, bio_sectors(bio) / 2); |
571 | 570 | ||
572 | bio_io_error(bio); | 571 | bio_io_error(bio); |
573 | return; | 572 | return; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 851023e2ba5d..55951182af73 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -92,7 +92,6 @@ static void r1bio_pool_free(void *r1_bio, void *data) | |||
92 | static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) | 92 | static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) |
93 | { | 93 | { |
94 | struct pool_info *pi = data; | 94 | struct pool_info *pi = data; |
95 | struct page *page; | ||
96 | struct r1bio *r1_bio; | 95 | struct r1bio *r1_bio; |
97 | struct bio *bio; | 96 | struct bio *bio; |
98 | int i, j; | 97 | int i, j; |
@@ -122,14 +121,10 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) | |||
122 | j = 1; | 121 | j = 1; |
123 | while(j--) { | 122 | while(j--) { |
124 | bio = r1_bio->bios[j]; | 123 | bio = r1_bio->bios[j]; |
125 | for (i = 0; i < RESYNC_PAGES; i++) { | 124 | bio->bi_vcnt = RESYNC_PAGES; |
126 | page = alloc_page(gfp_flags); | ||
127 | if (unlikely(!page)) | ||
128 | goto out_free_pages; | ||
129 | 125 | ||
130 | bio->bi_io_vec[i].bv_page = page; | 126 | if (bio_alloc_pages(bio, gfp_flags)) |
131 | bio->bi_vcnt = i+1; | 127 | goto out_free_bio; |
132 | } | ||
133 | } | 128 | } |
134 | /* If not user-requests, copy the page pointers to all bios */ | 129 | /* If not user-requests, copy the page pointers to all bios */ |
135 | if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { | 130 | if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { |
@@ -143,11 +138,6 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) | |||
143 | 138 | ||
144 | return r1_bio; | 139 | return r1_bio; |
145 | 140 | ||
146 | out_free_pages: | ||
147 | for (j=0 ; j < pi->raid_disks; j++) | ||
148 | for (i=0; i < r1_bio->bios[j]->bi_vcnt ; i++) | ||
149 | put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); | ||
150 | j = -1; | ||
151 | out_free_bio: | 141 | out_free_bio: |
152 | while (++j < pi->raid_disks) | 142 | while (++j < pi->raid_disks) |
153 | bio_put(r1_bio->bios[j]); | 143 | bio_put(r1_bio->bios[j]); |
@@ -267,7 +257,7 @@ static void raid_end_bio_io(struct r1bio *r1_bio) | |||
267 | (bio_data_dir(bio) == WRITE) ? "write" : "read", | 257 | (bio_data_dir(bio) == WRITE) ? "write" : "read", |
268 | (unsigned long long) bio->bi_sector, | 258 | (unsigned long long) bio->bi_sector, |
269 | (unsigned long long) bio->bi_sector + | 259 | (unsigned long long) bio->bi_sector + |
270 | (bio->bi_size >> 9) - 1); | 260 | bio_sectors(bio) - 1); |
271 | 261 | ||
272 | call_bio_endio(r1_bio); | 262 | call_bio_endio(r1_bio); |
273 | } | 263 | } |
@@ -458,7 +448,7 @@ static void raid1_end_write_request(struct bio *bio, int error) | |||
458 | " %llu-%llu\n", | 448 | " %llu-%llu\n", |
459 | (unsigned long long) mbio->bi_sector, | 449 | (unsigned long long) mbio->bi_sector, |
460 | (unsigned long long) mbio->bi_sector + | 450 | (unsigned long long) mbio->bi_sector + |
461 | (mbio->bi_size >> 9) - 1); | 451 | bio_sectors(mbio) - 1); |
462 | call_bio_endio(r1_bio); | 452 | call_bio_endio(r1_bio); |
463 | } | 453 | } |
464 | } | 454 | } |
@@ -925,7 +915,7 @@ static void alloc_behind_pages(struct bio *bio, struct r1bio *r1_bio) | |||
925 | if (unlikely(!bvecs)) | 915 | if (unlikely(!bvecs)) |
926 | return; | 916 | return; |
927 | 917 | ||
928 | bio_for_each_segment(bvec, bio, i) { | 918 | bio_for_each_segment_all(bvec, bio, i) { |
929 | bvecs[i] = *bvec; | 919 | bvecs[i] = *bvec; |
930 | bvecs[i].bv_page = alloc_page(GFP_NOIO); | 920 | bvecs[i].bv_page = alloc_page(GFP_NOIO); |
931 | if (unlikely(!bvecs[i].bv_page)) | 921 | if (unlikely(!bvecs[i].bv_page)) |
@@ -1023,7 +1013,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1023 | md_write_start(mddev, bio); /* wait on superblock update early */ | 1013 | md_write_start(mddev, bio); /* wait on superblock update early */ |
1024 | 1014 | ||
1025 | if (bio_data_dir(bio) == WRITE && | 1015 | if (bio_data_dir(bio) == WRITE && |
1026 | bio->bi_sector + bio->bi_size/512 > mddev->suspend_lo && | 1016 | bio_end_sector(bio) > mddev->suspend_lo && |
1027 | bio->bi_sector < mddev->suspend_hi) { | 1017 | bio->bi_sector < mddev->suspend_hi) { |
1028 | /* As the suspend_* range is controlled by | 1018 | /* As the suspend_* range is controlled by |
1029 | * userspace, we want an interruptible | 1019 | * userspace, we want an interruptible |
@@ -1034,7 +1024,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1034 | flush_signals(current); | 1024 | flush_signals(current); |
1035 | prepare_to_wait(&conf->wait_barrier, | 1025 | prepare_to_wait(&conf->wait_barrier, |
1036 | &w, TASK_INTERRUPTIBLE); | 1026 | &w, TASK_INTERRUPTIBLE); |
1037 | if (bio->bi_sector + bio->bi_size/512 <= mddev->suspend_lo || | 1027 | if (bio_end_sector(bio) <= mddev->suspend_lo || |
1038 | bio->bi_sector >= mddev->suspend_hi) | 1028 | bio->bi_sector >= mddev->suspend_hi) |
1039 | break; | 1029 | break; |
1040 | schedule(); | 1030 | schedule(); |
@@ -1054,7 +1044,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1054 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); | 1044 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); |
1055 | 1045 | ||
1056 | r1_bio->master_bio = bio; | 1046 | r1_bio->master_bio = bio; |
1057 | r1_bio->sectors = bio->bi_size >> 9; | 1047 | r1_bio->sectors = bio_sectors(bio); |
1058 | r1_bio->state = 0; | 1048 | r1_bio->state = 0; |
1059 | r1_bio->mddev = mddev; | 1049 | r1_bio->mddev = mddev; |
1060 | r1_bio->sector = bio->bi_sector; | 1050 | r1_bio->sector = bio->bi_sector; |
@@ -1132,7 +1122,7 @@ read_again: | |||
1132 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); | 1122 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); |
1133 | 1123 | ||
1134 | r1_bio->master_bio = bio; | 1124 | r1_bio->master_bio = bio; |
1135 | r1_bio->sectors = (bio->bi_size >> 9) - sectors_handled; | 1125 | r1_bio->sectors = bio_sectors(bio) - sectors_handled; |
1136 | r1_bio->state = 0; | 1126 | r1_bio->state = 0; |
1137 | r1_bio->mddev = mddev; | 1127 | r1_bio->mddev = mddev; |
1138 | r1_bio->sector = bio->bi_sector + sectors_handled; | 1128 | r1_bio->sector = bio->bi_sector + sectors_handled; |
@@ -1289,14 +1279,10 @@ read_again: | |||
1289 | struct bio_vec *bvec; | 1279 | struct bio_vec *bvec; |
1290 | int j; | 1280 | int j; |
1291 | 1281 | ||
1292 | /* Yes, I really want the '__' version so that | 1282 | /* |
1293 | * we clear any unused pointer in the io_vec, rather | 1283 | * We trimmed the bio, so _all is legit |
1294 | * than leave them unchanged. This is important | ||
1295 | * because when we come to free the pages, we won't | ||
1296 | * know the original bi_idx, so we just free | ||
1297 | * them all | ||
1298 | */ | 1284 | */ |
1299 | __bio_for_each_segment(bvec, mbio, j, 0) | 1285 | bio_for_each_segment_all(bvec, mbio, j) |
1300 | bvec->bv_page = r1_bio->behind_bvecs[j].bv_page; | 1286 | bvec->bv_page = r1_bio->behind_bvecs[j].bv_page; |
1301 | if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags)) | 1287 | if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags)) |
1302 | atomic_inc(&r1_bio->behind_remaining); | 1288 | atomic_inc(&r1_bio->behind_remaining); |
@@ -1334,14 +1320,14 @@ read_again: | |||
1334 | /* Mustn't call r1_bio_write_done before this next test, | 1320 | /* Mustn't call r1_bio_write_done before this next test, |
1335 | * as it could result in the bio being freed. | 1321 | * as it could result in the bio being freed. |
1336 | */ | 1322 | */ |
1337 | if (sectors_handled < (bio->bi_size >> 9)) { | 1323 | if (sectors_handled < bio_sectors(bio)) { |
1338 | r1_bio_write_done(r1_bio); | 1324 | r1_bio_write_done(r1_bio); |
1339 | /* We need another r1_bio. It has already been counted | 1325 | /* We need another r1_bio. It has already been counted |
1340 | * in bio->bi_phys_segments | 1326 | * in bio->bi_phys_segments |
1341 | */ | 1327 | */ |
1342 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); | 1328 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); |
1343 | r1_bio->master_bio = bio; | 1329 | r1_bio->master_bio = bio; |
1344 | r1_bio->sectors = (bio->bi_size >> 9) - sectors_handled; | 1330 | r1_bio->sectors = bio_sectors(bio) - sectors_handled; |
1345 | r1_bio->state = 0; | 1331 | r1_bio->state = 0; |
1346 | r1_bio->mddev = mddev; | 1332 | r1_bio->mddev = mddev; |
1347 | r1_bio->sector = bio->bi_sector + sectors_handled; | 1333 | r1_bio->sector = bio->bi_sector + sectors_handled; |
@@ -1867,7 +1853,7 @@ static int process_checks(struct r1bio *r1_bio) | |||
1867 | struct bio *sbio = r1_bio->bios[i]; | 1853 | struct bio *sbio = r1_bio->bios[i]; |
1868 | int size; | 1854 | int size; |
1869 | 1855 | ||
1870 | if (r1_bio->bios[i]->bi_end_io != end_sync_read) | 1856 | if (sbio->bi_end_io != end_sync_read) |
1871 | continue; | 1857 | continue; |
1872 | 1858 | ||
1873 | if (test_bit(BIO_UPTODATE, &sbio->bi_flags)) { | 1859 | if (test_bit(BIO_UPTODATE, &sbio->bi_flags)) { |
@@ -1892,16 +1878,15 @@ static int process_checks(struct r1bio *r1_bio) | |||
1892 | continue; | 1878 | continue; |
1893 | } | 1879 | } |
1894 | /* fixup the bio for reuse */ | 1880 | /* fixup the bio for reuse */ |
1881 | bio_reset(sbio); | ||
1895 | sbio->bi_vcnt = vcnt; | 1882 | sbio->bi_vcnt = vcnt; |
1896 | sbio->bi_size = r1_bio->sectors << 9; | 1883 | sbio->bi_size = r1_bio->sectors << 9; |
1897 | sbio->bi_idx = 0; | ||
1898 | sbio->bi_phys_segments = 0; | ||
1899 | sbio->bi_flags &= ~(BIO_POOL_MASK - 1); | ||
1900 | sbio->bi_flags |= 1 << BIO_UPTODATE; | ||
1901 | sbio->bi_next = NULL; | ||
1902 | sbio->bi_sector = r1_bio->sector + | 1884 | sbio->bi_sector = r1_bio->sector + |
1903 | conf->mirrors[i].rdev->data_offset; | 1885 | conf->mirrors[i].rdev->data_offset; |
1904 | sbio->bi_bdev = conf->mirrors[i].rdev->bdev; | 1886 | sbio->bi_bdev = conf->mirrors[i].rdev->bdev; |
1887 | sbio->bi_end_io = end_sync_read; | ||
1888 | sbio->bi_private = r1_bio; | ||
1889 | |||
1905 | size = sbio->bi_size; | 1890 | size = sbio->bi_size; |
1906 | for (j = 0; j < vcnt ; j++) { | 1891 | for (j = 0; j < vcnt ; j++) { |
1907 | struct bio_vec *bi; | 1892 | struct bio_vec *bi; |
@@ -1912,10 +1897,9 @@ static int process_checks(struct r1bio *r1_bio) | |||
1912 | else | 1897 | else |
1913 | bi->bv_len = size; | 1898 | bi->bv_len = size; |
1914 | size -= PAGE_SIZE; | 1899 | size -= PAGE_SIZE; |
1915 | memcpy(page_address(bi->bv_page), | ||
1916 | page_address(pbio->bi_io_vec[j].bv_page), | ||
1917 | PAGE_SIZE); | ||
1918 | } | 1900 | } |
1901 | |||
1902 | bio_copy_data(sbio, pbio); | ||
1919 | } | 1903 | } |
1920 | return 0; | 1904 | return 0; |
1921 | } | 1905 | } |
@@ -1952,7 +1936,7 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio) | |||
1952 | wbio->bi_rw = WRITE; | 1936 | wbio->bi_rw = WRITE; |
1953 | wbio->bi_end_io = end_sync_write; | 1937 | wbio->bi_end_io = end_sync_write; |
1954 | atomic_inc(&r1_bio->remaining); | 1938 | atomic_inc(&r1_bio->remaining); |
1955 | md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9); | 1939 | md_sync_acct(conf->mirrors[i].rdev->bdev, bio_sectors(wbio)); |
1956 | 1940 | ||
1957 | generic_make_request(wbio); | 1941 | generic_make_request(wbio); |
1958 | } | 1942 | } |
@@ -2064,32 +2048,11 @@ static void fix_read_error(struct r1conf *conf, int read_disk, | |||
2064 | } | 2048 | } |
2065 | } | 2049 | } |
2066 | 2050 | ||
2067 | static void bi_complete(struct bio *bio, int error) | ||
2068 | { | ||
2069 | complete((struct completion *)bio->bi_private); | ||
2070 | } | ||
2071 | |||
2072 | static int submit_bio_wait(int rw, struct bio *bio) | ||
2073 | { | ||
2074 | struct completion event; | ||
2075 | rw |= REQ_SYNC; | ||
2076 | |||
2077 | init_completion(&event); | ||
2078 | bio->bi_private = &event; | ||
2079 | bio->bi_end_io = bi_complete; | ||
2080 | submit_bio(rw, bio); | ||
2081 | wait_for_completion(&event); | ||
2082 | |||
2083 | return test_bit(BIO_UPTODATE, &bio->bi_flags); | ||
2084 | } | ||
2085 | |||
2086 | static int narrow_write_error(struct r1bio *r1_bio, int i) | 2051 | static int narrow_write_error(struct r1bio *r1_bio, int i) |
2087 | { | 2052 | { |
2088 | struct mddev *mddev = r1_bio->mddev; | 2053 | struct mddev *mddev = r1_bio->mddev; |
2089 | struct r1conf *conf = mddev->private; | 2054 | struct r1conf *conf = mddev->private; |
2090 | struct md_rdev *rdev = conf->mirrors[i].rdev; | 2055 | struct md_rdev *rdev = conf->mirrors[i].rdev; |
2091 | int vcnt, idx; | ||
2092 | struct bio_vec *vec; | ||
2093 | 2056 | ||
2094 | /* bio has the data to be written to device 'i' where | 2057 | /* bio has the data to be written to device 'i' where |
2095 | * we just recently had a write error. | 2058 | * we just recently had a write error. |
@@ -2117,30 +2080,32 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) | |||
2117 | & ~(sector_t)(block_sectors - 1)) | 2080 | & ~(sector_t)(block_sectors - 1)) |
2118 | - sector; | 2081 | - sector; |
2119 | 2082 | ||
2120 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { | ||
2121 | vcnt = r1_bio->behind_page_count; | ||
2122 | vec = r1_bio->behind_bvecs; | ||
2123 | idx = 0; | ||
2124 | while (vec[idx].bv_page == NULL) | ||
2125 | idx++; | ||
2126 | } else { | ||
2127 | vcnt = r1_bio->master_bio->bi_vcnt; | ||
2128 | vec = r1_bio->master_bio->bi_io_vec; | ||
2129 | idx = r1_bio->master_bio->bi_idx; | ||
2130 | } | ||
2131 | while (sect_to_write) { | 2083 | while (sect_to_write) { |
2132 | struct bio *wbio; | 2084 | struct bio *wbio; |
2133 | if (sectors > sect_to_write) | 2085 | if (sectors > sect_to_write) |
2134 | sectors = sect_to_write; | 2086 | sectors = sect_to_write; |
2135 | /* Write at 'sector' for 'sectors'*/ | 2087 | /* Write at 'sector' for 'sectors'*/ |
2136 | 2088 | ||
2137 | wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); | 2089 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { |
2138 | memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); | 2090 | unsigned vcnt = r1_bio->behind_page_count; |
2139 | wbio->bi_sector = r1_bio->sector; | 2091 | struct bio_vec *vec = r1_bio->behind_bvecs; |
2092 | |||
2093 | while (!vec->bv_page) { | ||
2094 | vec++; | ||
2095 | vcnt--; | ||
2096 | } | ||
2097 | |||
2098 | wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); | ||
2099 | memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); | ||
2100 | |||
2101 | wbio->bi_vcnt = vcnt; | ||
2102 | } else { | ||
2103 | wbio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev); | ||
2104 | } | ||
2105 | |||
2140 | wbio->bi_rw = WRITE; | 2106 | wbio->bi_rw = WRITE; |
2141 | wbio->bi_vcnt = vcnt; | 2107 | wbio->bi_sector = r1_bio->sector; |
2142 | wbio->bi_size = r1_bio->sectors << 9; | 2108 | wbio->bi_size = r1_bio->sectors << 9; |
2143 | wbio->bi_idx = idx; | ||
2144 | 2109 | ||
2145 | md_trim_bio(wbio, sector - r1_bio->sector, sectors); | 2110 | md_trim_bio(wbio, sector - r1_bio->sector, sectors); |
2146 | wbio->bi_sector += rdev->data_offset; | 2111 | wbio->bi_sector += rdev->data_offset; |
@@ -2289,8 +2254,7 @@ read_more: | |||
2289 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); | 2254 | r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); |
2290 | 2255 | ||
2291 | r1_bio->master_bio = mbio; | 2256 | r1_bio->master_bio = mbio; |
2292 | r1_bio->sectors = (mbio->bi_size >> 9) | 2257 | r1_bio->sectors = bio_sectors(mbio) - sectors_handled; |
2293 | - sectors_handled; | ||
2294 | r1_bio->state = 0; | 2258 | r1_bio->state = 0; |
2295 | set_bit(R1BIO_ReadError, &r1_bio->state); | 2259 | set_bit(R1BIO_ReadError, &r1_bio->state); |
2296 | r1_bio->mddev = mddev; | 2260 | r1_bio->mddev = mddev; |
@@ -2464,18 +2428,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int *skipp | |||
2464 | for (i = 0; i < conf->raid_disks * 2; i++) { | 2428 | for (i = 0; i < conf->raid_disks * 2; i++) { |
2465 | struct md_rdev *rdev; | 2429 | struct md_rdev *rdev; |
2466 | bio = r1_bio->bios[i]; | 2430 | bio = r1_bio->bios[i]; |
2467 | 2431 | bio_reset(bio); | |
2468 | /* take from bio_init */ | ||
2469 | bio->bi_next = NULL; | ||
2470 | bio->bi_flags &= ~(BIO_POOL_MASK-1); | ||
2471 | bio->bi_flags |= 1 << BIO_UPTODATE; | ||
2472 | bio->bi_rw = READ; | ||
2473 | bio->bi_vcnt = 0; | ||
2474 | bio->bi_idx = 0; | ||
2475 | bio->bi_phys_segments = 0; | ||
2476 | bio->bi_size = 0; | ||
2477 | bio->bi_end_io = NULL; | ||
2478 | bio->bi_private = NULL; | ||
2479 | 2432 | ||
2480 | rdev = rcu_dereference(conf->mirrors[i].rdev); | 2433 | rdev = rcu_dereference(conf->mirrors[i].rdev); |
2481 | if (rdev == NULL || | 2434 | if (rdev == NULL || |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 018741ba9310..59d4daa5f4c7 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1174,14 +1174,13 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1174 | /* If this request crosses a chunk boundary, we need to | 1174 | /* If this request crosses a chunk boundary, we need to |
1175 | * split it. This will only happen for 1 PAGE (or less) requests. | 1175 | * split it. This will only happen for 1 PAGE (or less) requests. |
1176 | */ | 1176 | */ |
1177 | if (unlikely((bio->bi_sector & chunk_mask) + (bio->bi_size >> 9) | 1177 | if (unlikely((bio->bi_sector & chunk_mask) + bio_sectors(bio) |
1178 | > chunk_sects | 1178 | > chunk_sects |
1179 | && (conf->geo.near_copies < conf->geo.raid_disks | 1179 | && (conf->geo.near_copies < conf->geo.raid_disks |
1180 | || conf->prev.near_copies < conf->prev.raid_disks))) { | 1180 | || conf->prev.near_copies < conf->prev.raid_disks))) { |
1181 | struct bio_pair *bp; | 1181 | struct bio_pair *bp; |
1182 | /* Sanity check -- queue functions should prevent this happening */ | 1182 | /* Sanity check -- queue functions should prevent this happening */ |
1183 | if ((bio->bi_vcnt != 1 && bio->bi_vcnt != 0) || | 1183 | if (bio_segments(bio) > 1) |
1184 | bio->bi_idx != 0) | ||
1185 | goto bad_map; | 1184 | goto bad_map; |
1186 | /* This is a one page bio that upper layers | 1185 | /* This is a one page bio that upper layers |
1187 | * refuse to split for us, so we need to split it. | 1186 | * refuse to split for us, so we need to split it. |
@@ -1214,7 +1213,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1214 | bad_map: | 1213 | bad_map: |
1215 | printk("md/raid10:%s: make_request bug: can't convert block across chunks" | 1214 | printk("md/raid10:%s: make_request bug: can't convert block across chunks" |
1216 | " or bigger than %dk %llu %d\n", mdname(mddev), chunk_sects/2, | 1215 | " or bigger than %dk %llu %d\n", mdname(mddev), chunk_sects/2, |
1217 | (unsigned long long)bio->bi_sector, bio->bi_size >> 10); | 1216 | (unsigned long long)bio->bi_sector, bio_sectors(bio) / 2); |
1218 | 1217 | ||
1219 | bio_io_error(bio); | 1218 | bio_io_error(bio); |
1220 | return; | 1219 | return; |
@@ -1229,7 +1228,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1229 | */ | 1228 | */ |
1230 | wait_barrier(conf); | 1229 | wait_barrier(conf); |
1231 | 1230 | ||
1232 | sectors = bio->bi_size >> 9; | 1231 | sectors = bio_sectors(bio); |
1233 | while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && | 1232 | while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && |
1234 | bio->bi_sector < conf->reshape_progress && | 1233 | bio->bi_sector < conf->reshape_progress && |
1235 | bio->bi_sector + sectors > conf->reshape_progress) { | 1234 | bio->bi_sector + sectors > conf->reshape_progress) { |
@@ -1331,8 +1330,7 @@ read_again: | |||
1331 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); | 1330 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); |
1332 | 1331 | ||
1333 | r10_bio->master_bio = bio; | 1332 | r10_bio->master_bio = bio; |
1334 | r10_bio->sectors = ((bio->bi_size >> 9) | 1333 | r10_bio->sectors = bio_sectors(bio) - sectors_handled; |
1335 | - sectors_handled); | ||
1336 | r10_bio->state = 0; | 1334 | r10_bio->state = 0; |
1337 | r10_bio->mddev = mddev; | 1335 | r10_bio->mddev = mddev; |
1338 | r10_bio->sector = bio->bi_sector + sectors_handled; | 1336 | r10_bio->sector = bio->bi_sector + sectors_handled; |
@@ -1574,7 +1572,7 @@ retry_write: | |||
1574 | * after checking if we need to go around again. | 1572 | * after checking if we need to go around again. |
1575 | */ | 1573 | */ |
1576 | 1574 | ||
1577 | if (sectors_handled < (bio->bi_size >> 9)) { | 1575 | if (sectors_handled < bio_sectors(bio)) { |
1578 | one_write_done(r10_bio); | 1576 | one_write_done(r10_bio); |
1579 | /* We need another r10_bio. It has already been counted | 1577 | /* We need another r10_bio. It has already been counted |
1580 | * in bio->bi_phys_segments. | 1578 | * in bio->bi_phys_segments. |
@@ -1582,7 +1580,7 @@ retry_write: | |||
1582 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); | 1580 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); |
1583 | 1581 | ||
1584 | r10_bio->master_bio = bio; | 1582 | r10_bio->master_bio = bio; |
1585 | r10_bio->sectors = (bio->bi_size >> 9) - sectors_handled; | 1583 | r10_bio->sectors = bio_sectors(bio) - sectors_handled; |
1586 | 1584 | ||
1587 | r10_bio->mddev = mddev; | 1585 | r10_bio->mddev = mddev; |
1588 | r10_bio->sector = bio->bi_sector + sectors_handled; | 1586 | r10_bio->sector = bio->bi_sector + sectors_handled; |
@@ -2084,13 +2082,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2084 | * First we need to fixup bv_offset, bv_len and | 2082 | * First we need to fixup bv_offset, bv_len and |
2085 | * bi_vecs, as the read request might have corrupted these | 2083 | * bi_vecs, as the read request might have corrupted these |
2086 | */ | 2084 | */ |
2085 | bio_reset(tbio); | ||
2086 | |||
2087 | tbio->bi_vcnt = vcnt; | 2087 | tbio->bi_vcnt = vcnt; |
2088 | tbio->bi_size = r10_bio->sectors << 9; | 2088 | tbio->bi_size = r10_bio->sectors << 9; |
2089 | tbio->bi_idx = 0; | ||
2090 | tbio->bi_phys_segments = 0; | ||
2091 | tbio->bi_flags &= ~(BIO_POOL_MASK - 1); | ||
2092 | tbio->bi_flags |= 1 << BIO_UPTODATE; | ||
2093 | tbio->bi_next = NULL; | ||
2094 | tbio->bi_rw = WRITE; | 2089 | tbio->bi_rw = WRITE; |
2095 | tbio->bi_private = r10_bio; | 2090 | tbio->bi_private = r10_bio; |
2096 | tbio->bi_sector = r10_bio->devs[i].addr; | 2091 | tbio->bi_sector = r10_bio->devs[i].addr; |
@@ -2108,7 +2103,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2108 | d = r10_bio->devs[i].devnum; | 2103 | d = r10_bio->devs[i].devnum; |
2109 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); | 2104 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); |
2110 | atomic_inc(&r10_bio->remaining); | 2105 | atomic_inc(&r10_bio->remaining); |
2111 | md_sync_acct(conf->mirrors[d].rdev->bdev, tbio->bi_size >> 9); | 2106 | md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(tbio)); |
2112 | 2107 | ||
2113 | tbio->bi_sector += conf->mirrors[d].rdev->data_offset; | 2108 | tbio->bi_sector += conf->mirrors[d].rdev->data_offset; |
2114 | tbio->bi_bdev = conf->mirrors[d].rdev->bdev; | 2109 | tbio->bi_bdev = conf->mirrors[d].rdev->bdev; |
@@ -2133,7 +2128,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2133 | d = r10_bio->devs[i].devnum; | 2128 | d = r10_bio->devs[i].devnum; |
2134 | atomic_inc(&r10_bio->remaining); | 2129 | atomic_inc(&r10_bio->remaining); |
2135 | md_sync_acct(conf->mirrors[d].replacement->bdev, | 2130 | md_sync_acct(conf->mirrors[d].replacement->bdev, |
2136 | tbio->bi_size >> 9); | 2131 | bio_sectors(tbio)); |
2137 | generic_make_request(tbio); | 2132 | generic_make_request(tbio); |
2138 | } | 2133 | } |
2139 | 2134 | ||
@@ -2259,13 +2254,13 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2259 | wbio2 = r10_bio->devs[1].repl_bio; | 2254 | wbio2 = r10_bio->devs[1].repl_bio; |
2260 | if (wbio->bi_end_io) { | 2255 | if (wbio->bi_end_io) { |
2261 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); | 2256 | atomic_inc(&conf->mirrors[d].rdev->nr_pending); |
2262 | md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9); | 2257 | md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); |
2263 | generic_make_request(wbio); | 2258 | generic_make_request(wbio); |
2264 | } | 2259 | } |
2265 | if (wbio2 && wbio2->bi_end_io) { | 2260 | if (wbio2 && wbio2->bi_end_io) { |
2266 | atomic_inc(&conf->mirrors[d].replacement->nr_pending); | 2261 | atomic_inc(&conf->mirrors[d].replacement->nr_pending); |
2267 | md_sync_acct(conf->mirrors[d].replacement->bdev, | 2262 | md_sync_acct(conf->mirrors[d].replacement->bdev, |
2268 | wbio2->bi_size >> 9); | 2263 | bio_sectors(wbio2)); |
2269 | generic_make_request(wbio2); | 2264 | generic_make_request(wbio2); |
2270 | } | 2265 | } |
2271 | } | 2266 | } |
@@ -2536,25 +2531,6 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 | |||
2536 | } | 2531 | } |
2537 | } | 2532 | } |
2538 | 2533 | ||
2539 | static void bi_complete(struct bio *bio, int error) | ||
2540 | { | ||
2541 | complete((struct completion *)bio->bi_private); | ||
2542 | } | ||
2543 | |||
2544 | static int submit_bio_wait(int rw, struct bio *bio) | ||
2545 | { | ||
2546 | struct completion event; | ||
2547 | rw |= REQ_SYNC; | ||
2548 | |||
2549 | init_completion(&event); | ||
2550 | bio->bi_private = &event; | ||
2551 | bio->bi_end_io = bi_complete; | ||
2552 | submit_bio(rw, bio); | ||
2553 | wait_for_completion(&event); | ||
2554 | |||
2555 | return test_bit(BIO_UPTODATE, &bio->bi_flags); | ||
2556 | } | ||
2557 | |||
2558 | static int narrow_write_error(struct r10bio *r10_bio, int i) | 2534 | static int narrow_write_error(struct r10bio *r10_bio, int i) |
2559 | { | 2535 | { |
2560 | struct bio *bio = r10_bio->master_bio; | 2536 | struct bio *bio = r10_bio->master_bio; |
@@ -2695,8 +2671,7 @@ read_more: | |||
2695 | r10_bio = mempool_alloc(conf->r10bio_pool, | 2671 | r10_bio = mempool_alloc(conf->r10bio_pool, |
2696 | GFP_NOIO); | 2672 | GFP_NOIO); |
2697 | r10_bio->master_bio = mbio; | 2673 | r10_bio->master_bio = mbio; |
2698 | r10_bio->sectors = (mbio->bi_size >> 9) | 2674 | r10_bio->sectors = bio_sectors(mbio) - sectors_handled; |
2699 | - sectors_handled; | ||
2700 | r10_bio->state = 0; | 2675 | r10_bio->state = 0; |
2701 | set_bit(R10BIO_ReadError, | 2676 | set_bit(R10BIO_ReadError, |
2702 | &r10_bio->state); | 2677 | &r10_bio->state); |
@@ -3133,6 +3108,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3133 | } | 3108 | } |
3134 | } | 3109 | } |
3135 | bio = r10_bio->devs[0].bio; | 3110 | bio = r10_bio->devs[0].bio; |
3111 | bio_reset(bio); | ||
3136 | bio->bi_next = biolist; | 3112 | bio->bi_next = biolist; |
3137 | biolist = bio; | 3113 | biolist = bio; |
3138 | bio->bi_private = r10_bio; | 3114 | bio->bi_private = r10_bio; |
@@ -3157,6 +3133,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3157 | rdev = mirror->rdev; | 3133 | rdev = mirror->rdev; |
3158 | if (!test_bit(In_sync, &rdev->flags)) { | 3134 | if (!test_bit(In_sync, &rdev->flags)) { |
3159 | bio = r10_bio->devs[1].bio; | 3135 | bio = r10_bio->devs[1].bio; |
3136 | bio_reset(bio); | ||
3160 | bio->bi_next = biolist; | 3137 | bio->bi_next = biolist; |
3161 | biolist = bio; | 3138 | biolist = bio; |
3162 | bio->bi_private = r10_bio; | 3139 | bio->bi_private = r10_bio; |
@@ -3185,6 +3162,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3185 | if (rdev == NULL || bio == NULL || | 3162 | if (rdev == NULL || bio == NULL || |
3186 | test_bit(Faulty, &rdev->flags)) | 3163 | test_bit(Faulty, &rdev->flags)) |
3187 | break; | 3164 | break; |
3165 | bio_reset(bio); | ||
3188 | bio->bi_next = biolist; | 3166 | bio->bi_next = biolist; |
3189 | biolist = bio; | 3167 | biolist = bio; |
3190 | bio->bi_private = r10_bio; | 3168 | bio->bi_private = r10_bio; |
@@ -3283,7 +3261,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3283 | r10_bio->devs[i].repl_bio->bi_end_io = NULL; | 3261 | r10_bio->devs[i].repl_bio->bi_end_io = NULL; |
3284 | 3262 | ||
3285 | bio = r10_bio->devs[i].bio; | 3263 | bio = r10_bio->devs[i].bio; |
3286 | bio->bi_end_io = NULL; | 3264 | bio_reset(bio); |
3287 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | 3265 | clear_bit(BIO_UPTODATE, &bio->bi_flags); |
3288 | if (conf->mirrors[d].rdev == NULL || | 3266 | if (conf->mirrors[d].rdev == NULL || |
3289 | test_bit(Faulty, &conf->mirrors[d].rdev->flags)) | 3267 | test_bit(Faulty, &conf->mirrors[d].rdev->flags)) |
@@ -3320,6 +3298,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3320 | 3298 | ||
3321 | /* Need to set up for writing to the replacement */ | 3299 | /* Need to set up for writing to the replacement */ |
3322 | bio = r10_bio->devs[i].repl_bio; | 3300 | bio = r10_bio->devs[i].repl_bio; |
3301 | bio_reset(bio); | ||
3323 | clear_bit(BIO_UPTODATE, &bio->bi_flags); | 3302 | clear_bit(BIO_UPTODATE, &bio->bi_flags); |
3324 | 3303 | ||
3325 | sector = r10_bio->devs[i].addr; | 3304 | sector = r10_bio->devs[i].addr; |
@@ -3353,17 +3332,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
3353 | } | 3332 | } |
3354 | } | 3333 | } |
3355 | 3334 | ||
3356 | for (bio = biolist; bio ; bio=bio->bi_next) { | ||
3357 | |||
3358 | bio->bi_flags &= ~(BIO_POOL_MASK - 1); | ||
3359 | if (bio->bi_end_io) | ||
3360 | bio->bi_flags |= 1 << BIO_UPTODATE; | ||
3361 | bio->bi_vcnt = 0; | ||
3362 | bio->bi_idx = 0; | ||
3363 | bio->bi_phys_segments = 0; | ||
3364 | bio->bi_size = 0; | ||
3365 | } | ||
3366 | |||
3367 | nr_sectors = 0; | 3335 | nr_sectors = 0; |
3368 | if (sector_nr + max_sync < max_sector) | 3336 | if (sector_nr + max_sync < max_sector) |
3369 | max_sector = sector_nr + max_sync; | 3337 | max_sector = sector_nr + max_sync; |
@@ -4411,7 +4379,6 @@ read_more: | |||
4411 | read_bio->bi_flags &= ~(BIO_POOL_MASK - 1); | 4379 | read_bio->bi_flags &= ~(BIO_POOL_MASK - 1); |
4412 | read_bio->bi_flags |= 1 << BIO_UPTODATE; | 4380 | read_bio->bi_flags |= 1 << BIO_UPTODATE; |
4413 | read_bio->bi_vcnt = 0; | 4381 | read_bio->bi_vcnt = 0; |
4414 | read_bio->bi_idx = 0; | ||
4415 | read_bio->bi_size = 0; | 4382 | read_bio->bi_size = 0; |
4416 | r10_bio->master_bio = read_bio; | 4383 | r10_bio->master_bio = read_bio; |
4417 | r10_bio->read_slot = r10_bio->devs[r10_bio->read_slot].devnum; | 4384 | r10_bio->read_slot = r10_bio->devs[r10_bio->read_slot].devnum; |
@@ -4435,17 +4402,14 @@ read_more: | |||
4435 | } | 4402 | } |
4436 | if (!rdev2 || test_bit(Faulty, &rdev2->flags)) | 4403 | if (!rdev2 || test_bit(Faulty, &rdev2->flags)) |
4437 | continue; | 4404 | continue; |
4405 | |||
4406 | bio_reset(b); | ||
4438 | b->bi_bdev = rdev2->bdev; | 4407 | b->bi_bdev = rdev2->bdev; |
4439 | b->bi_sector = r10_bio->devs[s/2].addr + rdev2->new_data_offset; | 4408 | b->bi_sector = r10_bio->devs[s/2].addr + rdev2->new_data_offset; |
4440 | b->bi_private = r10_bio; | 4409 | b->bi_private = r10_bio; |
4441 | b->bi_end_io = end_reshape_write; | 4410 | b->bi_end_io = end_reshape_write; |
4442 | b->bi_rw = WRITE; | 4411 | b->bi_rw = WRITE; |
4443 | b->bi_flags &= ~(BIO_POOL_MASK - 1); | ||
4444 | b->bi_flags |= 1 << BIO_UPTODATE; | ||
4445 | b->bi_next = blist; | 4412 | b->bi_next = blist; |
4446 | b->bi_vcnt = 0; | ||
4447 | b->bi_idx = 0; | ||
4448 | b->bi_size = 0; | ||
4449 | blist = b; | 4413 | blist = b; |
4450 | } | 4414 | } |
4451 | 4415 | ||
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 4a7be455d6d8..9359828ffe26 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -90,7 +90,7 @@ static inline struct hlist_head *stripe_hash(struct r5conf *conf, sector_t sect) | |||
90 | */ | 90 | */ |
91 | static inline struct bio *r5_next_bio(struct bio *bio, sector_t sector) | 91 | static inline struct bio *r5_next_bio(struct bio *bio, sector_t sector) |
92 | { | 92 | { |
93 | int sectors = bio->bi_size >> 9; | 93 | int sectors = bio_sectors(bio); |
94 | if (bio->bi_sector + sectors < sector + STRIPE_SECTORS) | 94 | if (bio->bi_sector + sectors < sector + STRIPE_SECTORS) |
95 | return bio->bi_next; | 95 | return bio->bi_next; |
96 | else | 96 | else |
@@ -569,14 +569,6 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
569 | bi = &sh->dev[i].req; | 569 | bi = &sh->dev[i].req; |
570 | rbi = &sh->dev[i].rreq; /* For writing to replacement */ | 570 | rbi = &sh->dev[i].rreq; /* For writing to replacement */ |
571 | 571 | ||
572 | bi->bi_rw = rw; | ||
573 | rbi->bi_rw = rw; | ||
574 | if (rw & WRITE) { | ||
575 | bi->bi_end_io = raid5_end_write_request; | ||
576 | rbi->bi_end_io = raid5_end_write_request; | ||
577 | } else | ||
578 | bi->bi_end_io = raid5_end_read_request; | ||
579 | |||
580 | rcu_read_lock(); | 572 | rcu_read_lock(); |
581 | rrdev = rcu_dereference(conf->disks[i].replacement); | 573 | rrdev = rcu_dereference(conf->disks[i].replacement); |
582 | smp_mb(); /* Ensure that if rrdev is NULL, rdev won't be */ | 574 | smp_mb(); /* Ensure that if rrdev is NULL, rdev won't be */ |
@@ -651,7 +643,14 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
651 | 643 | ||
652 | set_bit(STRIPE_IO_STARTED, &sh->state); | 644 | set_bit(STRIPE_IO_STARTED, &sh->state); |
653 | 645 | ||
646 | bio_reset(bi); | ||
654 | bi->bi_bdev = rdev->bdev; | 647 | bi->bi_bdev = rdev->bdev; |
648 | bi->bi_rw = rw; | ||
649 | bi->bi_end_io = (rw & WRITE) | ||
650 | ? raid5_end_write_request | ||
651 | : raid5_end_read_request; | ||
652 | bi->bi_private = sh; | ||
653 | |||
655 | pr_debug("%s: for %llu schedule op %ld on disc %d\n", | 654 | pr_debug("%s: for %llu schedule op %ld on disc %d\n", |
656 | __func__, (unsigned long long)sh->sector, | 655 | __func__, (unsigned long long)sh->sector, |
657 | bi->bi_rw, i); | 656 | bi->bi_rw, i); |
@@ -665,12 +664,9 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
665 | if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) | 664 | if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) |
666 | bi->bi_rw |= REQ_FLUSH; | 665 | bi->bi_rw |= REQ_FLUSH; |
667 | 666 | ||
668 | bi->bi_flags = 1 << BIO_UPTODATE; | ||
669 | bi->bi_idx = 0; | ||
670 | bi->bi_io_vec[0].bv_len = STRIPE_SIZE; | 667 | bi->bi_io_vec[0].bv_len = STRIPE_SIZE; |
671 | bi->bi_io_vec[0].bv_offset = 0; | 668 | bi->bi_io_vec[0].bv_offset = 0; |
672 | bi->bi_size = STRIPE_SIZE; | 669 | bi->bi_size = STRIPE_SIZE; |
673 | bi->bi_next = NULL; | ||
674 | if (rrdev) | 670 | if (rrdev) |
675 | set_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags); | 671 | set_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags); |
676 | 672 | ||
@@ -687,7 +683,13 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
687 | 683 | ||
688 | set_bit(STRIPE_IO_STARTED, &sh->state); | 684 | set_bit(STRIPE_IO_STARTED, &sh->state); |
689 | 685 | ||
686 | bio_reset(rbi); | ||
690 | rbi->bi_bdev = rrdev->bdev; | 687 | rbi->bi_bdev = rrdev->bdev; |
688 | rbi->bi_rw = rw; | ||
689 | BUG_ON(!(rw & WRITE)); | ||
690 | rbi->bi_end_io = raid5_end_write_request; | ||
691 | rbi->bi_private = sh; | ||
692 | |||
691 | pr_debug("%s: for %llu schedule op %ld on " | 693 | pr_debug("%s: for %llu schedule op %ld on " |
692 | "replacement disc %d\n", | 694 | "replacement disc %d\n", |
693 | __func__, (unsigned long long)sh->sector, | 695 | __func__, (unsigned long long)sh->sector, |
@@ -699,12 +701,9 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
699 | else | 701 | else |
700 | rbi->bi_sector = (sh->sector | 702 | rbi->bi_sector = (sh->sector |
701 | + rrdev->data_offset); | 703 | + rrdev->data_offset); |
702 | rbi->bi_flags = 1 << BIO_UPTODATE; | ||
703 | rbi->bi_idx = 0; | ||
704 | rbi->bi_io_vec[0].bv_len = STRIPE_SIZE; | 704 | rbi->bi_io_vec[0].bv_len = STRIPE_SIZE; |
705 | rbi->bi_io_vec[0].bv_offset = 0; | 705 | rbi->bi_io_vec[0].bv_offset = 0; |
706 | rbi->bi_size = STRIPE_SIZE; | 706 | rbi->bi_size = STRIPE_SIZE; |
707 | rbi->bi_next = NULL; | ||
708 | if (conf->mddev->gendisk) | 707 | if (conf->mddev->gendisk) |
709 | trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev), | 708 | trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev), |
710 | rbi, disk_devt(conf->mddev->gendisk), | 709 | rbi, disk_devt(conf->mddev->gendisk), |
@@ -2402,11 +2401,11 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in | |||
2402 | } else | 2401 | } else |
2403 | bip = &sh->dev[dd_idx].toread; | 2402 | bip = &sh->dev[dd_idx].toread; |
2404 | while (*bip && (*bip)->bi_sector < bi->bi_sector) { | 2403 | while (*bip && (*bip)->bi_sector < bi->bi_sector) { |
2405 | if ((*bip)->bi_sector + ((*bip)->bi_size >> 9) > bi->bi_sector) | 2404 | if (bio_end_sector(*bip) > bi->bi_sector) |
2406 | goto overlap; | 2405 | goto overlap; |
2407 | bip = & (*bip)->bi_next; | 2406 | bip = & (*bip)->bi_next; |
2408 | } | 2407 | } |
2409 | if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9)) | 2408 | if (*bip && (*bip)->bi_sector < bio_end_sector(bi)) |
2410 | goto overlap; | 2409 | goto overlap; |
2411 | 2410 | ||
2412 | BUG_ON(*bip && bi->bi_next && (*bip) != bi->bi_next); | 2411 | BUG_ON(*bip && bi->bi_next && (*bip) != bi->bi_next); |
@@ -2422,8 +2421,8 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in | |||
2422 | sector < sh->dev[dd_idx].sector + STRIPE_SECTORS && | 2421 | sector < sh->dev[dd_idx].sector + STRIPE_SECTORS && |
2423 | bi && bi->bi_sector <= sector; | 2422 | bi && bi->bi_sector <= sector; |
2424 | bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) { | 2423 | bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) { |
2425 | if (bi->bi_sector + (bi->bi_size>>9) >= sector) | 2424 | if (bio_end_sector(bi) >= sector) |
2426 | sector = bi->bi_sector + (bi->bi_size>>9); | 2425 | sector = bio_end_sector(bi); |
2427 | } | 2426 | } |
2428 | if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS) | 2427 | if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS) |
2429 | set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags); | 2428 | set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags); |
@@ -3849,7 +3848,7 @@ static int in_chunk_boundary(struct mddev *mddev, struct bio *bio) | |||
3849 | { | 3848 | { |
3850 | sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev); | 3849 | sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev); |
3851 | unsigned int chunk_sectors = mddev->chunk_sectors; | 3850 | unsigned int chunk_sectors = mddev->chunk_sectors; |
3852 | unsigned int bio_sectors = bio->bi_size >> 9; | 3851 | unsigned int bio_sectors = bio_sectors(bio); |
3853 | 3852 | ||
3854 | if (mddev->new_chunk_sectors < mddev->chunk_sectors) | 3853 | if (mddev->new_chunk_sectors < mddev->chunk_sectors) |
3855 | chunk_sectors = mddev->new_chunk_sectors; | 3854 | chunk_sectors = mddev->new_chunk_sectors; |
@@ -3941,7 +3940,7 @@ static int bio_fits_rdev(struct bio *bi) | |||
3941 | { | 3940 | { |
3942 | struct request_queue *q = bdev_get_queue(bi->bi_bdev); | 3941 | struct request_queue *q = bdev_get_queue(bi->bi_bdev); |
3943 | 3942 | ||
3944 | if ((bi->bi_size>>9) > queue_max_sectors(q)) | 3943 | if (bio_sectors(bi) > queue_max_sectors(q)) |
3945 | return 0; | 3944 | return 0; |
3946 | blk_recount_segments(q, bi); | 3945 | blk_recount_segments(q, bi); |
3947 | if (bi->bi_phys_segments > queue_max_segments(q)) | 3946 | if (bi->bi_phys_segments > queue_max_segments(q)) |
@@ -3988,7 +3987,7 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio) | |||
3988 | 0, | 3987 | 0, |
3989 | &dd_idx, NULL); | 3988 | &dd_idx, NULL); |
3990 | 3989 | ||
3991 | end_sector = align_bi->bi_sector + (align_bi->bi_size >> 9); | 3990 | end_sector = bio_end_sector(align_bi); |
3992 | rcu_read_lock(); | 3991 | rcu_read_lock(); |
3993 | rdev = rcu_dereference(conf->disks[dd_idx].replacement); | 3992 | rdev = rcu_dereference(conf->disks[dd_idx].replacement); |
3994 | if (!rdev || test_bit(Faulty, &rdev->flags) || | 3993 | if (!rdev || test_bit(Faulty, &rdev->flags) || |
@@ -4011,7 +4010,7 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio) | |||
4011 | align_bi->bi_flags &= ~(1 << BIO_SEG_VALID); | 4010 | align_bi->bi_flags &= ~(1 << BIO_SEG_VALID); |
4012 | 4011 | ||
4013 | if (!bio_fits_rdev(align_bi) || | 4012 | if (!bio_fits_rdev(align_bi) || |
4014 | is_badblock(rdev, align_bi->bi_sector, align_bi->bi_size>>9, | 4013 | is_badblock(rdev, align_bi->bi_sector, bio_sectors(align_bi), |
4015 | &first_bad, &bad_sectors)) { | 4014 | &first_bad, &bad_sectors)) { |
4016 | /* too big in some way, or has a known bad block */ | 4015 | /* too big in some way, or has a known bad block */ |
4017 | bio_put(align_bi); | 4016 | bio_put(align_bi); |
@@ -4273,7 +4272,7 @@ static void make_request(struct mddev *mddev, struct bio * bi) | |||
4273 | } | 4272 | } |
4274 | 4273 | ||
4275 | logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1); | 4274 | logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1); |
4276 | last_sector = bi->bi_sector + (bi->bi_size>>9); | 4275 | last_sector = bio_end_sector(bi); |
4277 | bi->bi_next = NULL; | 4276 | bi->bi_next = NULL; |
4278 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ | 4277 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ |
4279 | 4278 | ||
@@ -4739,7 +4738,7 @@ static int retry_aligned_read(struct r5conf *conf, struct bio *raid_bio) | |||
4739 | logical_sector = raid_bio->bi_sector & ~((sector_t)STRIPE_SECTORS-1); | 4738 | logical_sector = raid_bio->bi_sector & ~((sector_t)STRIPE_SECTORS-1); |
4740 | sector = raid5_compute_sector(conf, logical_sector, | 4739 | sector = raid5_compute_sector(conf, logical_sector, |
4741 | 0, &dd_idx, NULL); | 4740 | 0, &dd_idx, NULL); |
4742 | last_sector = raid_bio->bi_sector + (raid_bio->bi_size>>9); | 4741 | last_sector = bio_end_sector(raid_bio); |
4743 | 4742 | ||
4744 | for (; logical_sector < last_sector; | 4743 | for (; logical_sector < last_sector; |
4745 | logical_sector += STRIPE_SECTORS, | 4744 | logical_sector += STRIPE_SECTORS, |
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index ffee6f781e30..dd239bdbfcb4 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -2235,10 +2235,10 @@ static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | /* do we need to support multiple segments? */ | 2237 | /* do we need to support multiple segments? */ |
2238 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { | 2238 | if (bio_segments(req->bio) > 1 || bio_segments(rsp->bio) > 1) { |
2239 | printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n", | 2239 | printk(MYIOC_s_ERR_FMT "%s: multiple segments req %u %u, rsp %u %u\n", |
2240 | ioc->name, __func__, req->bio->bi_vcnt, blk_rq_bytes(req), | 2240 | ioc->name, __func__, bio_segments(req->bio), blk_rq_bytes(req), |
2241 | rsp->bio->bi_vcnt, blk_rq_bytes(rsp)); | 2241 | bio_segments(rsp->bio), blk_rq_bytes(rsp)); |
2242 | return -EINVAL; | 2242 | return -EINVAL; |
2243 | } | 2243 | } |
2244 | 2244 | ||
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 07ba32b07fb0..6eca019bcf30 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c | |||
@@ -822,8 +822,7 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio) | |||
822 | if ((bio->bi_sector & 7) != 0 || (bio->bi_size & 4095) != 0) | 822 | if ((bio->bi_sector & 7) != 0 || (bio->bi_size & 4095) != 0) |
823 | /* Request is not page-aligned. */ | 823 | /* Request is not page-aligned. */ |
824 | goto fail; | 824 | goto fail; |
825 | if (((bio->bi_size >> 9) + bio->bi_sector) | 825 | if (bio_end_sector(bio) > get_capacity(bio->bi_bdev->bd_disk)) { |
826 | > get_capacity(bio->bi_bdev->bd_disk)) { | ||
827 | /* Request beyond end of DCSS segment. */ | 826 | /* Request beyond end of DCSS segment. */ |
828 | goto fail; | 827 | goto fail; |
829 | } | 828 | } |
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 55cbd0180159..f42b0e15410f 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -2163,10 +2163,10 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2163 | } | 2163 | } |
2164 | 2164 | ||
2165 | /* do we need to support multiple segments? */ | 2165 | /* do we need to support multiple segments? */ |
2166 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { | 2166 | if (bio_segments(req->bio) > 1 || bio_segments(rsp->bio) > 1) { |
2167 | printk("%s: multiple segments req %u %u, rsp %u %u\n", | 2167 | printk("%s: multiple segments req %u %u, rsp %u %u\n", |
2168 | __func__, req->bio->bi_vcnt, blk_rq_bytes(req), | 2168 | __func__, bio_segments(req->bio), blk_rq_bytes(req), |
2169 | rsp->bio->bi_vcnt, blk_rq_bytes(rsp)); | 2169 | bio_segments(rsp->bio), blk_rq_bytes(rsp)); |
2170 | return -EINVAL; | 2170 | return -EINVAL; |
2171 | } | 2171 | } |
2172 | 2172 | ||
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c index 8c2ffbe6af0f..193e7ae90c3b 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_transport.c +++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c | |||
@@ -1939,7 +1939,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1939 | ioc->transport_cmds.status = MPT2_CMD_PENDING; | 1939 | ioc->transport_cmds.status = MPT2_CMD_PENDING; |
1940 | 1940 | ||
1941 | /* Check if the request is split across multiple segments */ | 1941 | /* Check if the request is split across multiple segments */ |
1942 | if (req->bio->bi_vcnt > 1) { | 1942 | if (bio_segments(req->bio) > 1) { |
1943 | u32 offset = 0; | 1943 | u32 offset = 0; |
1944 | 1944 | ||
1945 | /* Allocate memory and copy the request */ | 1945 | /* Allocate memory and copy the request */ |
@@ -1971,7 +1971,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1971 | 1971 | ||
1972 | /* Check if the response needs to be populated across | 1972 | /* Check if the response needs to be populated across |
1973 | * multiple segments */ | 1973 | * multiple segments */ |
1974 | if (rsp->bio->bi_vcnt > 1) { | 1974 | if (bio_segments(rsp->bio) > 1) { |
1975 | pci_addr_in = pci_alloc_consistent(ioc->pdev, blk_rq_bytes(rsp), | 1975 | pci_addr_in = pci_alloc_consistent(ioc->pdev, blk_rq_bytes(rsp), |
1976 | &pci_dma_in); | 1976 | &pci_dma_in); |
1977 | if (!pci_addr_in) { | 1977 | if (!pci_addr_in) { |
@@ -2038,7 +2038,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2038 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | | 2038 | sgl_flags = (MPI2_SGE_FLAGS_SIMPLE_ELEMENT | |
2039 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); | 2039 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
2040 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; | 2040 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
2041 | if (req->bio->bi_vcnt > 1) { | 2041 | if (bio_segments(req->bio) > 1) { |
2042 | ioc->base_add_sg_single(psge, sgl_flags | | 2042 | ioc->base_add_sg_single(psge, sgl_flags | |
2043 | (blk_rq_bytes(req) - 4), pci_dma_out); | 2043 | (blk_rq_bytes(req) - 4), pci_dma_out); |
2044 | } else { | 2044 | } else { |
@@ -2054,7 +2054,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2054 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | | 2054 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
2055 | MPI2_SGE_FLAGS_END_OF_LIST); | 2055 | MPI2_SGE_FLAGS_END_OF_LIST); |
2056 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; | 2056 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
2057 | if (rsp->bio->bi_vcnt > 1) { | 2057 | if (bio_segments(rsp->bio) > 1) { |
2058 | ioc->base_add_sg_single(psge, sgl_flags | | 2058 | ioc->base_add_sg_single(psge, sgl_flags | |
2059 | (blk_rq_bytes(rsp) + 4), pci_dma_in); | 2059 | (blk_rq_bytes(rsp) + 4), pci_dma_in); |
2060 | } else { | 2060 | } else { |
@@ -2099,7 +2099,7 @@ _transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
2099 | le16_to_cpu(mpi_reply->ResponseDataLength); | 2099 | le16_to_cpu(mpi_reply->ResponseDataLength); |
2100 | /* check if the resp needs to be copied from the allocated | 2100 | /* check if the resp needs to be copied from the allocated |
2101 | * pci mem */ | 2101 | * pci mem */ |
2102 | if (rsp->bio->bi_vcnt > 1) { | 2102 | if (bio_segments(rsp->bio) > 1) { |
2103 | u32 offset = 0; | 2103 | u32 offset = 0; |
2104 | u32 bytes_to_copy = | 2104 | u32 bytes_to_copy = |
2105 | le16_to_cpu(mpi_reply->ResponseDataLength); | 2105 | le16_to_cpu(mpi_reply->ResponseDataLength); |