Skip to content

Commit 2c4345e

Browse files
committed
ZTS: update the relevant mmp test cases
- mmp_exported_import: an activity check is now required for pools which were cleanly exported if the system and pool hostids don't match. - mmp_inactive_import: an activity check is now required for any pool which wasn't cleanly exported, even if the system and pool hostids match. - mmp_on_uberblocks: updated expected uberblocks to take in to account the value MMP_INTERVAL_DEFAULT is set too. - mmp_reset_interval: reduce the number of iterations from 10 to 3. This is sufficient to verify functionality and significantly speeds up the test. - mmp_on_uberblocks: reduce threshold from 7 to 6 to avoid false positives observed in CI on ubuntu 22.04. - Update tests to use 'zhack action idle' instead of ztest to improve the reliability of the tests. - Add additional log_note messages to test cases which have multiple verification steps to make it clear which portion of a test failed when reviewing the logs. - Replace default_setup/cleanup_noexit calls with 'zpool create' and 'zpool destroy' calls to avoid additional unnecessary dataset creation work. - Update activity/noactivity check helper functions to use the ZFS_LOAD_INFO_DEBUG information now available from 'zpool import' to determine if this activity check ran and why. This is more reliable in the CI than measuring the runtime. - Set MMP_INTERVAL_DEFAULT=500 by default to reduce the total runtime. - Removed all mmp tests from the zts-report.py exceptions list. - Enabled MMP tests to run on FreeBSD. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
1 parent 885beba commit 2c4345e

20 files changed

+106
-75
lines changed

module/zfs/spa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,8 +4100,8 @@ spa_activity_check_tryimport(spa_t *spa, uberblock_t *spa_ub,
41004100
hrtime_t extra_delay = MMP_IMPORT_VERIFY_ITERS *
41014101
MSEC2NSEC(MMP_INTERVAL_VALID(spa_ub) ?
41024102
MMP_INTERVAL(spa_ub) : MMP_MIN_INTERVAL);
4103-
cmn_err(CE_NOTE, "pool '%s' multihost activity check "
4104-
"required, %llu seconds remaining", spa_load_name(spa),
4103+
cmn_err(CE_NOTE, "pool '%s' activity check required, "
4104+
"%llu seconds remaining", spa_load_name(spa),
41054105
(u_longlong_t)MAX(NSEC2SEC(import_delay + extra_delay), 1));
41064106
spa_import_progress_set_notes(spa, "Checking MMP activity, "
41074107
"waiting %llu ms", (u_longlong_t)NSEC2MSEC(import_delay));

tests/runfiles/common.run

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,14 @@ tests = ['mmap_mixed', 'mmap_read_001_pos', 'mmap_seek_001_pos',
824824
'mmap_sync_001_pos', 'mmap_write_001_pos', 'mmap_ftruncate']
825825
tags = ['functional', 'mmap']
826826

827+
[tests/functional/mmp]
828+
tests = ['mmp_on_thread', 'mmp_on_uberblocks', 'mmp_on_off', 'mmp_interval',
829+
'mmp_active_import', 'mmp_inactive_import', 'mmp_exported_import',
830+
'mmp_write_uberblocks', 'mmp_reset_interval', 'multihost_history',
831+
'mmp_on_zdb', 'mmp_write_distribution', 'mmp_hostid', 'mmp_write_slow_disk']
832+
tags = ['functional', 'mmp']
833+
timeout = 1200
834+
827835
[tests/functional/mount]
828836
tests = ['umount_001', 'umountall_001']
829837
tags = ['functional', 'mount']

tests/runfiles/linux.run

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ tags = ['functional', 'luks']
155155
tests = ['mmap_libaio_001_pos', 'mmap_sync_001_pos']
156156
tags = ['functional', 'mmap']
157157

158-
[tests/functional/mmp:Linux]
159-
tests = ['mmp_on_thread', 'mmp_on_uberblocks', 'mmp_on_off', 'mmp_interval',
160-
'mmp_active_import', 'mmp_inactive_import', 'mmp_exported_import',
161-
'mmp_write_uberblocks', 'mmp_reset_interval', 'multihost_history',
162-
'mmp_on_zdb', 'mmp_write_distribution', 'mmp_hostid', 'mmp_write_slow_disk']
163-
tags = ['functional', 'mmp']
164-
165158
[tests/functional/mount:Linux]
166159
tests = ['umount_unlinked_drain', 'mount_loopback']
167160
tags = ['functional', 'mount']

tests/test-runner/bin/zts-report.py.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ maybe = {
247247
'l2arc/persist_l2arc_005_pos': ['FAIL', known_reason],
248248
'largest_pool/largest_pool_001_pos': ['FAIL', known_reason],
249249
'mmap/mmap_sync_001_pos': ['FAIL', known_reason],
250-
'mmp/mmp_on_uberblocks': ['FAIL', known_reason],
251250
'pam/setup': ['SKIP', "pamtester might be not available"],
252251
'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946],
253252
'projectquota/setup': ['SKIP', exec_reason],
@@ -366,9 +365,6 @@ elif sys.platform.startswith('linux'):
366365
'io/io_uring': ['SKIP', 'io_uring support required'],
367366
'limits/filesystem_limit': ['SKIP', known_reason],
368367
'limits/snapshot_limit': ['SKIP', known_reason],
369-
'mmp/mmp_active_import': ['FAIL', known_reason],
370-
'mmp/mmp_exported_import': ['FAIL', known_reason],
371-
'mmp/mmp_inactive_import': ['FAIL', known_reason],
372368
'stat/statx_dioalign': ['SKIP', 'statx_reason'],
373369
})
374370

tests/zfs-tests/tests/functional/mmp/cleanup.ksh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
verify_runnable "global"
2626

27+
if [ -e $HOSTID_FILE.save ]; then
28+
mv -f ${HOSTID_FILE}.save $HOSTID_FILE
29+
fi
30+
2731
log_must set_tunable64 MULTIHOST_HISTORY $MMP_HISTORY_OFF
2832

2933
log_pass "mmp cleanup passed"

tests/zfs-tests/tests/functional/mmp/mmp.cfg

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ export TXG_TIMEOUT_DEFAULT=5
3232
export MMP_POOL=mmppool
3333
export MMP_DIR=$TEST_BASE_DIR/mmp
3434
export MMP_CACHE=$MMP_DIR/zpool.cache
35-
export MMP_ZTEST_LOG=$MMP_DIR/ztest.log
35+
export MMP_ZTEST_LOG=$MMP_DIR/zhack.log
3636
export MMP_HISTORY=100
3737
export MMP_HISTORY_OFF=0
3838

3939
export MMP_INTERVAL_HOUR=$((60*60*1000))
40-
export MMP_INTERVAL_DEFAULT=1000
40+
export MMP_INTERVAL_DEFAULT=500
4141
export MMP_INTERVAL_MIN=100
4242

4343
export MMP_IMPORT_INTERVALS=20
4444
export MMP_FAIL_INTERVALS_DEFAULT=10
4545
export MMP_FAIL_INTERVALS_MIN=2
46-
47-
export MMP_TEST_DURATION_DEFAULT=$((MMP_IMPORT_INTERVALS*MMP_INTERVAL_DEFAULT/1000))

tests/zfs-tests/tests/functional/mmp/mmp.kshlib

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function mmp_pool_create_simple # pool dir
9999
log_must zpool set multihost=on $pool
100100
}
101101

102-
function mmp_pool_create # pool dir
102+
function mmp_pool_create_zhack # pool dir
103103
{
104104
typeset pool=${1:-$MMP_POOL}
105105
typeset dir=${2:-$MMP_DIR}
106-
typeset opts="-VVVVV -T120 -M -k0 -f $dir -E -p $pool"
106+
typeset opts="-d $dir action idle -t120 $pool"
107107

108108
mmp_pool_create_simple $pool $dir
109109

@@ -112,11 +112,11 @@ function mmp_pool_create # pool dir
112112
log_must mmp_clear_hostid
113113
log_must mmp_set_hostid $HOSTID2
114114

115-
log_note "Starting ztest in the background as hostid $HOSTID1"
116-
log_must eval "ZFS_HOSTID=$HOSTID1 ztest $opts >$MMP_ZTEST_LOG 2>&1 &"
115+
log_note "Starting zhack in the background as hostid $HOSTID1"
116+
log_must eval "ZFS_HOSTID=$HOSTID1 zhack $opts >$MMP_ZTEST_LOG 2>&1 &"
117117

118118
while ! is_pool_imported "$pool" "-d $dir"; do
119-
log_must pgrep ztest
119+
log_must pgrep zhack
120120
log_must sleep 5
121121
done
122122
}
@@ -126,7 +126,7 @@ function mmp_pool_destroy # pool dir
126126
typeset pool=${1:-$MMP_POOL}
127127
typeset dir=${2:-$MMP_DIR}
128128

