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.

zloop: introduce the zone_append configuration parameter

A zloop zoned block device declares to the block layer that it supports
zone append operations. That is, a zloop device ressembles an NVMe ZNS
devices supporting zone append.

This native support is fine but it does not allow exercising the block
layer zone write plugging emulation of zone append, as is done with SCSI
or ATA SMR HDDs.

Introduce the zone_append configuration parameter to allow creating a
zloop device without native support for zone append, thus relying on the
block layer zone append emulation. If not specified, zone append support
is enabled by default. Otherwise, a value of 0 disables native zone
append and a value of 1 enables it.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Damien Le Moal and committed by
Jens Axboe
9236c5fd e3a96ca9

+30 -2
+30 -2
drivers/block/zloop.c
··· 32 32 ZLOOP_OPT_NR_QUEUES = (1 << 6), 33 33 ZLOOP_OPT_QUEUE_DEPTH = (1 << 7), 34 34 ZLOOP_OPT_BUFFERED_IO = (1 << 8), 35 + ZLOOP_OPT_ZONE_APPEND = (1 << 9), 35 36 }; 36 37 37 38 static const match_table_t zloop_opt_tokens = { ··· 45 44 { ZLOOP_OPT_NR_QUEUES, "nr_queues=%u" }, 46 45 { ZLOOP_OPT_QUEUE_DEPTH, "queue_depth=%u" }, 47 46 { ZLOOP_OPT_BUFFERED_IO, "buffered_io" }, 47 + { ZLOOP_OPT_ZONE_APPEND, "zone_append=%u" }, 48 48 { ZLOOP_OPT_ERR, NULL } 49 49 }; 50 50 ··· 58 56 #define ZLOOP_DEF_NR_QUEUES 1 59 57 #define ZLOOP_DEF_QUEUE_DEPTH 128 60 58 #define ZLOOP_DEF_BUFFERED_IO false 59 + #define ZLOOP_DEF_ZONE_APPEND true 61 60 62 61 /* Arbitrary limit on the zone size (16GB). */ 63 62 #define ZLOOP_MAX_ZONE_SIZE_MB 16384 ··· 74 71 unsigned int nr_queues; 75 72 unsigned int queue_depth; 76 73 bool buffered_io; 74 + bool zone_append; 77 75 }; 78 76 79 77 /* ··· 112 108 113 109 struct workqueue_struct *workqueue; 114 110 bool buffered_io; 111 + bool zone_append; 115 112 116 113 const char *base_dir; 117 114 struct file *data_dir; ··· 382 377 cmd->sector = sector; 383 378 cmd->nr_sectors = nr_sectors; 384 379 cmd->ret = 0; 380 + 381 + if (WARN_ON_ONCE(is_append && !zlo->zone_append)) { 382 + ret = -EIO; 383 + goto out; 384 + } 385 385 386 386 /* We should never get an I/O beyond the device capacity. */ 387 387 if (WARN_ON_ONCE(zone_no >= zlo->nr_zones)) { ··· 899 889 { 900 890 struct queue_limits lim = { 901 891 .max_hw_sectors = SZ_1M >> SECTOR_SHIFT, 902 - .max_hw_zone_append_sectors = SZ_1M >> SECTOR_SHIFT, 903 892 .chunk_sectors = opts->zone_size, 904 893 .features = BLK_FEAT_ZONED, 905 894 }; ··· 950 941 zlo->nr_zones = nr_zones; 951 942 zlo->nr_conv_zones = opts->nr_conv_zones; 952 943 zlo->buffered_io = opts->buffered_io; 944 + zlo->zone_append = opts->zone_append; 953 945 954 946 zlo->workqueue = alloc_workqueue("zloop%d", WQ_UNBOUND | WQ_FREEZABLE, 955 947 opts->nr_queues * opts->queue_depth, zlo->id); ··· 991 981 992 982 lim.physical_block_size = zlo->block_size; 993 983 lim.logical_block_size = zlo->block_size; 984 + if (zlo->zone_append) 985 + lim.max_hw_zone_append_sectors = lim.max_hw_sectors; 994 986 995 987 zlo->tag_set.ops = &zloop_mq_ops; 996 988 zlo->tag_set.nr_hw_queues = opts->nr_queues; ··· 1033 1021 zlo->state = Zlo_live; 1034 1022 mutex_unlock(&zloop_ctl_mutex); 1035 1023 1036 - pr_info("Added device %d: %u zones of %llu MB, %u B block size\n", 1024 + pr_info("zloop: device %d, %u zones of %llu MiB, %u B block size\n", 1037 1025 zlo->id, zlo->nr_zones, 1038 1026 ((sector_t)zlo->zone_size << SECTOR_SHIFT) >> 20, 1039 1027 zlo->block_size); 1028 + pr_info("zloop%d: using %s zone append\n", 1029 + zlo->id, 1030 + zlo->zone_append ? "native" : "emulated"); 1040 1031 1041 1032 return 0; 1042 1033 ··· 1126 1111 opts->nr_queues = ZLOOP_DEF_NR_QUEUES; 1127 1112 opts->queue_depth = ZLOOP_DEF_QUEUE_DEPTH; 1128 1113 opts->buffered_io = ZLOOP_DEF_BUFFERED_IO; 1114 + opts->zone_append = ZLOOP_DEF_ZONE_APPEND; 1129 1115 1130 1116 if (!buf) 1131 1117 return 0; ··· 1235 1219 break; 1236 1220 case ZLOOP_OPT_BUFFERED_IO: 1237 1221 opts->buffered_io = true; 1222 + break; 1223 + case ZLOOP_OPT_ZONE_APPEND: 1224 + if (match_uint(args, &token)) { 1225 + ret = -EINVAL; 1226 + goto out; 1227 + } 1228 + if (token != 0 && token != 1) { 1229 + pr_err("Invalid zone_append value\n"); 1230 + ret = -EINVAL; 1231 + goto out; 1232 + } 1233 + opts->zone_append = token; 1238 1234 break; 1239 1235 case ZLOOP_OPT_ERR: 1240 1236 default: