From 88656cc95b698c7089364767bb0b5ba0a7d6e625 Mon Sep 17 00:00:00 2001 From: Christos Longros <98426896+chrislongros@users.noreply.github.com> Date: Tue, 26 May 2026 01:07:02 +0200 Subject: [PATCH] ZTS/alloc_class: move file_in_special_vdev to alloc_class.kshlib Move the function into the shared library. Reviewed-by: Brian Behlendorf Signed-off-by: Christos Longros Closes #18584 --- .../functional/alloc_class/alloc_class.kshlib | 34 ++++++++++++++++++ .../alloc_class/alloc_class_012_pos.ksh | 35 ------------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib index be281c62404..649a6ec601c 100644 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib @@ -67,3 +67,37 @@ function display_status return $ret } + +# +# Verify the file identified by the input is written on a special vdev +# According to the pool layout used in this test vdev_id 3 and 4 are special +# +function file_in_special_vdev # +{ + typeset dataset="$1" + typeset inum="$2" + typeset num_normal=$(echo $ZPOOL_DISKS | wc -w) + num_normal=${num_normal##* } + + zdb -dddddd $dataset $inum | awk -v d=$num_normal '{ +# find DVAs from string "offset level dva" only for L0 (data) blocks +if (match($0,"L0 [0-9]+")) { + dvas[0]=$3 + dvas[1]=$4 + dvas[2]=$5 + for (i = 0; i < 3; ++i) { + if (match(dvas[i],"([^:]+):.*")) { + dva = substr(dvas[i], RSTART, RLENGTH); + # parse DVA from string "vdev:offset:asize" + if (split(dva,arr,":") != 3) { + print "Error parsing DVA: <" dva ">"; + exit 1; + } + # verify vdev is "special" + if (arr[1] < d) { + exit 1; + } + } + } +}}' +} diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh index 743a717b2e8..3d463b37611 100755 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh @@ -25,41 +25,6 @@ verify_runnable "global" -# -# Verify the file identified by the input is written on a special vdev -# According to the pool layout used in this test vdev_id 3 and 4 are special -# XXX: move this function to libtest.shlib once we get "Vdev Properties" -# -function file_in_special_vdev # -{ - typeset dataset="$1" - typeset inum="$2" - typeset num_normal=$(echo $ZPOOL_DISKS | wc -w) - num_normal=${num_normal##* } - - zdb -dddddd $dataset $inum | awk -v d=$num_normal '{ -# find DVAs from string "offset level dva" only for L0 (data) blocks -if (match($0,"L0 [0-9]+")) { - dvas[0]=$3 - dvas[1]=$4 - dvas[2]=$5 - for (i = 0; i < 3; ++i) { - if (match(dvas[i],"([^:]+):.*")) { - dva = substr(dvas[i], RSTART, RLENGTH); - # parse DVA from string "vdev:offset:asize" - if (split(dva,arr,":") != 3) { - print "Error parsing DVA: <" dva ">"; - exit 1; - } - # verify vdev is "special" - if (arr[1] < d) { - exit 1; - } - } - } -}}' -} - # # Check that device removal works for special class vdevs #