Emulated ZBC disks make it possible to do application development and kernel tests even if you do not have access to ZBC or ZAC disks. There are several ways to do this.
null_blk: The null_blk kernel driver makes it possible to emulate zoned block devices. This method is discussed in more detail in the Zoned Block Device Emulation with null_blk chapter of the Getting Started Guide.
tcmu-runner: This scsi device emulation application makes it possible to use a regular file (as a storage backstore) to emulate both host-aware and host-managed ZBC SCSI disks. The disks created using tcmu-runner function like physical disks.
scsi_debug: The scsi_debug kernel driver can be configured to emulate host-aware and host-managed ZBC disks that appear to the kernel and application exactly as a real disk would.
The ZBC file handler is an internal device handler of tcmu-runner that emulates a ZBC SCSI disk and uses a file as a backstore. The tcmu-runner infrastructure connects the emulated disk to a virtual HBA that has been implemented as a kernel driver. This structure provides a command path for the emulated disk that is identical to the command path that would be available if a physical disk were in its place. Applications and kernel components will not perceive any difference.
The tcmu-runner ZBC Disk Emulation chapter of the Tools and Libraries guide describes in more detail the options available for creating emulated disks. These include the disk zone model, the disk zone size, the disk capacity, and the number of conventional zones of the disk.
The following example shows how to create a small (20 GB) host-managed ZBC disk that has 10 conventional zones and a 256 MiB zone size. In this example, the emulated disk capacity is stored in the file /var/local/zbc0.raw.
You can verify that the emulated disk has been identified and initialized by the kernel in the same way that you verify the kernel identification and initialization of Serial ATA disks and SAS disks, as discussed in the Getting started with an SMR disk chapter.
Identify the emulated disk by looking at the disk vendor ID that is displayed by the lsscsi utility:
In this example, the emulated disk is listed with the device vendor name "LIO-ORG" and the device model name is "TCMU ZBC device".
As with physical ZBC and ZAC disks, the kernel messages will show that the drive has been identified and initialized:
The kernel identifies the emulated disk in the same way that it would identify a physical SAS host managed disk (that is, with the device type "Direct-Access-ZBC").
The emulated disk can now be used in the same manner as any physical disk. For instance, the blkzone or zbc_report_zones utilities can be used to inspect the disk zone configuration:
The scsi_debug kernel module can be used to create emulated ZBC SCSI disks that use memory backing to store data, which is written to sectors. Because this method uses memory as a backing store, the creation of large disks requires a host with a large amount of DRAM.
This method stores sector data using volatile memory. This means that the data written to the emulated device will not survive the device's destruction and the data written to this emulated device will not survive a host reboot.
scsi_debug ZBC disks can be created using modprobe with arguments. The following is an example that creates a host managed ZBC disk with 16GiB capacity, 64MiB zones, and 32 conventional zones.
After the disk has been created, it can be examined by using the lsscsi command.
The vendor field of the disk is set to "scsi_debug". The kernel messages also show the process whereby this disk came online.
Use zbc_report_zones to verify the zone configuration of the newly-created emulated ZBC disk:
Use blkzone to verify the zone configuration of the newly-created emulated ZBC disk. This displays the same information that is returned by "zbc_report_zones", but it is displayed in a different format: