Skip to contentSkip to conversation

New zoned loop block device driver

PATCH Applied Damien Le Moal 4 participants 7 messages Apr 7, 2025 – May 1, 2025

Subsystems (4)
lore
Share & tools
lore

Damien Le Moal

author maintainer
#0 lore raw

v3 cover New zoned loop block device driver

This patch series implements the new "zloop" zoned block device driver which allows creating zoned block devices using one regular file per zone as backing storage. This driver is an alternative to the RUST rublk driver which provide a similar functionality using ublk (See https://github.com/ublk-org/rublk.git). However, zloop is far simpler to use (a single shell command to setup and teardown a device) and does not have any user space dependencies. These characteristics make zloop a better solution for integration in test environments (such as xfstests) using small VMs.

zloop and rublk performance is generally comparable. zloop is a bit faster for large sequential write operations than rublk, while rublk is faster for small zone-random write IOs.

The first patch implements the "zloop" zoned block device driver under drivers/block. 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 v2:
- Rebased on 6.15-rc1
- Some corrections of the documentation

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       |  169 ++
 MAINTAINERS                                   |    8 +
 drivers/block/Kconfig                         |   19 +
 drivers/block/Makefile                        |    1 +
 drivers/block/zloop.c                         | 1385 +++++++++++++++++
 6 files changed, 1583 insertions(+)
 create mode 100644 Documentation/admin-guide/blockdev/zoned_loop.rst
 create mode 100644 drivers/block/zloop.c
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v3 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  | 1385 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1409 insertions(+)
 create mode 100644 drivers/block/zloop.c
MAINTAINERS +7 -0
index 96b827049501..00a27bb81948 100644
@@ -26665,6 +26665,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
index a97f2c40c640..abdbe5d49026 100644
@@ -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
index 1105a2d4fdcb..097707aca725 100644
@@ -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 +1385 -0

1,385 lines not on this page · raw message

Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v3 2/2 Documentation: Document the new zoned loop block device driver

In reply to Damien Le Moal

Introduce 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       | 169 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 drivers/block/Kconfig                         |   3 +
 4 files changed, 174 insertions(+)
 create mode 100644 Documentation/admin-guide/blockdev/zoned_loop.rst
Documentation/admin-guide/blockdev/index.rst +1 -0
index 957ccf617797..3262397ebe8f 100644
@@ -11,6 +11,7 @@ Block Devices
    nbd
    paride
    ramdisk
+   zoned_loop
    zram
 
    drbd/index
Documentation/admin-guide/blockdev/zoned_loop.rst new file +169 -0

169 lines not on this page · raw message

MAINTAINERS +1 -0
index 00a27bb81948..4f25eadf3a27 100644
@@ -26670,6 +26670,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
index abdbe5d49026..3d8874128157 100644
@@ -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.49.0
author maintainer
#5 lore raw
In reply to Damien Le Moal
Quoted 9 lines · Damien Le Moal

This patch series implements the new "zloop" zoned block device driver which allows creating zoned block devices using one regular file per zone as backing storage. This driver is an alternative to the RUST rublk driver which provide a similar functionality using ublk (See https://github.com/ublk-org/rublk.git). However, zloop is far simpler to use (a single shell command to setup and teardown a device) and does not have any user space dependencies. These characteristics make zloop a better solution for integration in test environments (such as xfstests) using small VMs.

Jens,

Can we get this queued ?

Quoted 39 lines

zloop and rublk performance is generally comparable. zloop is a bit faster for large sequential write operations than rublk, while rublk is faster for small zone-random write IOs.

The first patch implements the "zloop" zoned block device driver under drivers/block. 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 v2:
- Rebased on 6.15-rc1
- Some corrections of the documentation

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       |  169 ++
 MAINTAINERS                                   |    8 +
 drivers/block/Kconfig                         |   19 +
 drivers/block/Makefile                        |    1 +
 drivers/block/zloop.c                         | 1385 +++++++++++++++++
 6 files changed, 1583 insertions(+)
 create mode 100644 Documentation/admin-guide/blockdev/zoned_loop.rst
 create mode 100644 drivers/block/zloop.c
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#6 lore raw
In reply to Damien Le Moal
Quoted 11 lines · Damien Le Moal

This patch series implements the new "zloop" zoned block device driver which allows creating zoned block devices using one regular file per zone as backing storage. This driver is an alternative to the RUST rublk driver which provide a similar functionality using ublk (See https://github.com/ublk-org/rublk.git). However, zloop is far simpler to use (a single shell command to setup and teardown a device) and does not have any user space dependencies. These characteristics make zloop a better solution for integration in test environments (such as xfstests) using small VMs.

[...]

Applied, thanks!

[1/2] block: new zoned loop block device driver

      commit: eb0570c7df23c2f32fe899fcdaf8fca9a5ecd51e
[2/2] Documentation: Document the new zoned loop block device driver
      commit: 9e4f11c1228cc8ebf236cfa51d44abafec80f326

Best regards,

Signature · 1 line
Jens Axboe