diff --git a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh index e51cf179d8ef..552a27e98102 100755 --- a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh @@ -29,8 +29,8 @@ # # DESCRIPTION: -# Ensure stats presented in /proc/spl/kstat/zfs/dbufstats are correct -# based on /proc/spl/kstat/zfs/dbufs. +# Ensure stats presented in the dbufstats kstat are correct based on the +# dbufs kstat. # # STRATEGY: # 1. Generate a file with random data in it @@ -55,12 +55,7 @@ function testdbufstat # stat_name dbufstat_filter [[ -n "$2" ]] && filter="-F $2" - if is_linux; then - read -r _ _ from_dbufstat _ < <(grep -w "$name" "$DBUFSTATS_FILE") - else - from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \ - "$DBUFSTATS_FILE") - fi + from_dbufstat=$(grep "^$name " "$DBUFSTATS_FILE" | cut -f2 -d' ') from_dbufs=$(dbufstat -bxn -i "$DBUFS_FILE" "$filter" | wc -l) within_tolerance $from_dbufstat $from_dbufs 15 \ @@ -77,7 +72,7 @@ log_must file_write -o create -f "$TESTDIR/file" -b 1048576 -c 20 -d R sync_all_pools log_must eval "kstat dbufs > $DBUFS_FILE" -log_must eval "kstat dbufstats '' > $DBUFSTATS_FILE" +log_must eval "kstat -g dbufstats > $DBUFSTATS_FILE" for level in {0..11}; do testdbufstat "cache_level_$level" "dbc=1,level=$level" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh index fdda9ba22638..d108f0c53348 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -31,10 +31,9 @@ # 7. Run zdb -dddddd pool/objsetID objectID (hex) # 8. Confirm names # 9. Repeat with zdb -NNNNNN pool/objsetID objectID -# 10. Obtain objsetID from /proc/spl/kstat/zfs/testpool/obset-0x -# (linux only) +# 10. Obtain dataset name from testpool.objset-0x.dataset_name kstat # 11. Run zdb -dddddd pool/objsetID (hex) -# 12. Match name from zdb against proc entry +# 12. Match name from zdb against kstat # 13. Create dataset with hex numeric name # 14. Create dataset with decimal numeric name # 15. zdb -d for numeric datasets succeeds @@ -68,7 +67,7 @@ log_note "file $init_data has object number $obj" sync_pool $TESTPOOL IFS=", " read -r _ _ _ _ objset_id _ < <(zdb -d $TESTPOOL/$TESTFS) -objset_hex=$(printf "0x%X" $objset_id) +objset_hex=$(printf "0x%x" $objset_id) log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" for id in "$objset_id" "$objset_hex" @@ -89,13 +88,9 @@ do log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" done -if is_linux; then - output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL | grep objset- | tail -1) - objset_hex=${output#*-} - name_from_proc=$(grep dataset_name /proc/spl/kstat/zfs/$TESTPOOL/$output | cut -d' ' -f3) - log_note "checking zdb output for $name_from_proc" - log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" -fi +name_from_proc=$(kstat objset-$objset_hex.dataset_name $TESTPOOL) +log_note "checking zdb output for $name_from_proc" +log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" log_must zfs create $hex_ds log_must zfs create $num_ds diff --git a/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh b/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh index f1561b7282e5..839f8f6fd606 100755 --- a/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh +++ b/tests/zfs-tests/tests/functional/deadman/deadman_sync.ksh @@ -73,11 +73,7 @@ log_must zinject -c all sync_all_pools # Log txg sync times for reference and the zpool event summary. -if is_freebsd; then - log_must sysctl -n kstat.zfs.$TESTPOOL.txgs -else - log_must cat /proc/spl/kstat/zfs/$TESTPOOL/txgs -fi +log_must kstat txgs $TESTPOOL log_must zpool events # Verify at least 3 deadman events were logged. The first after 5 seconds, diff --git a/tests/zfs-tests/tests/functional/direct/dio.kshlib b/tests/zfs-tests/tests/functional/direct/dio.kshlib index 5b3f893e1ce1..0d06f6ffe183 100644 --- a/tests/zfs-tests/tests/functional/direct/dio.kshlib +++ b/tests/zfs-tests/tests/functional/direct/dio.kshlib @@ -140,29 +140,6 @@ function check_dio_chksum_verify_failures # pool vdev_type op expect_errors } -# -# Get the value of a counter from -# Linux: /proc/spl/kstat/zfs/$pool/iostats file. -# FreeBSD: kstat.zfs.$pool.msic.iostats.$stat -# -function get_iostats_stat # pool stat -{ - typeset pool=$1 - typeset stat=$2 - - if is_linux; then - iostats_file=/proc/spl/kstat/zfs/$pool/iostats - val=$(grep -m1 "$stat" $iostats_file | awk '{ print $3 }') - else - val=$(sysctl -n kstat.zfs.$pool.misc.iostats.$stat) - fi - if [[ -z "$val" ]]; then - log_fail "Unable to read $stat counter" - fi - - echo "$val" -} - # # Evict any buffered blocks by overwritting them using an O_DIRECT request. # @@ -190,17 +167,13 @@ function verify_dio_write_count #pool bs size mnpnt log_note "Checking for $dio_wr_expected Direct I/O writes" - prev_dio_wr=$(get_iostats_stat $pool direct_write_count) + prev_dio_wr=$(kstat iostats.direct_write_count $pool) dio_and_verify write $size $bs $mntpnt "sync" - curr_dio_wr=$(get_iostats_stat $pool direct_write_count) + curr_dio_wr=$(kstat iostats.direct_write_count $pool) dio_wr_actual=$((curr_dio_wr - prev_dio_wr)) if [[ $dio_wr_actual -lt $dio_wr_expected ]]; then - if is_linux; then - cat /proc/spl/kstat/zfs/$pool/iostats - else - sysctl kstat.zfs.$pool.misc.iostats - fi + kstat -g iostats $pool log_fail "Direct writes $dio_wr_actual of $dio_wr_expected" fi } @@ -223,33 +196,25 @@ function check_write # pool file bs count seek flags buf_wr dio_wr log_note "Checking $count * $bs write(s) at offset $seek, $flags" - prev_buf_wr=$(get_iostats_stat $pool arc_write_count) - prev_dio_wr=$(get_iostats_stat $pool direct_write_count) + prev_buf_wr=$(kstat iostats.arc_write_count $pool) + prev_dio_wr=$(kstat iostats.direct_write_count $pool) log_must stride_dd -i /dev/urandom -o $file -b $bs -c $count \ -k $seek $flags - curr_buf_wr=$(get_iostats_stat $pool arc_write_count) + curr_buf_wr=$(kstat iostats.arc_write_count $pool) buf_wr_actual=$((curr_buf_wr - prev_buf_wr)) - curr_dio_wr=$(get_iostats_stat $pool direct_write_count) + curr_dio_wr=$(kstat iostats.direct_write_count $pool) dio_wr_actual=$((curr_dio_wr - prev_dio_wr)) if [[ $buf_wr_actual -lt $buf_wr_expect ]]; then - if is_linux; then - cat /proc/spl/kstat/zfs/$pool/iostats - else - sysctl kstat.zfs.$pool.misc.iostats - fi + kstat -g iostats $pool log_fail "Buffered writes $buf_wr_actual of $buf_wr_expect" fi if [[ $dio_wr_actual -lt $dio_wr_expect ]]; then - if is_linux; then - cat /proc/spl/kstat/zfs/$pool/iostats - else - sysctl kstat.zfs.$pool.misc.iostats - fi + kstat -g iostats $pool log_fail "Direct writes $dio_wr_actual of $dio_wr_expect" fi } @@ -272,33 +237,25 @@ function check_read # pool file bs count skip flags buf_rd dio_rd log_note "Checking $count * $bs read(s) at offset $skip, $flags" - prev_buf_rd=$(get_iostats_stat $pool arc_read_count) - prev_dio_rd=$(get_iostats_stat $pool direct_read_count) + prev_buf_rd=$(kstat iostats.arc_read_count $pool) + prev_dio_rd=$(kstat iostats.direct_read_count $pool) log_must stride_dd -i $file -o /dev/null -b $bs -c $count \ -p $skip $flags - curr_buf_rd=$(get_iostats_stat $pool arc_read_count) + curr_buf_rd=$(kstat iostats.arc_read_count $pool) buf_rd_actual=$((curr_buf_rd - prev_buf_rd)) - curr_dio_rd=$(get_iostats_stat $pool direct_read_count) + curr_dio_rd=$(kstat iostats.direct_read_count $pool) dio_rd_actual=$((curr_dio_rd - prev_dio_rd)) if [[ $buf_rd_actual -lt $buf_rd_expect ]]; then - if is_linux; then - cat /proc/spl/kstat/zfs/$pool/iostats - else - sysctl kstat.zfs.$pool.misc.iostats - fi + kstat -g iostats $pool log_fail "Buffered reads $buf_rd_actual of $buf_rd_expect" fi if [[ $dio_rd_actual -lt $dio_rd_expect ]]; then - if is_linux; then - cat /proc/spl/kstat/zfs/$pool/iostats - else - sysctl kstat.zfs.$pool.misc.iostats - fi + kstat -g iostats $pool log_fail "Direct reads $dio_rd_actual of $dio_rd_expect" fi } diff --git a/tests/zfs-tests/tests/functional/direct/dio_read_verify.ksh b/tests/zfs-tests/tests/functional/direct/dio_read_verify.ksh index 456d429b1d99..ecd14b0463ea 100755 --- a/tests/zfs-tests/tests/functional/direct/dio_read_verify.ksh +++ b/tests/zfs-tests/tests/functional/direct/dio_read_verify.ksh @@ -72,8 +72,8 @@ for type in "" "mirror" "raidz" "draid"; do $TESTPOOL1/$TESTFS1" mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS1) - prev_dio_rd=$(get_iostats_stat $TESTPOOL1 direct_read_count) - prev_arc_rd=$(get_iostats_stat $TESTPOOL1 arc_read_count) + prev_dio_rd=$(kstat iostats.direct_read_count $TESTPOOL1) + prev_arc_rd=$(kstat iostats.arc_read_count $TESTPOOL1) # Create the file before trying to manipulate the contents log_must stride_dd -o "$mntpnt/direct-write.iso" -i /dev/urandom \ @@ -83,8 +83,8 @@ for type in "" "mirror" "raidz" "draid"; do -n $NUMBLOCKS -b $BS -r # Getting new Direct I/O and ARC Write counts. - curr_dio_rd=$(get_iostats_stat $TESTPOOL1 direct_read_count) - curr_arc_rd=$(get_iostats_stat $TESTPOOL1 arc_read_count) + curr_dio_rd=$(kstat iostats.direct_read_count $TESTPOOL1) + curr_arc_rd=$(kstat iostats.arc_read_count $TESTPOOL1) total_dio_rd=$((curr_dio_rd - prev_dio_rd)) total_arc_rd=$((curr_arc_rd - prev_arc_rd)) diff --git a/tests/zfs-tests/tests/functional/direct/dio_unaligned_filesize.ksh b/tests/zfs-tests/tests/functional/direct/dio_unaligned_filesize.ksh index 8bb363f1a983..437084a1370c 100755 --- a/tests/zfs-tests/tests/functional/direct/dio_unaligned_filesize.ksh +++ b/tests/zfs-tests/tests/functional/direct/dio_unaligned_filesize.ksh @@ -73,11 +73,11 @@ log_must zpool export $TESTPOOL log_must zpool import $TESTPOOL # Reading the file back using Direct I/O -prev_dio_read=$(get_iostats_stat $TESTPOOL direct_read_count) -prev_arc_read=$(get_iostats_stat $TESTPOOL arc_read_count) +prev_dio_read=$(kstat iostats.direct_read_count $TESTPOOL) +prev_arc_read=$(kstat iostats.arc_read_count $TESTPOOL) log_must stride_dd -i $filename -o /dev/null -b $bs -e -d -curr_dio_read=$(get_iostats_stat $TESTPOOL direct_read_count) -curr_arc_read=$(get_iostats_stat $TESTPOOL arc_read_count) +curr_dio_read=$(kstat iostats.direct_read_count $TESTPOOL) +curr_arc_read=$(kstat iostats.arc_read_count $TESTPOOL) total_dio_read=$((curr_dio_read - prev_dio_read)) total_arc_read=$((curr_arc_read - prev_arc_read)) diff --git a/tests/zfs-tests/tests/functional/direct/dio_write_stable_pages.ksh b/tests/zfs-tests/tests/functional/direct/dio_write_stable_pages.ksh index ccdabc678a68..dd15035af518 100755 --- a/tests/zfs-tests/tests/functional/direct/dio_write_stable_pages.ksh +++ b/tests/zfs-tests/tests/functional/direct/dio_write_stable_pages.ksh @@ -72,7 +72,7 @@ do log_note "Verifying stable pages for Direct I/O writes \ iteration $i of $ITERATIONS" - prev_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + prev_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) # Manipulate the user's buffer while running O_DIRECT write # workload with the buffer. @@ -83,7 +83,7 @@ do log_must stride_dd -i $mntpnt/direct-write.iso -o /dev/null \ -b $BS -c $NUMBLOCKS - curr_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + curr_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) total_dio_wr=$((curr_dio_wr - prev_dio_wr)) log_note "Making sure we have Direct I/O writes logged" diff --git a/tests/zfs-tests/tests/functional/direct/dio_write_verify.ksh b/tests/zfs-tests/tests/functional/direct/dio_write_verify.ksh index 4eb9efe95ef1..311c55bcfead 100755 --- a/tests/zfs-tests/tests/functional/direct/dio_write_verify.ksh +++ b/tests/zfs-tests/tests/functional/direct/dio_write_verify.ksh @@ -90,10 +90,10 @@ log_must set_tunable32 VDEV_DIRECT_WR_VERIFY 0 # failures log_note "Verifying no panics for Direct I/O writes with compression" log_must zfs set compression=on $TESTPOOL/$TESTFS -prev_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) +prev_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) log_must manipulate_user_buffer -f "$mntpnt/direct-write.iso" -n $NUMBLOCKS \ -b $BS -w -curr_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) +curr_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) total_dio_wr=$((curr_dio_wr - prev_dio_wr)) log_note "Making sure we have Direct I/O writes logged" @@ -115,7 +115,7 @@ for i in $(seq 1 $ITERATIONS); do log_note "Verifying Direct I/O write checksums iteration \ $i of $ITERATIONS with zfs_vdev_direct_write_verify=0" - prev_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + prev_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) log_must manipulate_user_buffer -f "$mntpnt/direct-write.iso" \ -n $NUMBLOCKS -b $BS -w @@ -126,7 +126,7 @@ for i in $(seq 1 $ITERATIONS); do -c $num_blocks # Getting new Direct I/O and ARC write counts. - curr_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + curr_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) total_dio_wr=$((curr_dio_wr - prev_dio_wr)) # Verifying there are checksum errors @@ -165,7 +165,7 @@ for i in $(seq 1 $ITERATIONS); do log_note "Verifying every Direct I/O write checksums iteration $i of \ $ITERATIONS with zfs_vdev_direct_write_verify=1" - prev_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + prev_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) log_must manipulate_user_buffer -f "$mntpnt/direct-write.iso" \ -n $NUMBLOCKS -b $BS -e -w @@ -176,7 +176,7 @@ for i in $(seq 1 $ITERATIONS); do -c $num_blocks # Getting new Direct I/O write counts. - curr_dio_wr=$(get_iostats_stat $TESTPOOL direct_write_count) + curr_dio_wr=$(kstat iostats.direct_write_count $TESTPOOL) total_dio_wr=$((curr_dio_wr - prev_dio_wr)) log_note "Making sure there are no checksum errors with the ZPool" diff --git a/tests/zfs-tests/tests/functional/fadvise/fadvise_sequential.ksh b/tests/zfs-tests/tests/functional/fadvise/fadvise_sequential.ksh index 7b7d1d379ac6..daeb93273a54 100755 --- a/tests/zfs-tests/tests/functional/fadvise/fadvise_sequential.ksh +++ b/tests/zfs-tests/tests/functional/fadvise/fadvise_sequential.ksh @@ -54,10 +54,6 @@ function cleanup [[ -e $TESTDIR ]] && log_must rm -Rf $TESTDIR/* } -getstat() { - awk -v c="$1" '$1 == c {print $3; exit}' /proc/spl/kstat/zfs/arcstats -} - log_assert "Ensure fadvise prefetch data" log_onexit cleanup @@ -67,12 +63,12 @@ log_must zfs set primarycache=metadata $TESTPOOL log_must file_write -o create -f $FILE -b $BLKSZ -c 1000 sync_pool $TESTPOOL -data_size1=$(getstat data_size) +data_size1=$(kstat arcstats.data_size) log_must file_fadvise -f $FILE -a 2 sleep 10 -data_size2=$(getstat data_size) +data_size2=$(kstat arcstats.data_size) log_note "original data_size is $data_size1, final data_size is $data_size2" log_must [ $data_size1 -le $data_size2 ] diff --git a/tests/zfs-tests/tests/functional/fault/suspend_on_probe_errors.ksh b/tests/zfs-tests/tests/functional/fault/suspend_on_probe_errors.ksh index d9261bb5d274..4b413a465350 100755 --- a/tests/zfs-tests/tests/functional/fault/suspend_on_probe_errors.ksh +++ b/tests/zfs-tests/tests/functional/fault/suspend_on_probe_errors.ksh @@ -119,14 +119,14 @@ log_must dd if=/dev/urandom of=$MNTPOINT/writes bs=1M count=1 # Wait until sync starts, and the pool suspends log_note "waiting for pool to suspend" typeset -i tries=30 -until [[ $(cat /proc/spl/kstat/zfs/$TESTPOOL/state) == "SUSPENDED" ]] ; do +until [[ $(kstat state $TESTPOOL) == "SUSPENDED" ]] ; do if ((tries-- == 0)); then zpool status -s log_fail "UNEXPECTED -- pool did not suspend" fi sleep 1 done -log_note $(cat /proc/spl/kstat/zfs/$TESTPOOL/state) +log_note $(kstat state $TESTPOOL) # Put the missing disks back into service log_must eval "echo running > /sys/block/$sd/device/state" @@ -137,7 +137,7 @@ log_must zpool clear $TESTPOOL # Wait until the pool resumes log_note "waiting for pool to resume" tries=30 -until [[ $(cat /proc/spl/kstat/zfs/$TESTPOOL/state) != "SUSPENDED" ]] ; do +until [[ $(kstat state $TESTPOOL) != "SUSPENDED" ]] ; do if ((tries-- == 0)); then log_fail "pool did not resume" fi diff --git a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh index b67059158a57..260e3c449c63 100755 --- a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh +++ b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh @@ -26,8 +26,6 @@ . $STF_SUITE/include/libtest.shlib -set -x - DATAFILE="$TMPDIR/datafile" function cleanup @@ -62,7 +60,7 @@ log_must cp $DATAFILE /$TESTPOOL/file # wait until sync starts, and the pool suspends log_note "waiting for pool to suspend" typeset -i tries=10 -until [[ $(cat /proc/spl/kstat/zfs/$TESTPOOL/state) == "SUSPENDED" ]] ; do +until [[ $(kstat state $TESTPOOL) == "SUSPENDED" ]] ; do if ((tries-- == 0)); then log_fail "pool didn't suspend" fi @@ -82,7 +80,7 @@ log_note "giving pool time to settle and complete txg" sleep 7 # if the pool suspended, then everything is bad -if [[ $(cat /proc/spl/kstat/zfs/$TESTPOOL/state) == "SUSPENDED" ]] ; then +if [[ $(kstat state $TESTPOOL) == "SUSPENDED" ]] ; then log_fail "pool suspended" fi diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh index f8dc2b108f0d..14063658e3c5 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh @@ -32,8 +32,7 @@ # 4. Export pool. # 5. Import pool. # 6. Check in zpool iostat if the cache device has space allocated. -# 7. Read the file written in (3) and check if l2_hits in -# /proc/spl/kstat/zfs/arcstats increased. +# 7. Read the file written in (3) and check if arcstats.l2_hits increased. # verify_runnable "global" diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 5071830c489a..8784ec770218 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -199,20 +199,20 @@ function count_skipped_mmp_writes # pool duration { typeset pool=$1 typeset -i duration=$2 - typeset hist_path="/proc/spl/kstat/zfs/$pool/multihost" sleep $duration - awk 'BEGIN {count=0}; $NF == "-" {count++}; END {print count};' "$hist_path" + kstat multihost $pool | \ + awk 'BEGIN {count=0}; $NF == "-" {count++}; END {print count};' } function count_mmp_writes # pool duration { typeset pool=$1 typeset -i duration=$2 - typeset hist_path="/proc/spl/kstat/zfs/$pool/multihost" sleep $duration - awk 'BEGIN {count=0}; $NF != "-" {count++}; END {print count};' "$hist_path" + kstat multihost $pool | \ + awk 'BEGIN {count=0}; $NF != "-" {count++}; END {print count};' } function summarize_uberblock_mmp # device diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh index 1ac254aa1dab..bafa32856800 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh @@ -47,7 +47,6 @@ log_assert "mmp writes are evenly distributed across leaf vdevs" log_onexit cleanup MMP_HISTORY_TMP=$MMP_DIR/history -MMP_HISTORY=/proc/spl/kstat/zfs/$MMP_POOL/multihost # Step 1 log_must mkdir -p $MMP_DIR @@ -69,7 +68,7 @@ typeset -i min_writes=999 typeset -i max_writes=0 typeset -i write_count # copy to get as close to a consistent view as possible -cp $MMP_HISTORY $MMP_HISTORY_TMP +kstat multihost $MMP_POOL > $MMP_HISTORY_TMP for x in {0..7}; do write_count=$(grep -c file.${x} $MMP_HISTORY_TMP) if [ $write_count -lt $min_writes ]; then diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_write_slow_disk.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_write_slow_disk.ksh index 8b118684aa7f..fcbacc8520a5 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_write_slow_disk.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_write_slow_disk.ksh @@ -58,7 +58,7 @@ function cleanup log_assert "A long VDEV probe doesn't cause a MMP check suspend" log_onexit cleanup -MMP_HISTORY_URL=/proc/spl/kstat/zfs/$MMP_POOL/multihost +MMP_HISTORY_TMP=$MMP_DIR/history # Create a multiple drive pool log_must zpool events -c @@ -83,8 +83,9 @@ sleep 10 sync_pool $MMP_POOL # Confirm mmp writes to the non-slow disks have taken place +kstat multihost $MMP_POOL > $MMP_HISTORY_TMP for x in {0,1,2,4}; do - write_count=$(grep -c file.${x} $MMP_HISTORY_URL) + write_count=$(grep -c file.${x} $MMP_HISTORY_TMP) [[ $write_count -gt 0 ]] || log_fail "expecting mmp writes" done diff --git a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh index 40045a7a96b5..efcebda96d6d 100755 --- a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh +++ b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh @@ -42,13 +42,18 @@ function cleanup function unlinked_size_is { + typeset -i expect=$1 + typeset pool=$2 + typeset -i objsetid=$3 + + typeset osstat=$(printf "objset-0x%x" objsetid) + MAX_ITERS=5 # iteration to do before we consider reported number stable iters=0 last_usize=0 while [[ $iters -le $MAX_ITERS ]]; do - kstat_file=$(grep -nrwl /proc/spl/kstat/zfs/$2/objset-0x* -e $3) - nunlinks=$(awk '/nunlinks/ {print $3}' $kstat_file) - nunlinked=$(awk '/nunlinked/ {print $3}' $kstat_file) + nunlinks=$(kstat $osstat.nunlinks $pool) + nunlinked=$(kstat $osstat.nunlinked $pool) usize=$(($nunlinks - $nunlinked)) if [[ $iters == $MAX_ITERS && $usize == $1 ]]; then return 0 @@ -73,6 +78,8 @@ log_onexit cleanup log_assert "Unlinked list drain does not hold up mounting of fs" for fs in 1 2 3; do + typeset -i objsetid=$(get_prop objsetid $TESTPOOL/$TESTFS.$fs) + set -A xattrs on sa off for xa in ${xattrs[@]}; do # setup fs and ensure all deleted files got into unliked set @@ -89,20 +96,20 @@ for fs in 1 2 3; do fi log_must set_tunable32 UNLINK_SUSPEND_PROGRESS 1 - log_must unlinked_size_is 0 $TESTPOOL $TESTPOOL/$TESTFS.$fs + log_must unlinked_size_is 0 $TESTPOOL $objsetid # build up unlinked set for fn in $(seq 1 100); do log_must eval "rm $TESTDIR.$fs/file-$fn &" done - log_must unlinked_size_is 100 $TESTPOOL $TESTPOOL/$TESTFS.$fs + log_must unlinked_size_is 100 $TESTPOOL $objsetid # test that we can mount fs without emptying the unlinked list log_must zfs umount $TESTPOOL/$TESTFS.$fs log_must unmounted $TESTDIR.$fs log_must zfs mount $TESTPOOL/$TESTFS.$fs log_must mounted $TESTDIR.$fs - log_must unlinked_size_is 100 $TESTPOOL $TESTPOOL/$TESTFS.$fs + log_must unlinked_size_is 100 $TESTPOOL $objsetid # confirm we can drain and add to unlinked set at the same time log_must set_tunable32 UNLINK_SUSPEND_PROGRESS 0 @@ -111,7 +118,7 @@ for fs in 1 2 3; do for fn in $(seq 101 175); do log_must eval "rm $TESTDIR.$fs/file-$fn &" done - log_must unlinked_size_is 0 $TESTPOOL $TESTPOOL/$TESTFS.$fs + log_must unlinked_size_is 0 $TESTPOOL $objsetid done done