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
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.
18 # Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
22 # Under no circumstances when multihost is active, should an active pool
23 # with one hostid be importable by a host with a different hostid.
26 # 1. Simulate an active pool on another host with ztest.
27 # 2. Verify 'zpool import' reports an active pool.
28 # 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
29 # 4. Kill ztest to make pool eligible for import.
30 # 5. Verify 'zpool import' fails with the expected error message.
31 # 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
32 # 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
33 # 8. Verify pool may be exported/imported without -f argument.
36 .
$STF_SUITE/include
/libtest.shlib
37 .
$STF_SUITE/tests
/functional
/mmp
/mmp.cfg
38 .
$STF_SUITE/tests
/functional
/mmp
/mmp.kshlib
40 verify_runnable
"both"
44 mmp_pool_destroy
$MMP_POOL $MMP_DIR
45 log_must set_tunable64 zfs_multihost_interval
$MMP_INTERVAL_DEFAULT
46 log_must mmp_clear_hostid
49 log_assert
"multihost=on|off active pool activity checks"
52 # 1. Simulate an active pool on another host with ztest.
53 mmp_pool_destroy
$MMP_POOL $MMP_DIR
54 mmp_pool_create
$MMP_POOL $MMP_DIR
56 # 2. Verify 'zpool import' reports an active pool.
57 log_must mmp_set_hostid
$HOSTID2
58 log_must set_tunable64 zfs_multihost_interval
$MMP_INTERVAL_MIN
59 log_must is_pool_imported
$MMP_POOL "-d $MMP_DIR"
61 # 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
62 MMP_IMPORTED_MSG
="Cannot import '$MMP_POOL': pool is imported"
64 log_must try_pool_import
$MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
66 log_must try_pool_import
$MMP_POOL "-f -d $MMP_DIR" "$MMP_IMPORTED_MSG"
69 log_must try_pool_import
$MMP_POOL "-c ${MMP_CACHE}.stale" "$MMP_IMPORTED_MSG"
72 log_must try_pool_import
$MMP_POOL "-f -c ${MMP_CACHE}.stale" \
76 # 4. Kill ztest to make pool eligible for import. Poll with 'zpool status'.
77 ZTESTPID
=$
(pgrep ztest
)
78 if [ -n "$ZTESTPID" ]; then
79 log_must
kill -9 $ZTESTPID
81 log_must wait_pool_imported
$MMP_POOL "-d $MMP_DIR"
83 # 5. Verify 'zpool import' fails with the expected error message, when
84 # - hostid=0: - configuration error
85 # - hostid=matches - safe to import the pool
86 # - hostid=different - previously imported on a different system
88 log_must mmp_clear_hostid
89 MMP_IMPORTED_MSG
="Set a unique system hostid"
90 log_must check_pool_import
$MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
92 log_must mmp_set_hostid
$HOSTID1
93 MMP_IMPORTED_MSG
="The pool can be imported"
94 log_must check_pool_import
$MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
96 log_must mmp_clear_hostid
97 log_must mmp_set_hostid
$HOSTID2
98 MMP_IMPORTED_MSG
="The pool was last accessed by another system."
99 log_must check_pool_import
$MMP_POOL "-d $MMP_DIR" "status" "$MMP_IMPORTED_MSG"
101 # 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
102 MMP_IMPORTED_MSG
="pool was previously in use from another system."
103 log_must try_pool_import
$MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
105 # 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
106 # Default interval results in minimum activity test 10s which
107 # makes detection of the activity test reliable.
108 log_must set_tunable64 zfs_multihost_interval
$MMP_INTERVAL_DEFAULT
109 log_must import_activity_check
$MMP_POOL "-f -d $MMP_DIR"
111 # 8 Verify pool may be exported/imported without -f argument.
112 log_must zpool
export $MMP_POOL
113 log_must import_no_activity_check
$MMP_POOL "-d $MMP_DIR"
115 log_pass
"multihost=on|off active pool activity checks passed"