Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

md/raid10: convert read/write to use bio_submit_split_bioset()

Unify bio split code, prepare to fix ordering of split IO, the error path
is modified a bit, however no functional changes are intended:

- bio_submit_split_bioset() can fail the original bio directly
by split error, set R10BIO_Uptodate in this case to notify
raid_end_bio_io() that the original bio is returned already.
- set R10BIO_Uptodate and set error value to -EIO is useless now,
for r10_bio without R10BIO_Uptodate, -EIO will be returned for
original bio.

And discard is not handled, because discard is only split for
unaligned head and tail, and this can be considered slow path, the
reorder here does not matter much.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yu Kuai and committed by
Jens Axboe
6fc07785 deeeab30

+13 -29
+13 -29
drivers/md/raid10.c
··· 1156 1156 int slot = r10_bio->read_slot; 1157 1157 struct md_rdev *err_rdev = NULL; 1158 1158 gfp_t gfp = GFP_NOIO; 1159 - int error; 1160 1159 1161 1160 if (slot >= 0 && r10_bio->devs[slot].rdev) { 1162 1161 /* ··· 1204 1205 rdev->bdev, 1205 1206 (unsigned long long)r10_bio->sector); 1206 1207 if (max_sectors < bio_sectors(bio)) { 1207 - struct bio *split = bio_split(bio, max_sectors, 1208 - gfp, &conf->bio_split); 1209 - if (IS_ERR(split)) { 1210 - error = PTR_ERR(split); 1208 + allow_barrier(conf); 1209 + bio = bio_submit_split_bioset(bio, max_sectors, 1210 + &conf->bio_split); 1211 + wait_barrier(conf, false); 1212 + if (!bio) { 1213 + set_bit(R10BIO_Returned, &r10_bio->state); 1211 1214 goto err_handle; 1212 1215 } 1213 1216 1214 - bio_chain(split, bio); 1215 - trace_block_split(split, bio->bi_iter.bi_sector); 1216 - allow_barrier(conf); 1217 - submit_bio_noacct(bio); 1218 - wait_barrier(conf, false); 1219 - bio = split; 1220 1217 r10_bio->master_bio = bio; 1221 1218 r10_bio->sectors = max_sectors; 1222 1219 } ··· 1240 1245 return; 1241 1246 err_handle: 1242 1247 atomic_dec(&rdev->nr_pending); 1243 - bio->bi_status = errno_to_blk_status(error); 1244 - set_bit(R10BIO_Uptodate, &r10_bio->state); 1245 1248 raid_end_bio_io(r10_bio); 1246 1249 } 1247 1250 ··· 1348 1355 int i, k; 1349 1356 sector_t sectors; 1350 1357 int max_sectors; 1351 - int error; 1352 1358 1353 1359 if ((mddev_is_clustered(mddev) && 1354 1360 mddev->cluster_ops->area_resyncing(mddev, WRITE, ··· 1461 1469 * complexity of supporting that is not worth 1462 1470 * the benefit. 1463 1471 */ 1464 - if (bio->bi_opf & REQ_ATOMIC) { 1465 - error = -EIO; 1472 + if (bio->bi_opf & REQ_ATOMIC) 1466 1473 goto err_handle; 1467 - } 1468 1474 1469 1475 good_sectors = first_bad - dev_sector; 1470 1476 if (good_sectors < max_sectors) ··· 1483 1493 r10_bio->sectors = max_sectors; 1484 1494 1485 1495 if (r10_bio->sectors < bio_sectors(bio)) { 1486 - struct bio *split = bio_split(bio, r10_bio->sectors, 1487 - GFP_NOIO, &conf->bio_split); 1488 - if (IS_ERR(split)) { 1489 - error = PTR_ERR(split); 1496 + allow_barrier(conf); 1497 + bio = bio_submit_split_bioset(bio, r10_bio->sectors, 1498 + &conf->bio_split); 1499 + wait_barrier(conf, false); 1500 + if (!bio) { 1501 + set_bit(R10BIO_Returned, &r10_bio->state); 1490 1502 goto err_handle; 1491 1503 } 1492 1504 1493 - bio_chain(split, bio); 1494 - trace_block_split(split, bio->bi_iter.bi_sector); 1495 - allow_barrier(conf); 1496 - submit_bio_noacct(bio); 1497 - wait_barrier(conf, false); 1498 - bio = split; 1499 1505 r10_bio->master_bio = bio; 1500 1506 } 1501 1507 ··· 1523 1537 } 1524 1538 } 1525 1539 1526 - bio->bi_status = errno_to_blk_status(error); 1527 - set_bit(R10BIO_Uptodate, &r10_bio->state); 1528 1540 raid_end_bio_io(r10_bio); 1529 1541 } 1530 1542