129-
ZTESTPID=$(pgrep ztest)
129+
ZTESTPID=$(pgrep zhack)
130130
if [ -n "$ZTESTPID" ]; then
131131
log_must kill $ZTESTPID
132132
wait $ZTESTPID
@@ -158,33 +158,34 @@ function import_no_activity_check # pool opts
158158
typeset pool=$1
159159
typeset opts=$2
160160

161-
typeset max_duration=$((MMP_TEST_DURATION_DEFAULT-1))
162-
163-
SECONDS=0
164-
zpool import $opts $pool
161+
RESULT=$(ZFS_LOAD_INFO_DEBUG=1 zpool import $opts $pool)
165162
typeset rc=$?
166163

167-
if [[ $SECONDS -gt $max_duration ]]; then
168-
log_fail "ERROR: import_no_activity_check unexpected activity \
169-
check (${SECONDS}s gt $max_duration)"
164+
# mmp_result: 3 (ESRCH) no activity check was run not required
165+
# mmp_result: 6 (ENXIO) no activity check was run hostid not set
166+
if ! echo "$RESULT" | grep -q "mmp_result: 3" &&
167+
! echo "$RESULT" | grep -q "mmp_result: 6"; then
168+
log_note "ERROR: $RESULT"
169+
log_fail "ERROR: import_no_activity_check unexpected activity check"
170170
fi
171171

172172
return $rc
173173
}
174174

