From 0ea05c64f8d08c20439dd2a06e949a2aa4115101 Mon Sep 17 00:00:00 2001 From: Alek P Date: Thu, 6 Jul 2017 22:16:13 -0700 Subject: Implemented zpool scrub pause/resume Currently, there is no way to pause a scrub. Pausing may be useful when the pool is busy with other I/O to preserve bandwidth. This patch adds the ability to pause and resume scrubbing. This is achieved by maintaining a persistent on-disk scrub state. While the state is 'paused' we do not scrub any more blocks. We do however perform regular scan housekeeping such as freeing async destroyed and deadlist blocks while paused. Reviewed by: Matthew Ahrens Reviewed by: Thomas Caputi Reviewed-by: Serapheim Dimitropoulos Reviewed-by: Brian Behlendorf Signed-off-by: Alek Pinchuk Closes #6167 --- tests/zfs-tests/include/libtest.shlib | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) (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 5d8500ddf..034b36691 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -1999,54 +1999,65 @@ function check_vdev_state # pool disk state{online,offline,unavail} # # Return 0 is contain, 1 otherwise # -function check_pool_status # pool token keyword +function check_pool_status # pool token keyword { typeset pool=$1 typeset token=$2 typeset keyword=$3 + typeset verbose=${4:-false} - zpool status -v "$pool" 2>/dev/null | nawk -v token="$token:" ' - ($1==token) {print $0}' \ - | grep -i "$keyword" > /dev/null 2>&1 + scan=$(zpool status -v "$pool" 2>/dev/null | nawk -v token="$token:" ' + ($1==token) {print $0}') + if [[ $verbose == true ]]; then + log_note $scan + fi + echo $scan | grep -i "$keyword" > /dev/null 2>&1 return $? } # -# These 5 following functions are instance of check_pool_status() +# These 6 following functions are instance of check_pool_status() # is_pool_resilvering - to check if the pool is resilver in progress # is_pool_resilvered - to check if the pool is resilver completed # is_pool_scrubbing - to check if the pool is scrub in progress # is_pool_scrubbed - to check if the pool is scrub completed # is_pool_scrub_stopped - to check if the pool is scrub stopped +# is_pool_scrub_paused - to check if the pool has scrub paused # -function is_pool_resilvering #pool +function is_pool_resilvering #pool +{ + check_pool_status "$1" "scan" "resilver in progress since " $2 + return $? +} + +function is_pool_resilvered #pool { - check_pool_status "$1" "scan" "resilver in progress since " + check_pool_status "$1" "scan" "resilvered " $2 return $? } -function is_pool_resilvered #pool +function is_pool_scrubbing #pool { - check_pool_status "$1" "scan" "resilvered " + check_pool_status "$1" "scan" "scrub in progress since " $2 return $? } -function is_pool_scrubbing #pool +function is_pool_scrubbed #pool { - check_pool_status "$1" "scan" "scrub in progress since " + check_pool_status "$1" "scan" "scrub repaired" $2 return $? } -function is_pool_scrubbed #pool +function is_pool_scrub_stopped #pool { - check_pool_status "$1" "scan" "scrub repaired" + check_pool_status "$1" "scan" "scrub canceled" $2 return $? } -function is_pool_scrub_stopped #pool +function is_pool_scrub_paused #pool { - check_pool_status "$1" "scan" "scrub canceled" + check_pool_status "$1" "scan" "scrub paused since " $2 return $? } -- cgit v1.2.3