]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / mmp / mmp_on_off.ksh
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 #
20
21 # DESCRIPTION:
22 #       When multihost=off ensure that leaf vdev uberblocks are not updated.
23 #
24 # STRATEGY:
25 #       1. Set multihost=off (disables mmp)
26 #       2. Set TXG_TIMEOUT to large value
27 #       3. Create a zpool
28 #       4. Find the current "best" uberblock
29 #       5. Sleep for enough time for uberblocks to change
30 #       6. Find the current "best" uberblock
31 #       7. If the uberblock changed, fail
32 #       8. Set multihost=on
33 #       9. Sleep for enough time for uberblocks to change
34 #       10. Find the current "best" uberblock
35 #       11. If uberblocks didn't change, fail
36 #
37
38 . $STF_SUITE/include/libtest.shlib
39 . $STF_SUITE/tests/functional/mmp/mmp.cfg
40 . $STF_SUITE/tests/functional/mmp/mmp.kshlib
41
42 verify_runnable "both"
43
44 function cleanup
45 {
46         default_cleanup_noexit
47         log_must set_tunable64 TXG_TIMEOUT $TXG_TIMEOUT_DEFAULT
48         log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_DEFAULT
49         log_must rm -f $PREV_UBER $CURR_UBER
50         log_must mmp_clear_hostid
51 }
52
53 log_assert "mmp thread won't write uberblocks with multihost=off"
54 log_onexit cleanup
55
56 log_must set_tunable64 MULTIHOST_INTERVAL $MMP_INTERVAL_MIN
57 log_must set_tunable64 TXG_TIMEOUT $TXG_TIMEOUT_LONG
58 log_must mmp_set_hostid $HOSTID1
59
60 default_setup_noexit $DISK
61 log_must zpool set multihost=off $TESTPOOL
62
63 log_must zdb -u $TESTPOOL > $PREV_UBER
64 log_must sleep 5
65 log_must zdb -u $TESTPOOL > $CURR_UBER
66
67 if ! diff "$CURR_UBER" "$PREV_UBER"; then
68         log_fail "mmp thread has updated an uberblock"
69 fi
70
71 log_must zpool set multihost=on $TESTPOOL
72 log_must sleep 5
73 log_must zdb -u $TESTPOOL > $CURR_UBER
74
75 if diff "$CURR_UBER" "$PREV_UBER"; then
76         log_fail "mmp failed to update uberblocks"
77 fi
78
79 log_pass "mmp thread won't write uberblocks with multihost=off passed"