175-
function import_activity_check # pool opts act_test_duration
175+
function import_activity_check # pool opts
176176
{
177177
typeset pool=$1
178178
typeset opts=$2
179-
typeset min_duration=${3:-$MMP_TEST_DURATION_DEFAULT}
180179

181-
SECONDS=0
182-
zpool import $opts $pool
180+
RESULT=$(ZFS_LOAD_INFO_DEBUG=1 zpool import $opts $pool)
183181
typeset rc=$?
184182

185-
if [[ $SECONDS -le $min_duration ]]; then
186-
log_fail "ERROR: import_activity_check expected activity check \
187-
(${SECONDS}s le min_duration $min_duration)"
183+
# mmp_result: 0 (Success) check was run no activity detected
184+
# mmp_result: 121 (EREMOTEIO) check was run activity detected
185+
# mmp_result: 4 (EINTR) check was run but interrupted by user
186+
if ! echo "$RESULT" | grep -q "mmp_result: 0"; then
187+
log_note "ERROR: $RESULT"
188+
log_fail "ERROR: import_activity_check expected activity check"
188189
fi
189190

190191
return $rc

tests/zfs-tests/tests/functional/mmp/mmp_active_import.ksh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
# with one hostid be importable by a host with a different hostid.
2525
#
2626
# STRATEGY:
27-
# 1. Simulate an active pool on another host with ztest.
27+
# 1. Simulate an active pool on another host with zhack.
2828
# 2. Verify 'zpool import' reports an active pool.
2929
# 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
30-
# 4. Kill ztest to make pool eligible for import.
30+
# 4. Kill zhack to make pool eligible for import.
3131
# 5. Verify 'zpool import' fails with the expected error message.
3232
# 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
3333
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
@@ -44,15 +44,15 @@ function cleanup
4444
{
4545
mmp_pool_destroy $MMP_POOL $MMP_DIR
4646
log_must mmp_clear_hostid
47-
ZTESTPID=$(pgrep ztest)
47+
ZTESTPID=$(pgrep zhack)
4848
if [ -n "$ZTESTPID" ]; then
4949
for pid in $ZTESTPID; do
5050
log_must kill -9 $pid
5151
done
5252
else
53-
# if ztest not running and log present, ztest crashed
53+
# if zhack is not running and log present, zhack crashed
5454
if [ -f $MMP_ZTEST_LOG ]; then
55-
log_note "ztest appears to have crashed. Tail of log:"
55+
log_note "zhack appears to have crashed. Tail of log:"
5656
tail -n 50 $MMP_ZTEST_LOG
5757
fi
5858
fi
@@ -61,15 +61,18 @@ function cleanup
6161
log_assert "multihost=on|off active pool activity checks"
6262
log_onexit cleanup
6363

64-
# 1. Simulate an active pool on another host with ztest.
64+
# 1. Simulate an active pool on another host with zhack.
65+
log_note "Simulate an active pool on another host with zhack"
6566
mmp_pool_destroy $MMP_POOL $MMP_DIR
66-
mmp_pool_create $MMP_POOL $MMP_DIR
67+
mmp_pool_create_zhack $MMP_POOL $MMP_DIR
6768

6869
# 2. Verify 'zpool import' reports an active pool.
70+
log_note "Verify 'zpool import' reports an active pool"
6971
log_must mmp_set_hostid $HOSTID2
7072
log_must is_pool_imported $MMP_POOL "-d $MMP_DIR"
7173

7274
# 3. Verify 'zpool import [-f] $MMP_POOL' cannot import the pool.
75+
log_note "Verify 'zpool import [-f] $MMP_POOL' cannot import the pool"
7376
MMP_IMPORTED_MSG="Cannot import '$MMP_POOL': pool is imported"
7477

7578
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
@@ -84,8 +87,9 @@ for i in {1..10}; do
8487
"$MMP_IMPORTED_MSG"
8588
done
8689

87-
# 4. Kill ztest to make pool eligible for import. Poll with 'zpool status'.
88-
ZTESTPID=$(pgrep ztest)
90+
# 4. Kill zhack to make pool eligible for import. Poll with 'zpool status'.
91+
log_note "Kill zhack to make pool eligible for import. Poll with 'zpool status'"
92+
ZTESTPID=$(pgrep zhack)
8993
if [ -n "$ZTESTPID" ]; then
9094
log_must kill -9 $ZTESTPID
9195
fi
@@ -99,6 +103,7 @@ fi
99103
# - hostid=matches - safe to import the pool
100104
# - hostid=different - previously imported on a different system
101105
#
106+
log_note "Verify 'zpool import' fails with the expected error message"
102107
log_must mmp_clear_hostid
103108
MMP_IMPORTED_MSG="Set a unique system hostid"
104109
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "action" "$MMP_IMPORTED_MSG"
@@ -113,13 +118,16 @@ MMP_IMPORTED_MSG="The pool was last accessed by another system."
113118
log_must check_pool_import $MMP_POOL "-d $MMP_DIR" "status" "$MMP_IMPORTED_MSG"
114119

115120
# 6. Verify 'zpool import $MMP_POOL' fails with the expected message.
121+
log_note "Verify 'zpool import $MMP_POOL' fails with the expected message"
116122
MMP_IMPORTED_MSG="pool was previously in use from another system."
117123
log_must try_pool_import $MMP_POOL "-d $MMP_DIR" "$MMP_IMPORTED_MSG"
118124

119125
# 7. Verify 'zpool import -f $MMP_POOL' can now import the pool.
126+
log_note "Verify 'zpool import -f $MMP_POOL' can now import the pool"
120127
log_must import_activity_check $MMP_POOL "-f -d $MMP_DIR"
121128

122129
# 8 Verify pool may be exported/imported without -f argument.
130+
log_note "Verify pool may be exported/imported without -f argument"
123131
log_must zpool export $MMP_POOL
124132
log_must import_no_activity_check $MMP_POOL "-d $MMP_DIR"
125133

tests/zfs-tests/tests/functional/mmp/mmp_exported_import.ksh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# 3. Verify multihost=off and hostids differ (no activity check)
2929
# 4. Verify multihost=off and hostid zero allowed (no activity check)
3030
# 5. Verify multihost=on and hostids match (no activity check)
31-
# 6. Verify multihost=on and hostids differ (no activity check)
31+
# 6. Verify multihost=on and hostids differ (activity check)
3232
# 7. Verify multihost=on and hostid zero fails (no activity check)
3333
#
3434

@@ -40,7 +40,7 @@ verify_runnable "both"
4040

4141
function cleanup
4242
{
43-
default_cleanup_noexit
43+
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
4444
log_must mmp_clear_hostid
4545
}
4646

@@ -49,9 +49,10 @@ log_onexit cleanup
4949

5050
# 1. Create a zpool
5151
log_must mmp_set_hostid $HOSTID1
52-
default_setup_noexit $DISK
52+
log_must zpool create -f $TESTPOOL $DISK
5353

5454
# 2. Verify multihost=off and hostids match (no activity check)
55+
log_note "Verify multihost=off and hostids match (no activity check)"
5556
log_must zpool set multihost=off $TESTPOOL
5657

5758
for opt in "" "-f"; do
@@ -60,6 +61,7 @@ for opt in "" "-f"; do
6061
done
6162

6263
# 3. Verify multihost=off and hostids differ (no activity check)
64+
log_note "Verify multihost=off and hostids differ (no activity check)"
6365
for opt in "" "-f"; do
6466
log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
6567
log_must zpool export $TESTPOOL
@@ -69,6 +71,7 @@ for opt in "" "-f"; do
6971
done
7072

7173
# 4. Verify multihost=off and hostid zero allowed (no activity check)
74+
log_note "Verify multihost=off and hostid zero allowed (no activity check)"
7275
log_must mmp_clear_hostid
7376

7477
for opt in "" "-f"; do
@@ -77,6 +80,7 @@ for opt in "" "-f"; do
7780
done
7881

7982
# 5. Verify multihost=on and hostids match (no activity check)
83+
log_note "Verify multihost=on and hostids match (no activity check)"
8084
log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
8185
log_must zpool set multihost=on $TESTPOOL
8286

@@ -85,16 +89,18 @@ for opt in "" "-f"; do
8589
log_must import_no_activity_check $TESTPOOL $opt
8690
done
8791

88-
# 6. Verify multihost=on and hostids differ (no activity check)
92+
# 6. Verify multihost=on and hostids differ (activity check)
93+
log_note "Verify multihost=on and hostids differ (activity check)"
8994
for opt in "" "-f"; do
9095
log_must mmp_pool_set_hostid $TESTPOOL $HOSTID1
9196
log_must zpool export $TESTPOOL
9297
log_must mmp_clear_hostid
9398
log_must mmp_set_hostid $HOSTID2
94-
log_must import_no_activity_check $TESTPOOL $opt
99+
log_must import_activity_check $TESTPOOL $opt
95100
done
96101

97102
# 7. Verify multihost=on and hostid zero fails (no activity check)
103+
log_note "Verify multihost=on and hostids differ (no activity check)"
98104
log_must zpool export $TESTPOOL
99105
log_must mmp_clear_hostid
100106

tests/zfs-tests/tests/functional/mmp/mmp_hostid.ksh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ verify_runnable "both"
4040

4141
function cleanup
4242
{
43-
default_cleanup_noexit
43+
datasetexists $MMP_POOL && destroy_pool $MMP_POOL
4444
log_must rm $MMP_DIR/file.{0,1,2,3,4,5}
4545
log_must rmdir $MMP_DIR
4646
log_must mmp_clear_hostid
@@ -56,7 +56,7 @@ log_must mkdir -p $MMP_DIR
5656
log_must truncate -s $MINVDEVSIZE $MMP_DIR/file.{0,1,2,3,4,5}
5757

5858
# 1. Create a non-redundant pool
59-
log_must zpool create $MMP_POOL $MMP_DIR/file.0
59+
log_must zpool create -f $MMP_POOL $MMP_DIR/file.0
6060

6161
# 2. Create an 'etc' dataset containing a valid hostid file; caching is
6262
# disabled on the dataset to force the hostid to be read from disk.
@@ -71,23 +71,27 @@ mntpnt_fs=$(get_prop mountpoint $MMP_POOL/fs)
7171
log_must mkfile 1M $mntpnt_fs/file
7272

7373
# 4. Verify multihost cannot be enabled until the /etc/hostid is linked
74+
log_note "Verify multihost cannot be enabled until the /etc/hostid is linked"
7475
log_mustnot zpool set multihost=on $MMP_POOL
7576
log_mustnot ls -l $HOSTID_FILE
7677
log_must ln -s $mntpnt_etc/hostid $HOSTID_FILE
7778
log_must zpool set multihost=on $MMP_POOL
7879

7980
# 5. Verify vdevs may be attached and detached
81+
log_note "Verify vdevs may be attached and detached"
8082
log_must zpool attach $MMP_POOL $MMP_DIR/file.0 $MMP_DIR/file.1
8183
log_must zpool detach $MMP_POOL $MMP_DIR/file.1
8284

8385
# 6. Verify normal, cache, log and special vdevs can be added
86+
log_note "Verify normal, cache, log and special vdevs can be added"
8487
log_must zpool add $MMP_POOL $MMP_DIR/file.1
8588
log_must zpool add $MMP_POOL $MMP_DIR/file.2
8689
log_must zpool add $MMP_POOL cache $MMP_DIR/file.3
8790
log_must zpool add $MMP_POOL log $MMP_DIR/file.4
8891
log_must zpool add $MMP_POOL special $MMP_DIR/file.5
8992

9093
# 7. Verify normal, cache, and log vdevs can be removed
94+
log_note "Verify normal, cache, and log vdevs can be removed"
9195
log_must zpool remove $MMP_POOL $MMP_DIR/file.2
9296
log_must zpool remove $MMP_POOL $MMP_DIR/file.3
9397
log_must zpool remove $MMP_POOL $MMP_DIR/file.4

0 commit comments

Comments
 (0)