From cb6ee92a7fbf7e373074409d9570dc9b27dece17 Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Thu, 21 Feb 2019 13:11:02 +0900 Subject: [PATCH] t/zbd: Fix handling of partition devices To allow t/zbd/tests-zbd-support test script to run correctly on partitions of zoned block devices, fix access to the device properties through sysfs by referencing the sysfs directory of the holder block device. Doing so, the "zoned", "logical_block_size" and "mq" attributes can be correctly accessed. Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: Jens Axboe --- t/zbd/test-zbd-support | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/t/zbd/test-zbd-support b/t/zbd/test-zbd-support index 2d727910..d316d880 100755 --- a/t/zbd/test-zbd-support +++ b/t/zbd/test-zbd-support @@ -761,7 +761,15 @@ source "$(dirname "$0")/functions" || exit $? dev=$1 realdev=$(readlink -f "$dev") basename=$(basename "$realdev") -disk_size=$(($(<"/sys/block/$basename/size")*512)) +major=$((0x$(stat -L -c '%t' "$realdev"))) +minor=$((0x$(stat -L -c '%T' "$realdev"))) +disk_size=$(($(<"/sys/dev/block/$major:$minor/size")*512)) +# When the target is a partition device, get basename of its holder device to +# access sysfs path of the holder device +if [[ -r "/sys/dev/block/$major:$minor/partition" ]]; then + realsysfs=$(readlink "/sys/dev/block/$major:$minor") + basename=$(basename "${realsysfs%/*}") +fi logical_block_size=$(<"/sys/block/$basename/queue/logical_block_size") case "$(<"/sys/class/block/$basename/queue/zoned")" in host-managed|host-aware) -- 2.25.1