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: Atomic write support

Set BLK_FEAT_ATOMIC_WRITES_STACKED to enable atomic writes.

For an attempt to atomic write to a region which has bad blocks, error
the write as we just cannot do this. It is unlikely to find devices which
support atomic writes and bad blocks.

Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20241118105018.1870052-6-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

John Garry and committed by
Jens Axboe
a1d9b4fd f2a38abf

+18 -2
+18 -2
drivers/md/raid10.c
··· 1255 1255 const enum req_op op = bio_op(bio); 1256 1256 const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC; 1257 1257 const blk_opf_t do_fua = bio->bi_opf & REQ_FUA; 1258 + const blk_opf_t do_atomic = bio->bi_opf & REQ_ATOMIC; 1258 1259 unsigned long flags; 1259 1260 struct r10conf *conf = mddev->private; 1260 1261 struct md_rdev *rdev; ··· 1274 1273 mbio->bi_iter.bi_sector = (r10_bio->devs[n_copy].addr + 1275 1274 choose_data_offset(r10_bio, rdev)); 1276 1275 mbio->bi_end_io = raid10_end_write_request; 1277 - mbio->bi_opf = op | do_sync | do_fua; 1276 + mbio->bi_opf = op | do_sync | do_fua | do_atomic; 1278 1277 if (!replacement && test_bit(FailFast, 1279 1278 &conf->mirrors[devnum].rdev->flags) 1280 1279 && enough(conf, devnum)) ··· 1469 1468 continue; 1470 1469 } 1471 1470 if (is_bad) { 1472 - int good_sectors = first_bad - dev_sector; 1471 + int good_sectors; 1472 + 1473 + /* 1474 + * We cannot atomically write this, so just 1475 + * error in that case. It could be possible to 1476 + * atomically write other mirrors, but the 1477 + * complexity of supporting that is not worth 1478 + * the benefit. 1479 + */ 1480 + if (bio->bi_opf & REQ_ATOMIC) { 1481 + error = -EIO; 1482 + goto err_handle; 1483 + } 1484 + 1485 + good_sectors = first_bad - dev_sector; 1473 1486 if (good_sectors < max_sectors) 1474 1487 max_sectors = good_sectors; 1475 1488 } ··· 4040 4025 lim.max_write_zeroes_sectors = 0; 4041 4026 lim.io_min = mddev->chunk_sectors << 9; 4042 4027 lim.io_opt = lim.io_min * raid10_nr_stripes(conf); 4028 + lim.features |= BLK_FEAT_ATOMIC_WRITES_STACKED; 4043 4029 err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); 4044 4030 if (err) { 4045 4031 queue_limits_cancel_update(mddev->gendisk->queue);