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

dm flakey: add support for zoned block devices

With the development of file system support for zoned block devices
(e.g. f2fs), having dm-flakey support these devices is interesting
to improve testing.

Add host-aware and host-managed zoned block devices support to in
dm-flakey. The target type feature is set to DM_TARGET_ZONED_HM to
indicate support for host-managed models. Also add hooks for remapping
of REQ_OP_ZONE_RESET and REQ_OP_ZONE_REPORT bios. Additionally, in the
bio completion path, (backward) remapping of a zone report reply is
added.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Damien Le Moal and committed by
Mike Snitzer
124c4454 10999307

+20 -3
+20 -3
drivers/md/dm-flakey.c
··· 275 275 struct flakey_c *fc = ti->private; 276 276 277 277 bio->bi_bdev = fc->dev->bdev; 278 - if (bio_sectors(bio)) 278 + if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET) 279 279 bio->bi_iter.bi_sector = 280 280 flakey_map_sector(ti, bio->bi_iter.bi_sector); 281 281 } ··· 305 305 unsigned elapsed; 306 306 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 307 307 pb->bio_submitted = false; 308 + 309 + /* Do not fail reset zone */ 310 + if (bio_op(bio) == REQ_OP_ZONE_RESET) 311 + goto map_bio; 312 + 313 + /* We need to remap reported zones, so remember the BIO iter */ 314 + if (bio_op(bio) == REQ_OP_ZONE_REPORT) 315 + goto map_bio; 308 316 309 317 /* Are we alive ? */ 310 318 elapsed = (jiffies - fc->start_time) / HZ; ··· 367 359 } 368 360 369 361 static int flakey_end_io(struct dm_target *ti, struct bio *bio, 370 - blk_status_t *error) 362 + blk_status_t *error) 371 363 { 372 364 struct flakey_c *fc = ti->private; 373 365 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 366 + 367 + if (bio_op(bio) == REQ_OP_ZONE_RESET) 368 + return DM_ENDIO_DONE; 369 + 370 + if (bio_op(bio) == REQ_OP_ZONE_REPORT) { 371 + dm_remap_zone_report(ti, bio, fc->start); 372 + return DM_ENDIO_DONE; 373 + } 374 374 375 375 if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { 376 376 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && ··· 462 446 463 447 static struct target_type flakey_target = { 464 448 .name = "flakey", 465 - .version = {1, 4, 0}, 449 + .version = {1, 5, 0}, 450 + .features = DM_TARGET_ZONED_HM, 466 451 .module = THIS_MODULE, 467 452 .ctr = flakey_ctr, 468 453 .dtr = flakey_dtr,