aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlaf Faaland <[email protected]>2018-04-04 16:38:44 -0700
committerBrian Behlendorf <[email protected]>2018-04-04 16:38:44 -0700
commit533ea0415bd788530ff894bc0edbc3cea20fbe4c (patch)
tree0bf6082bce3788652a52b3a0ff7e9dba7ba2800d /tests
parent21a4f5cc867b4f166704df84985edc048caa2578 (diff)
Update mmp_delay on sync or skipped, failed write
When an MMP write is skipped, or fails, and time since mts->mmp_last_write is already greater than mts->mmp_delay, increase mts->mmp_delay. The original code only updated mts->mmp_delay when a write succeeded, but this results in the write(s) after delays and failed write(s) reporting an ub_mmp_delay which is too low. Update mmp_last_write and mmp_delay if a txg sync was successful. At least one uberblock was written, thus extending the time we can be sure the pool will not be imported by another host. Do not allow mmp_delay to go below (MSEC2NSEC(zfs_multihost_interval) / vdev_count_leaves()) so that a period of frequent successful MMP writes, e.g. due to frequent txg syncs, does not result in an import activity check so short it is not reliable based on mmp thread writes alone. Remove unnecessary local variable, start. We do not use the start time of the loop iteration. Add a debug message in spa_activity_check() to allow verification of the import_delay value and to prove the activity check occurred. Alter the tests that import pools and attempt to detect an activity check. Calculate the expected duration of spa_activity_check() based on module parameters at the time the import is performed, rather than a fixed time set in mmp.cfg. The fixed time may be wrong. Also, use the default zfs_multihost_interval value so the activity check is longer and easier to recognize. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #7330
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/tests/functional/mmp/mmp.cfg2
-rw-r--r--tests/zfs-tests/tests/functional/mmp/mmp.kshlib26
-rwxr-xr-xtests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh3
3 files changed, 25 insertions, 6 deletions
diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.cfg b/tests/zfs-tests/tests/functional/mmp/mmp.cfg
index 36f995443..52680c275 100644
--- a/tests/zfs-tests/tests/functional/mmp/mmp.cfg
+++ b/tests/zfs-tests/tests/functional/mmp/mmp.cfg
@@ -38,5 +38,3 @@ export MMP_HISTORY_OFF=0
export MMP_INTERVAL_HOUR=$((60*60*1000))
export MMP_INTERVAL_DEFAULT=1000
export MMP_INTERVAL_MIN=100
-
-export ZPOOL_IMPORT_DURATION=9
diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib
index 571affe89..e74f04a5b 100644
--- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib
+++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib
@@ -163,17 +163,32 @@ function mmp_pool_set_hostid # pool hostid
return 0
}
+# Return the number of seconds the activity check portion of the import process
+# will take. Does not include the time to find devices and assemble the
+# preliminary pool configuration passed into the kernel.
+function seconds_mmp_waits_for_activity
+{
+ typeset import_intervals=$(get_tunable zfs_multihost_import_intervals)
+ typeset interval=$(get_tunable zfs_multihost_interval)
+ typeset seconds=$((interval*import_intervals/1000))
+
+ echo $seconds
+}
+
function import_no_activity_check # pool opts
{
typeset pool=$1
typeset opts=$2
+ typeset max_duration=$(seconds_mmp_waits_for_activity)
+
SECONDS=0
zpool import $opts $pool
typeset rc=$?
- if [[ $SECONDS -gt $ZPOOL_IMPORT_DURATION ]]; then
- log_fail "unexpected activity check (${SECONDS}s)"
+ if [[ $SECONDS -gt $max_duration ]]; then
+ log_fail "unexpected activity check (${SECONDS}s gt \
+$max_duration)"
fi
return $rc
@@ -184,12 +199,15 @@ function import_activity_check # pool opts
typeset pool=$1
typeset opts=$2
+ typeset min_duration=$(seconds_mmp_waits_for_activity)
+
SECONDS=0
zpool import $opts $pool
typeset rc=$?
- if [[ $SECONDS -le $ZPOOL_IMPORT_DURATION ]]; then
- log_fail "expected activity check (${SECONDS}s)"
+ if [[ $SECONDS -le $min_duration ]]; then
+ log_fail "expected activity check (${SECONDS}s le \
+$min_duration)"
fi
return $rc
diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh
index 035264fe0..e39c5ab30 100755
--- a/tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh
+++ b/tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh
@@ -103,6 +103,9 @@ MMP_IMPORTED_MSG="pool was previously in use from another system."
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
+# Default interval results in minimum activity test 10s which
+# makes detection of the activity test reliable.
+log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT
log_must import_activity_check $MMP_POOL "-f -d $MMP_DIR"
# 8 Verify pool may be exported/imported without -f argument.