From a76e4e676180acad9e12f5a1e03f5ff48ec85983 Mon Sep 17 00:00:00 2001 From: George Amanakis Date: Mon, 5 Oct 2020 18:29:05 -0400 Subject: Make L2ARC tests more robust Instead of relying on arbitrary timers after pool export/import or cache device off/online rely on arcstats. This makes the L2ARC tests more robust. Also cleanup some functions related to persistent L2ARC. Reviewed-by: Brian Behlendorf Reviewed-by: Adam Moss Signed-off-by: George Amanakis Closes #10983 --- tests/zfs-tests/include/libtest.shlib | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/zfs-tests/include/libtest.shlib') diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 1618c92bd..9898bada9 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -4173,6 +4173,45 @@ function get_arcstat # stat esac } +# +# Wait for the specified arcstat to reach non-zero quiescence. +# If echo is 1 echo the value after reaching quiescence, otherwise +# if echo is 0 print the arcstat we are waiting on. +# +function arcstat_quiescence # stat echo +{ + typeset stat=$1 + typeset echo=$2 + typeset do_once=true + + if [[ $echo -eq 0 ]]; then + echo "Waiting for arcstat $1 quiescence." + fi + + while $do_once || [ $stat1 -ne $stat2 ] || [ $stat2 -eq 0 ]; do + typeset stat1=$(get_arcstat $stat) + sleep 2 + typeset stat2=$(get_arcstat $stat) + do_once=false + done + + if [[ $echo -eq 1 ]]; then + echo $stat2 + fi +} + +function arcstat_quiescence_noecho # stat +{ + typeset stat=$1 + arcstat_quiescence $stat 0 +} + +function arcstat_quiescence_echo # stat +{ + typeset stat=$1 + arcstat_quiescence $stat 1 +} + # # Given an array of pids, wait until all processes # have completed and check their return status. -- cgit v1.2.3