diff options
author | Giuseppe Di Natale <[email protected]> | 2017-07-31 16:54:34 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-07-31 16:54:34 -0700 |
commit | af0f842883ceb7e88b8f4d1fe6ad80b6ad951827 (patch) | |
tree | 434cc79faa3c04c2468062e1a4a74cd5af024e73 /tests/zfs-tests | |
parent | c7a7601c08d3f7db42dfca46e0ad8aa287df43da (diff) |
mmp_on_uberblocks: Use kstat for uberblock counts
Use kstat to get a more accurate count of uberblock updates.
Using a loop with zdb can potentially miss some uberblocks.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Giuseppe Di Natale <[email protected]>
Closes #6407
Closes #6419
Diffstat (limited to 'tests/zfs-tests')
4 files changed, 35 insertions, 30 deletions
diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index ffe26dfde..43e4f3711 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -182,3 +182,19 @@ function import_activity_check # pool opts return $rc } + +function clear_mmp_history +{ + log_must set_tunable64 zfs_multihost_history $MMP_HISTORY_OFF + log_must set_tunable64 zfs_multihost_history $MMP_HISTORY +} + +function count_uberblocks # pool duration +{ + typeset pool=$1 + typeset -i duration=$2 + typeset hist_path="/proc/spl/kstat/zfs/$pool/multihost" + + log_must sleep $duration + echo $(cat "$hist_path" | sed '1,2d' | wc -l) +} diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_on_uberblocks.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_on_uberblocks.ksh index 2e21e2fef..df4ab888b 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_on_uberblocks.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_on_uberblocks.ksh @@ -24,8 +24,8 @@ # 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 # @@ -37,12 +37,15 @@ 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 } @@ -52,28 +55,19 @@ log_onexit cleanup 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" diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_reset_interval.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_reset_interval.ksh index ee408a849..e98b16218 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_reset_interval.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_reset_interval.ksh @@ -53,14 +53,11 @@ log_must mmp_set_hostid $HOSTID1 default_setup_noexit $DISK log_must zpool set multihost=on $TESTPOOL -prev_count=$(wc -l /proc/spl/kstat/zfs/$TESTPOOL/multihost | cut -f1 -d' ') +clear_mmp_history log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT +uber_count=$(count_uberblocks $TESTPOOL 1) -# slight delay to allow time for the mmp write to complete -sleep 1 -curr_count=$(wc -l /proc/spl/kstat/zfs/$TESTPOOL/multihost | cut -f1 -d' ') - -if [ $curr_count -eq $prev_count ]; then +if [ $uber_count -eq 0 ]; then log_fail "mmp writes did not start when zfs_multihost_interval reduced" fi diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_write_uberblocks.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_write_uberblocks.ksh index 4a13dfa2c..71b5c391b 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_write_uberblocks.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_write_uberblocks.ksh @@ -48,12 +48,10 @@ log_must mmp_set_hostid $HOSTID1 default_mirror_setup_noexit $DISKS log_must zpool set multihost=on $TESTPOOL log_must zinject -d ${DISK[0]} -e io -T write -f 50 $TESTPOOL -L uber +clear_mmp_history +uber_count=$(count_uberblocks $TESTPOOL 3) -prev_count=$(wc -l /proc/spl/kstat/zfs/$TESTPOOL/multihost | cut -f1 -d' ') -log_must sleep 3 -curr_count=$(wc -l /proc/spl/kstat/zfs/$TESTPOOL/multihost | cut -f1 -d' ') - -if [ $curr_count -eq $prev_count ]; then +if [ $uber_count -eq 0 ]; then log_fail "mmp writes did not occur when uberblock IO errors injected" fi |