Zoned Storage-Tools and Librarues
本章描述了支持zoned块设备的用户级应用程序和库。
Linux 系统实用程序
正如 util-linux 项目本身的文档所说,util-linux 是 Linux® 实用程序的随机集合。 util-linux 项目托管在 GitHub 。 该项目以 util-linux 名称打包在大多数发行版中,并默认安装。
util-linux 提供(以及其他实用程序)lsblk 和 blkzone 命令行工具,用于列出分区zoned设备和获取zone的配置。 blkzone 工具还允许重置顺序区域的写指针。
这些实用程序对于 shell 脚本和解决用户应用程序中的zone管理问题特别有用。
lsbllk
- lsblk 命令列出系统的所有块设备,无论块设备类型如何(这意味着是的,它还包括分区块设备)。 lsblk 的输出如下:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 167.7G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 150.7G 0 part /
└─sda3 8:3 0 16G 0 part [SWAP]
sdb 8:16 0 12.8T 0 disk
sdc 8:32 0 12.8T 0 disk
sdd 8:48 0 13.7T 0 disk
- 默认情况下,lsblk 不提供列出的块设备的区域模型的指示。 要发现此信息,请使用选项
-z
:
# lsblk -z
NAME ZONED
sda none
├─sda1 none
├─sda2 none
└─sda3 none
sdb host-managed
sdc host-managed
sdd host-managed
- 可以使用
-o
选项格式化 lsblk 的输出。 例如,以下命令将显示块设备名称、大小和区域模型。
# lsblk -o NAME,SIZE,ZONED
NAME SIZE ZONED
sda 167.7G none
├─sda1 1G none
├─sda2 150.7G none
└─sda3 16G none
sdb 12.8T host-managed
sdc 12.8T host-managed
sdd 13.7T host-managed
blkzone
blkzone 命令行实用程序列出(报告)zoned块设备的区域并重置顺序区域的写指针。 blkzone 依赖于内核提供的 ZBD ioctl()
接口来执行“zone report”和“zone reset”操作。 blkzone 不会直接向设备发出 SCSI、ATA 或 NVMe 命令。
blkzone 命令用法如下图:
# blkzone --help
Usage:
blkzone <command> [options] <device>
Run zone command on the given block device.
Commands:
report Report zone information about the given device
capacity Report zone capacity for the given device
reset Reset a range of zones.
open Open a range of zones.
close Close a range of zones.
finish Set a range of zones to Full.
Options:
-o, --offset <sector> start sector of zone to act (in 512-byte sectors)
-l, --length <sectors> maximum sectors to act (in 512-byte sectors)
-c, --count <number> maximum number of zones
-f, --force enforce on block devices used by the system
-v, --verbose display more details
-h, --help display this help
-V, --version display version
Arguments:
<sector> and <sectors> arguments may be followed by the suffixes for
GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is optional)
For more details see blkzone(8).
- Zone Report
# blkzone report /dev/sdd
start: 0x000000000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000080000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000100000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000180000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000200000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000280000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000300000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000380000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000400000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x000480000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
...
start: 0x010500000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x010580000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 0(nw) [type: 1(CONVENTIONAL)]
start: 0x010600000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
start: 0x010680000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
start: 0x010700000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
start: 0x010780000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 1(em) [type: 2(SEQ_WRITE_REQUIRED)]
start: 0x010800000, len 0x080000, cap 0x080000, wptr 0x000000 reset:0 non-seq:0, zcond: 1