1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2017 by Lawrence Livermore National Security, LLC. 19# Copyright 2019 Joyent, Inc. 20# 21 22# DESCRIPTION: 23# Ensure that MMP updates uberblocks at the expected intervals. 24# 25# STRATEGY: 26# 1. Set zfs_txg_timeout to large value 27# 2. Create a zpool 28# 3. Clear multihost history 29# 4. Sleep, then collect count of uberblocks written 30# 5. If number of changes seen is less than min threshold, then fail 31# 6. If number of changes seen is more than max threshold, then fail 32# 33 34. $STF_SUITE/include/libtest.shlib 35. $STF_SUITE/tests/functional/mmp/mmp.cfg 36. $STF_SUITE/tests/functional/mmp/mmp.kshlib 37 38verify_runnable "both" 39 40UBER_CHANGES=0 41EXPECTED=$(($(echo $DISKS | wc -w) * 10)) 42FUDGE=$((EXPECTED * 20 / 100)) 43MIN=$((EXPECTED - FUDGE)) 44MAX=$((EXPECTED + FUDGE)) 45 46function cleanup 47{ 48 default_cleanup_noexit 49 set_tunable32 zfs_txg_timeout $TXG_TIMEOUT_DEFAULT 50 log_must mmp_clear_hostid 51} 52 53log_assert "Ensure MMP uberblocks update at the correct interval" 54log_onexit cleanup 55 56log_must set_tunable32 zfs_txg_timeout $TXG_TIMEOUT_LONG 57log_must mmp_set_hostid $HOSTID1 58 59default_setup_noexit "$DISKS" 60log_must zpool set multihost=on $TESTPOOL 61clear_mmp_history 62UBER_CHANGES=$(count_mmp_writes $TESTPOOL 10) 63 64log_note "Uberblock changed $UBER_CHANGES times" 65 66if [ $UBER_CHANGES -lt $MIN ]; then 67 log_fail "Fewer uberblock writes occured than expected ($EXPECTED)" 68fi 69 70if [ $UBER_CHANGES -gt $MAX ]; then 71 log_fail "More uberblock writes occured than expected ($EXPECTED)" 72fi 73 74log_pass "Ensure MMP uberblocks update at the correct interval passed" 75