xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/mmp/mmp_on_off.ksh (revision d3b5f56344d8bfcdd6cfb82446af0e5e55ad9ebe)
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 zfs_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
42verify_runnable "both"
43
44function cleanup
45{
46	default_cleanup_noexit
47	log_must set_tunable64 zfs_txg_timeout $TXG_TIMEOUT_DEFAULT
48	log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT
49	log_must rm -f $PREV_UBER $CURR_UBER
50	log_must mmp_clear_hostid
51}
52
53log_assert "mmp thread won't write uberblocks with multihost=off"
54log_onexit cleanup
55
56log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_MIN
57log_must set_tunable64 zfs_txg_timeout $TXG_TIMEOUT_LONG
58log_must mmp_set_hostid $HOSTID1
59
60default_setup_noexit $DISK
61log_must zpool set multihost=off $TESTPOOL
62
63log_must zdb -u $TESTPOOL > $PREV_UBER
64log_must sleep 5
65log_must zdb -u $TESTPOOL > $CURR_UBER
66
67if ! diff "$CURR_UBER" "$PREV_UBER"; then
68	log_fail "mmp thread has updated an uberblock"
69fi
70
71log_must zpool set multihost=on $TESTPOOL
72log_must sleep 5
73log_must zdb -u $TESTPOOL > $CURR_UBER
74
75if diff "$CURR_UBER" "$PREV_UBER"; then
76	log_fail "mmp failed to update uberblocks"
77fi
78
79log_pass "mmp thread won't write uberblocks with multihost=off passed"
80