New zoned loop block device driver
Subsystems (4)
Damien Le Moal
maintainerv2 cover New zoned loop block device driver
The first patch implements the new "zloop" zoned block device driver which allows creating zoned block devices using one regular file per zone as backing storage.
The second patch adds documentation for this driver (overview and usage examples).
About half of the code of the first patch is from Christoph Hellwig.
Damien Le Moal (2):
block: new zoned loop block device driver
Documentation: Document the new zoned loop block device driver
Changes from v1:
- Corrected Kconfig description in patch 1 (outdated example was shown)
- Added missing request sector update on completion of zone append request (I had not pushed that...)
- Added reference to the documentation in the kconfig entry in patch 2
Damien Le Moal (2):
block: new zoned loop block device driver
Documentation: Document the new zoned loop block device driver
Documentation/admin-guide/blockdev/index.rst | 1 + .../admin-guide/blockdev/zoned_loop.rst | 168 +++ MAINTAINERS | 8 + drivers/block/Kconfig | 19 + drivers/block/Makefile | 1 + drivers/block/zloop.c | 1334 +++++++++++++++++ 6 files changed, 1531 insertions(+) create mode 100644 Documentation/admin-guide/blockdev/zoned_loop.rst create mode 100644 drivers/block/zloop.c
base-commit: 9d89551994a430b50c4fffcb1e617a057fa76e20
Signature · 1 line
2.47.1
Damien Le Moal
maintainerPATCH v2 1/2 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.
--- MAINTAINERS | 7 + drivers/block/Kconfig | 16 + drivers/block/Makefile | 1 + drivers/block/zloop.c | 1334 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1358 insertions(+) create mode 100644 drivers/block/zloop.c
MAINTAINERS +7 -0
@@ -25972,6 +25972,13 @@ L: [email protected] S: Maintained F: arch/x86/kernel/cpu/zhaoxin.c +ZONED LOOP DEVICE +M: Damien Le Moal <[email protected]> +R: Christoph Hellwig <[email protected]> +L: [email protected] +S: Maintained +F: drivers/block/zloop.c + ZONEFS FILESYSTEM M: Damien Le Moal <[email protected]> M: Naohiro Aota <[email protected]>
drivers/block/Kconfig +16 -0
@@ -413,4 +413,20 @@ config BLKDEV_UBLK_LEGACY_OPCODES source "drivers/block/rnbd/Kconfig" +config BLK_DEV_ZONED_LOOP + tristate "Zoned loopback device support" + depends on BLK_DEV_ZONED + help + Saying Y here will allow you to use create a zoned block device using + regular files for zones (one file per zones). This is useful to test + file systems, device mapper and applications that support zoned block + devices. To create a zoned loop device, no user utility is needed, a + zoned loop device can be created (or re-started) using a command + like: + + echo "add id=0,zone_size_mb=256,capacity_mb=16384,conv_zones=11" > \ + /dev/zloop-control + + If unsure, say N. + endif # BLK_DEV
drivers/block/Makefile +1 -0
@@ -41,5 +41,6 @@ obj-$(CONFIG_BLK_DEV_RNBD) += rnbd/ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk/ obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o +obj-$(CONFIG_BLK_DEV_ZONED_LOOP) += zloop.o swim_mod-y := swim.o swim_asm.o
drivers/block/zloop.c new file +1334 -0
1,334 lines not on this page · raw message
Signature · 1 line
2.47.1
Damien Le Moal
maintainerPATCH v2 2/2 Documentation: Document the new zoned loop block device driver
In reply to Damien Le MoalIntroduce the zoned_loop.rst documentation file under admin-guide/blockdev to document the zoned loop block device driver. An overview of the driver is provided and its usage to create and delete zoned devices described.
--- Documentation/admin-guide/blockdev/index.rst | 1 + .../admin-guide/blockdev/zoned_loop.rst | 168 ++++++++++++++++++ MAINTAINERS | 1 + drivers/block/Kconfig | 3 + 4 files changed, 173 insertions(+) create mode 100644 Documentation/admin-guide/blockdev/zoned_loop.rst
Documentation/admin-guide/blockdev/index.rst +1 -0
@@ -11,6 +11,7 @@ Block Devices nbd paride ramdisk + zoned_loop zram drbd/index
Documentation/admin-guide/blockdev/zoned_loop.rst new file +168 -0
168 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -25977,6 +25977,7 @@ M: Damien Le Moal <[email protected]> R: Christoph Hellwig <[email protected]> L: [email protected] S: Maintained +F: Documentation/admin-guide/blockdev/zoned_loop.rst F: drivers/block/zloop.c ZONEFS FILESYSTEM
drivers/block/Kconfig +3 -0
@@ -427,6 +427,9 @@ config BLK_DEV_ZONED_LOOP echo "add id=0,zone_size_mb=256,capacity_mb=16384,conv_zones=11" > \ /dev/zloop-control + See Documentation/admin-guide/blockdev/zoned_loop.rst for usage + details. + If unsure, say N. endif # BLK_DEV
Signature · 1 line
2.47.1