t/zbd: Mandate blkzone capacity report for devices with zone capacity
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 17 Jul 2020 09:36:34 +0000 (18:36 +0900)
committerJens Axboe <axboe@kernel.dk>
Tue, 21 Jul 2020 15:17:32 +0000 (09:17 -0600)
For NVMe ZNS and null_blk zoned drives, a zone capacity can be smaller
than its size. To test zone capacity handling by fio for these devices,
t/zbd/test-zbd-support must be able to discover zone capacities to avoid
test failures.

To avoid the failures, make zone capacity report by blkzone mandatory if
the test target device is a ZNS device or a null_blk device.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/zbd/functions
t/zbd/test-zbd-support

index 1bd22ec4259ddbcc86c5aa397d06ffe7fd21d7a6..14366e15c40717e88b4420d25eb8c9d6ffbcd538 100644 (file)
@@ -19,6 +19,51 @@ if [ -n "${use_libzbc}" ] &&
     exit 1
 fi
 
+blkzone_reports_capacity() {
+       local dev="${1}"
+
+       [[ -n "${blkzone}" ]] &&
+               "${blkzone}" report -c 1 -o 0 "${dev}" | grep -q 'cap '
+}
+
+# Whether or not $1 (/dev/...) is a NVME ZNS device.
+is_nvme_zns() {
+       local s
+
+       s=/sys/block/$(basename "${1}")/device/subsystem
+
+       if [[ ! -h "${s}" || $(realpath "${s}") != /sys/class/nvme ]]; then
+               return 1
+       fi
+
+       [[ $(</sys/block/$(basename "${1}")/queue/zoned) == host-managed ]]
+}
+
+# Whether or not $1 (/dev/...) is a null_blk device with zone capacity smaller
+# than zone size.
+is_nullb_with_zone_cap() {
+       local f
+
+       f=/sys/kernel/config/nullb/$(basename "${1}")
+       [[ -r "${f}/zone_capacity" &&
+                  $(<"${f}/zone_capacity") -lt $(<"${f}/zone_size") ]]
+}
+
+# Check if blkzone is available and suitable for the test target device. If not
+# available, print error message and return 1. Otherwise return 0.
+check_blkzone() {
+       local dev="${1}"
+
+       # If the device supports zone capacity, mandate zone capacity report by
+       # blkzone.
+       if (is_nvme_zns "${dev}" || is_nullb_with_zone_cap "${dev}") &&
+                               ! blkzone_reports_capacity "${dev}"; then
+               echo "Error: blkzone does not report zone capacity"
+               echo "Error: install latest util-linux with blkzone"
+               return 1
+       fi
+}
+
 # Reports the starting sector and length of the first sequential zone of device
 # $1.
 first_sequential_zone() {
index 80dc3f30b2442f04abc99b94e451829e6d31b805..f086bd1044dc83dcd8eea2f94ffe066944270dcb 100755 (executable)
@@ -863,6 +863,9 @@ if [[ -b "$realdev" ]]; then
        case "$(<"/sys/class/block/$basename/queue/zoned")" in
        host-managed|host-aware)
                is_zbd=true
+               if ! check_blkzone "${dev}"; then
+                       exit 1
+               fi
                if ! result=($(first_sequential_zone "$dev")); then
                        echo "Failed to determine first sequential zone"
                        exit 1