Implemented zpool sync command

This addition will enable us to sync an open TXG to the main pool
on demand. The functionality is similar to 'sync(2)' but 'zpool sync'
will return when data has hit the main storage instead of potentially
just the ZIL as is the case with the 'sync(2)' cmd.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Alek Pinchuk <apinchuk@datto.com>
Closes #6122
This commit is contained in:
Alek P
2017-05-19 12:33:11 -07:00
committed by Brian Behlendorf
parent 4a283c7f77
commit bec1067d54
20 changed files with 396 additions and 69 deletions
+11 -16
View File
@@ -26,6 +26,7 @@
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Copyright 2016 Nexenta Systems, Inc.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
# Copyright (c) 2017 Datto Inc.
#
. ${STF_TOOLS}/include/logapi.shlib
@@ -3203,29 +3204,23 @@ function get_objnum
}
#
# Synchronize all the data in pool
# Sync data to the pool
#
# $1 pool name
# $2 boolean to force uberblock (and config including zpool cache file) update
#
function sync_pool #pool
function sync_pool #pool <force>
{
typeset pool=${1:-$TESTPOOL}
typeset force=${2:-false}
log_must $SYNC
log_must sleep 2
# Flush all the pool data.
typeset -i ret
zpool scrub $pool >/dev/null 2>&1
ret=$?
(( $ret != 0 )) && \
log_fail "zpool scrub $pool failed."
if [[ $force == true ]]; then
log_must zpool sync -f $pool
else
log_must zpool sync $pool
fi
while ! is_pool_scrubbed $pool; do
if is_pool_resilvered $pool ; then
log_fail "$pool should not be resilver completed."
fi
log_must sleep 2
done
return 0
}
#