18569Sgziemski#!/bin/ksh -p 212732Sdholmes# 38569Sgziemski# CDDL HEADER START 48569Sgziemski# 58569Sgziemski# This file and its contents are supplied under the terms of the 68569Sgziemski# Common Development and Distribution License ("CDDL"), version 1.0. 78569Sgziemski# You may only use this file in accordance with the terms of version 88569Sgziemski# 1.0 of the CDDL. 98569Sgziemski# 108569Sgziemski# A full copy of the text of the CDDL should have accompanied this 118569Sgziemski# source. A copy of the CDDL is also available via the Internet at 128569Sgziemski# http://www.illumos.org/license/CDDL. 138569Sgziemski# 148569Sgziemski# CDDL HEADER END 158569Sgziemski# 168569Sgziemski 178569Sgziemski# 188569Sgziemski# Copyright (c) 2017 by Lawrence Livermore National Security, LLC. 198569Sgziemski# 208569Sgziemski 218569Sgziemski# DESCRIPTION: 228569Sgziemski# Ensure that MMP updates uberblocks with MMP info at expected intervals. 238569Sgziemski# 248569Sgziemski# STRATEGY: 258569Sgziemski# 1. Set TXG_TIMEOUT to large value 268569Sgziemski# 2. Create a zpool 278569Sgziemski# 3. Clear multihost history 288569Sgziemski# 4. Sleep, then collect count of uberblocks written 298569Sgziemski# 5. If number of changes seen is less than min threshold, then fail 308569Sgziemski# 6. If number of changes seen is more than max threshold, then fail 318569Sgziemski# 7. Sequence number increments when no TXGs are syncing 328569Sgziemski# 338569Sgziemski 348569Sgziemski. $STF_SUITE/include/libtest.shlib 358569Sgziemski. $STF_SUITE/tests/functional/mmp/mmp.cfg 368569Sgziemski. $STF_SUITE/tests/functional/mmp/mmp.kshlib 378839Sgziemski 388569Sgziemskiverify_runnable "both" 398839Sgziemski 408569SgziemskiUBER_CHANGES=0 419173SgziemskiEXPECTED=$(($(echo $DISKS | wc -w) * 10)) 429173SgziemskiFUDGE=$((EXPECTED * 20 / 100)) 439173SgziemskiMIN_UB_WRITES=$((EXPECTED - FUDGE)) 449173SgziemskiMAX_UB_WRITES=$((EXPECTED + FUDGE)) 459173SgziemskiMIN_SEQ_VALUES=7 469173Sgziemski 479173Sgziemskifunction cleanup 4810726Sgziemski{ 4910726Sgziemski default_cleanup_noexit 5010726Sgziemski log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_DEFAULT 5110726Sgziemski set_tunable64 TXG_TIMEOUT $TXG_TIMEOUT_DEFAULT 5210726Sgziemski log_must mmp_clear_hostid 538569Sgziemski} 54 55log_assert "Ensure MMP uberblocks update at the correct interval" 56log_onexit cleanup 57 58log_must set_tunable64 TXG_TIMEOUT $TXG_TIMEOUT_LONG 59log_must mmp_set_hostid $HOSTID1 60 61default_setup_noexit "$DISKS" 62log_must zpool set multihost=on $TESTPOOL 63clear_mmp_history 64UBER_CHANGES=$(count_mmp_writes $TESTPOOL 10) 65 66log_note "Uberblock changed $UBER_CHANGES times" 67 68if [ $UBER_CHANGES -lt $MIN_UB_WRITES ]; then 69 log_fail "Fewer uberblock writes occurred than expected ($EXPECTED)" 70fi 71 72if [ $UBER_CHANGES -gt $MAX_UB_WRITES ]; then 73 log_fail "More uberblock writes occurred than expected ($EXPECTED)" 74fi 75 76log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_MIN 77SEQ_BEFORE=$(zdb -luuuu ${DISK[0]} | awk '/mmp_seq/ {if ($NF>max) max=$NF}; END {print max}') 78sleep 1 79SEQ_AFTER=$(zdb -luuuu ${DISK[0]} | awk '/mmp_seq/ {if ($NF>max) max=$NF}; END {print max}') 80if [ $((SEQ_AFTER - SEQ_BEFORE)) -lt $MIN_SEQ_VALUES ]; then 81 zdb -luuuu ${DISK[0]} 82 log_fail "ERROR: mmp_seq did not increase by $MIN_SEQ_VALUES; before $SEQ_BEFORE after $SEQ_AFTER" 83fi 84 85log_pass "Ensure MMP uberblocks update at the correct interval passed" 86