mirror of
https://git.proxmox.com/git/mirror_zfs
synced 2025-04-28 11:40:17 +00:00
ZTS: update existing kstat users to new helper
Removes other custom helpers and direct accesses to /proc. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
parent
198621f910
commit
6edbbe0646
@ -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"
|
||||
|
@ -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<ID>
|
||||
# (linux only)
|
||||
# 10. Obtain dataset name from testpool.objset-0x<objsetID>.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_dataset -N $TESTPOOL/$objset_id dataset_name)
|
||||
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
|
||||
|
@ -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_pool $TESTPOOL txgs
|
||||
log_must zpool events
|
||||
|
||||
# Verify at least 3 deadman events were logged. The first after 5 seconds,
|
||||
|
@ -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_pool $pool iostats.direct_write_count)
|
||||
dio_and_verify write $size $bs $mntpnt "sync"
|
||||
curr_dio_wr=$(get_iostats_stat $pool direct_write_count)
|
||||
curr_dio_wr=$(kstat_pool $pool iostats.direct_write_count)
|
||||
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_pool -g $pool iostats
|
||||
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_pool $pool iostats.arc_write_count)
|
||||
prev_dio_wr=$(kstat_pool $pool iostats.direct_write_count)
|
||||
|
||||
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_pool $pool iostats.arc_write_count)
|
||||
buf_wr_actual=$((curr_buf_wr - prev_buf_wr))
|
||||
|
||||
curr_dio_wr=$(get_iostats_stat $pool direct_write_count)
|
||||
curr_dio_wr=$(kstat_pool $pool iostats.direct_write_count)
|
||||
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_pool -g $pool iostats
|
||||
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_pool -g $pool iostats
|
||||
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_pool $pool iostats.arc_read_count)
|
||||
prev_dio_rd=$(kstat_pool $pool iostats.direct_read_count)
|
||||
|
||||
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_pool $pool iostats.arc_read_count)
|
||||
buf_rd_actual=$((curr_buf_rd - prev_buf_rd))
|
||||
|
||||
curr_dio_rd=$(get_iostats_stat $pool direct_read_count)
|
||||
curr_dio_rd=$(kstat_pool $pool iostats.direct_read_count)
|
||||
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_pool -g $pool iostats
|
||||
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_pool -g $pool iostats
|
||||
log_fail "Direct reads $dio_rd_actual of $dio_rd_expect"
|
||||
fi
|
||||
}
|
||||
|
@ -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_pool $TESTPOOL1 iostats.direct_read_count)
|
||||
prev_arc_rd=$(kstat_pool $TESTPOOL1 iostats.arc_read_count)
|
||||
|
||||
# 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_pool $TESTPOOL1 iostats.direct_read_count)
|
||||
curr_arc_rd=$(kstat_pool $TESTPOOL1 iostats.arc_read_count)
|
||||
total_dio_rd=$((curr_dio_rd - prev_dio_rd))
|
||||
total_arc_rd=$((curr_arc_rd - prev_arc_rd))
|
||||
|
||||
|
@ -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_pool $TESTPOOL iostats.direct_read_count)
|
||||
prev_arc_read=$(kstat_pool $TESTPOOL iostats.arc_read_count)
|
||||
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_pool $TESTPOOL iostats.direct_read_count)
|
||||
curr_arc_read=$(kstat_pool $TESTPOOL iostats.arc_read_count)
|
||||
total_dio_read=$((curr_dio_read - prev_dio_read))
|
||||
total_arc_read=$((curr_arc_read - prev_arc_read))
|
||||
|
||||
|
@ -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_pool $TESTPOOL iostats.direct_write_count)
|
||||
|
||||
# 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_pool $TESTPOOL iostats.direct_write_count)
|
||||
total_dio_wr=$((curr_dio_wr - prev_dio_wr))
|
||||
|
||||
log_note "Making sure we have Direct I/O writes logged"
|
||||
|
@ -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_pool $TESTPOOL iostats.direct_write_count)
|
||||
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_pool $TESTPOOL iostats.direct_write_count)
|
||||
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_pool $TESTPOOL iostats.direct_write_count)
|
||||
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_pool $TESTPOOL iostats.direct_write_count)
|
||||
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_pool $TESTPOOL iostats.direct_write_count)
|
||||
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_pool $TESTPOOL iostats.direct_write_count)
|
||||
total_dio_wr=$((curr_dio_wr - prev_dio_wr))
|
||||
|
||||
log_note "Making sure there are no checksum errors with the ZPool"
|
||||
|
@ -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 ]
|
||||
|
@ -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_pool $TESTPOOL state) == "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_pool $TESTPOOL state)
|
||||
|
||||
# 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_pool $TESTPOOL state) != "SUSPENDED" ]] ; do
|
||||
if ((tries-- == 0)); then
|
||||
log_fail "pool did not resume"
|
||||
fi
|
||||
|
@ -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_pool $TESTPOOL state) == "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_pool $TESTPOOL state) == "SUSPENDED" ]] ; then
|
||||
log_fail "pool suspended"
|
||||
fi
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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_pool $pool multihost | \
|
||||
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_pool $pool multihost | \
|
||||
awk 'BEGIN {count=0}; $NF != "-" {count++}; END {print count};'
|
||||
}
|
||||
|
||||
function summarize_uberblock_mmp # device
|
||||
|
@ -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_pool $MMP_POOL multihost > $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
|
||||
|
@ -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_pool $MMP_POOL multihost > $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
|
||||
|
||||
|
@ -42,13 +42,15 @@ function cleanup
|
||||
|
||||
function unlinked_size_is
|
||||
{
|
||||
typeset -i expect=$1
|
||||
typeset dataset=$2
|
||||
|
||||
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_dataset $dataset nunlinks)
|
||||
nunlinked=$(kstat_dataset $dataset nunlinked)
|
||||
usize=$(($nunlinks - $nunlinked))
|
||||
if [[ $iters == $MAX_ITERS && $usize == $1 ]]; then
|
||||
return 0
|
||||
@ -89,20 +91,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/$TESTFS.$fs
|
||||
|
||||
# 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/$TESTFS.$fs
|
||||
|
||||
# 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/$TESTFS.$fs
|
||||
|
||||
# confirm we can drain and add to unlinked set at the same time
|
||||
log_must set_tunable32 UNLINK_SUSPEND_PROGRESS 0
|
||||
@ -111,7 +113,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/$TESTFS.$fs
|
||||
done
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user