# STRATEGY:
# 1. Set zfs_txg_timeout to large value
# 2. Create a zpool
-# 3. Find the current "best" uberblock
-# 4. Loop for 10 seconds, increment counter for each change in UB
+# 3. Clear multihost history
+# 4. Sleep, then collect count of uberblocks written
# 5. If number of changes seen is less than min threshold, then fail
# 6. If number of changes seen is more than max threshold, then fail
#
verify_runnable "both"
UBER_CHANGES=0
+EXPECTED=$(($(echo $DISKS | wc -w) * 10))
+FUDGE=$((EXPECTED * 20 / 100))
+MIN=$((EXPECTED - FUDGE))
+MAX=$((EXPECTED + FUDGE))
function cleanup
{
default_cleanup_noexit
set_tunable64 zfs_txg_timeout $TXG_TIMEOUT_DEFAULT
- log_must rm -f $PREV_UBER $CURR_UBER
log_must mmp_clear_hostid
}
log_must set_tunable64 zfs_txg_timeout $TXG_TIMEOUT_LONG
log_must mmp_set_hostid $HOSTID1
-default_setup_noexit $DISK
+default_setup_noexit "$DISKS"
log_must zpool set multihost=on $TESTPOOL
-
-log_must zdb -u $TESTPOOL > $PREV_UBER
-
-SECONDS=0
-while [[ $SECONDS -le 10 ]]; do
- log_must zdb -u $TESTPOOL > $CURR_UBER
- if ! diff -u "$CURR_UBER" "$PREV_UBER"; then
- (( UBER_CHANGES = UBER_CHANGES + 1 ))
- log_must mv "$CURR_UBER" "$PREV_UBER"
- fi
-done
+clear_mmp_history
+UBER_CHANGES=$(count_uberblocks $TESTPOOL 10)
log_note "Uberblock changed $UBER_CHANGES times"
-if [[ $UBER_CHANGES -lt 8 ]]; then
- log_fail "Fewer uberblock writes occured than expected (10)"
+if [ $UBER_CHANGES -lt $MIN ]; then
+ log_fail "Fewer uberblock writes occured than expected ($EXPECTED)"
fi
-if [[ $UBER_CHANGES -gt 12 ]]; then
- log_fail "More uberblock writes occured than expected (10)"
+if [ $UBER_CHANGES -gt $MAX ]; then
+ log_fail "More uberblock writes occured than expected ($EXPECTED)"
fi
log_pass "Ensure MMP uberblocks update at the correct interval passed"