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
@@ -22,6 +22,7 @@
#
# Copyright (c) 2013 by Jinshan Xiong. No rights reserved.
# Copyright (c) 2017 Datto Inc.
#
. $STF_SUITE/include/libtest.shlib
@@ -71,7 +72,7 @@ zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" ||
# Create a file in fs1 should trigger dataset upgrade
log_must mkfile 1m $TESTDIR/fs1/tf
sync_pool
log_must sleep 1 # upgrade done in the background so let's give it a sec
# Make sure userobj accounting is working for fs1
zfs userspace -o objused -H $TESTPOOL/fs1 | head -n 1 | grep -q "-" &&
@@ -79,7 +80,7 @@ zfs userspace -o objused -H $TESTPOOL/fs1 | head -n 1 | grep -q "-" &&
# Mount a dataset should trigger upgrade
log_must zfs mount $TESTPOOL/fs2
sync_pool
log_must sleep 1 # upgrade done in the background so let's give it a sec
# Make sure userobj accounting is working for fs2
zfs userspace -o objused -H $TESTPOOL/fs2 | head -n 1 | grep -q "-" &&
@@ -91,6 +92,7 @@ zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" ||
log_fail "userobj accounting should be disabled for $TESTPOOL"
# Manual upgrade root dataset
# uses an ioctl which will wait for the upgrade to be done before returning
log_must zfs set version=current $TESTPOOL
zfs userspace -o objused -H $TESTPOOL | head -n 1 | grep -q "-" &&
log_fail "userobj accounting should be enabled for $TESTPOOL"