Skip to content

Commit eb0570c

Browse files
damien-lemoalaxboe
authored andcommitted
block: new zoned loop block device driver
The zoned loop block device driver allows a user to create emulated zoned block devices using one regular file per zone as backing storage. Compared to null_blk or scsi_debug, it has the advantage of allowing emulating large zoned devices without requiring the same amount of memory as the capacity of the emulated device. Furthermore, zoned devices emulated with this driver can be re-started after a host reboot without any loss of the state of the device zones, which is something that null_blk and scsi_debug do not support. This initial implementation is simple and does not support zone resource limits. That is, a zoned loop block device limits for the maximum number of open zones and maximum number of active zones is always 0. This driver can be either compiled in-kernel or as a module, named "zloop". Compilation of this driver depends on the block layer support for zoned block device (CONFIG_BLK_DEV_ZONED must be set). Using the zloop driver to create and delete zoned block devices is done by writing commands to the zoned loop control character device file (/dev/zloop-control). Creating a device is done with: $ echo "add [options]" > /dev/zloop-control The options available for the "add" operation cat be listed by reading the zloop-control device file: $ cat /dev/zloop-control add id=%d,capacity_mb=%u,zone_size_mb=%u,zone_capacity_mb=%u,conv_zones=%u,base_dir=%s,nr_queues=%u,queue_depth=%u remove id=%d The options available allow controlling the zoned device total capacity, zone size, zone capactity of sequential zones, total number of conventional zones, base directory for the zones backing file, number of I/O queues and the maximum queue depth of I/O queues. Deleting a device is done using the "remove" command: $ echo "remove id=0" > /dev/zloop-control This implementation passes various tests using zonefs and fio (t/zbd tests) and provides a state machine for zone conditions that is compliant with the T10 ZBC and NVMe ZNS specifications. Co-developed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20250407075222.170336-2-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 53ec1ab commit eb0570c

File tree

4 files changed

+1409
-0
lines changed

4 files changed

+1409
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26723,6 +26723,13 @@ L: linux-kernel@vger.kernel.org
2672326723
S: Maintained
2672426724
F: arch/x86/kernel/cpu/zhaoxin.c
2672526725

26726+
ZONED LOOP DEVICE
26727+
M: Damien Le Moal <dlemoal@kernel.org>
26728+
R: Christoph Hellwig <hch@lst.de>
26729+
L: linux-block@vger.kernel.org
26730+
S: Maintained
26731+
F: drivers/block/zloop.c
26732+
2672626733
ZONEFS FILESYSTEM
2672726734
M: Damien Le Moal <dlemoal@kernel.org>
2672826735
M: Naohiro Aota <naohiro.aota@wdc.com>

drivers/block/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,20 @@ config BLKDEV_UBLK_LEGACY_OPCODES
407407

408408
source "drivers/block/rnbd/Kconfig"
409409

410+
config BLK_DEV_ZONED_LOOP
411+
tristate "Zoned loopback device support"
412+
depends on BLK_DEV_ZONED
413+
help
414+
Saying Y here will allow you to use create a zoned block device using
415+
regular files for zones (one file per zones). This is useful to test
416+
file systems, device mapper and applications that support zoned block
417+
devices. To create a zoned loop device, no user utility is needed, a
418+
zoned loop device can be created (or re-started) using a command
419+
like:
420+
421+
echo "add id=0,zone_size_mb=256,capacity_mb=16384,conv_zones=11" > \
422+
/dev/zloop-control
423+
424+
If unsure, say N.
425+
410426
endif # BLK_DEV

drivers/block/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ obj-$(CONFIG_BLK_DEV_RNBD) += rnbd/
4141
obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/
4242

4343
obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o
44+
obj-$(CONFIG_BLK_DEV_ZONED_LOOP) += zloop.o
4445

4546
swim_mod-y := swim.o swim_asm.o

0 commit comments

Comments
 (0)