zbd: Check for direct flag only if its block device
authorAnkit Kumar <ankit.kumar@samsung.com>
Tue, 31 May 2022 13:31:53 +0000 (19:01 +0530)
committerJens Axboe <axboe@kernel.dk>
Thu, 2 Jun 2022 08:19:41 +0000 (02:19 -0600)
nvme-ns generic character devices currently do not support O_DIRECT flag.
Check for fio option for direct flag only if filetype is a block device.

t/zbd skip test case #1 for character devices as they don't require
direct I/O.

Tested-by: Vincent Fu <vincent.fu@samsung.com>
Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20220531133155.17493-8-ankit.kumar@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/zbd/test-zbd-support
zbd.c

index 7e2fff00dac6adc4cc8bc08b7423ab9b7081ab3f..5190ae849364854039363040dfbe3ce86b00dda1 100755 (executable)
@@ -229,6 +229,14 @@ require_regular_block_dev() {
        return 0
 }
 
+require_block_dev() {
+       if [[ -b "$realdev" ]]; then
+               return 0
+       fi
+       SKIP_REASON="$dev is not a block device"
+       return 1
+}
+
 require_seq_zones() {
        local req_seq_zones=${1}
        local seq_bytes=$((disk_size - first_sequential_zone_sector * 512))
@@ -251,8 +259,9 @@ require_conv_zones() {
        return 0
 }
 
-# Check whether buffered writes are refused.
+# Check whether buffered writes are refused for block devices.
 test1() {
+    require_block_dev || return $SKIP_TESTCASE
     run_fio --name=job1 --filename="$dev" --rw=write --direct=0 --bs=4K        \
            "$(ioengine "psync")" --size="${zone_size}" --thread=1      \
            --zonemode=zbd --zonesize="${zone_size}" 2>&1 |
diff --git a/zbd.c b/zbd.c
index b1fd6b4bb0ae23cda7dba13a3c0bf3577139600f..627fb968ecf78d3fa5e48480c95a2199ae5187c2 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -466,7 +466,7 @@ out:
        return res;
 }
 
-/* Verify whether direct I/O is used for all host-managed zoned drives. */
+/* Verify whether direct I/O is used for all host-managed zoned block drives. */
 static bool zbd_using_direct_io(void)
 {
        struct thread_data *td;
@@ -477,7 +477,7 @@ static bool zbd_using_direct_io(void)
                if (td->o.odirect || !(td->o.td_ddir & TD_DDIR_WRITE))
                        continue;
                for_each_file(td, f, j) {
-                       if (f->zbd_info &&
+                       if (f->zbd_info && f->filetype == FIO_TYPE_BLOCK &&
                            f->zbd_info->model == ZBD_HOST_MANAGED)
                                return false;
                }