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# Verify import behavior for inactive, but not exported, pools 24# 25# STRATEGY: 26# 1. Create a zpool 27# 2. Verify multihost=off and hostids match (no activity check) 28# 3. Verify multihost=off and hostids differ (no activity check) 29# 4. Verify multihost=off and hostid allowed (no activity check) 30# 5. Verify multihost=on and hostids match (no activity check) 31# 6. Verify multihost=on and hostids differ (activity check) 32# 7. Verify mmp_write and mmp_fail are set correctly 33# 8. Verify multihost=on and hostid zero fails (no activity check) 34# 9. Verify activity check duration based on mmp_write and mmp_fail 35# 36 37. $STF_SUITE/include/libtest.shlib 38. $STF_SUITE/tests/functional/mmp/mmp.cfg 39. $STF_SUITE/tests/functional/mmp/mmp.kshlib 40 41verify_runnable "both" 42 43function cleanup 44{ 45 default_cleanup_noexit 46 log_must mmp_clear_hostid 47 log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT 48} 49 50log_assert "multihost=on|off inactive pool activity checks" 51log_onexit cleanup 52 53# 1. Create a zpool 54log_must mmp_set_hostid $HOSTID1 55default_setup_noexit $DISK 56 57# 2. Verify multihost=off and hostids match (no activity check) 58log_must zpool set multihost=off $TESTPOOL 59 60for opt in "" "-f"; do 61 log_must zpool export -F $TESTPOOL 62 log_must import_no_activity_check $TESTPOOL $opt 63done 64 65# 3. Verify multihost=off and hostids differ (no activity check) 66log_must zpool export -F $TESTPOOL 67log_must mmp_clear_hostid 68log_must mmp_set_hostid $HOSTID2 69log_mustnot import_no_activity_check $TESTPOOL "" 70log_must import_no_activity_check $TESTPOOL "-f" 71 72# 4. Verify multihost=off and hostid zero allowed (no activity check) 73log_must zpool export -F $TESTPOOL 74log_must mmp_clear_hostid 75log_mustnot import_no_activity_check $TESTPOOL "" 76log_must import_no_activity_check $TESTPOOL "-f" 77 78# 5. Verify multihost=on and hostids match (no activity check) 79log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1 80log_must zpool set multihost=on $TESTPOOL 81 82for opt in "" "-f"; do 83 log_must zpool export -F $TESTPOOL 84 log_must import_no_activity_check $TESTPOOL $opt 85done 86 87# 6. Verify multihost=on and hostids differ (activity check) 88log_must zpool export -F $TESTPOOL 89log_must mmp_clear_hostid 90log_must mmp_set_hostid $HOSTID2 91log_mustnot import_activity_check $TESTPOOL "" 92log_must import_activity_check $TESTPOOL "-f" 93 94# 7. Verify mmp_write and mmp_fail are set correctly 95log_must zpool export -F $TESTPOOL 96log_must verify_mmp_write_fail_present ${DISK[0]} 97 98# 8. Verify multihost=on and hostid zero fails (no activity check) 99log_must mmp_clear_hostid 100case "$(uname)" in 101Linux) MMP_IMPORTED_MSG="Set a unique system hostid";; 102SunOS) MMP_IMPORTED_MSG="Check the SMF svc:/system/hostid service.";; 103esac 104log_must check_pool_import $TESTPOOL "-f" "action" "$MMP_IMPORTED_MSG" 105log_mustnot import_no_activity_check $TESTPOOL "-f" 106 107# 9. Verify activity check duration based on mmp_write and mmp_fail 108# Specify a short test via tunables but import pool imported while 109# tunables set to default duration. 110log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_MIN 111log_must mmp_clear_hostid 112log_must mmp_set_hostid $HOSTID1 113log_must import_activity_check $TESTPOOL "-f" $MMP_TEST_DURATION_DEFAULT 114 115log_pass "multihost=on|off inactive pool activity checks passed" 116