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