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#	Ensure that the MMP thread is notified when zfs_multihost_interval is
23#	reduced.
24#
25# STRATEGY:
26#	1. Set zfs_multihost_interval to much longer than the test duration
27#	2. Create a zpool and enable multihost
28#	3. Verify no MMP writes occurred
29#	4. Set zfs_multihost_interval to 1 second
30#	5. Sleep briefly
31#	6. Verify MMP writes began
32#
33
34. $STF_SUITE/include/libtest.shlib
35. $STF_SUITE/tests/functional/mmp/mmp.cfg
36. $STF_SUITE/tests/functional/mmp/mmp.kshlib
37
38verify_runnable "both"
39
40function cleanup
41{
42	default_cleanup_noexit
43	log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT
44	log_must mmp_clear_hostid
45}
46
47log_assert "mmp threads notified when zfs_multihost_interval reduced"
48log_onexit cleanup
49
50log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_HOUR
51log_must mmp_set_hostid $HOSTID1
52
53default_setup_noexit $DISK
54log_must zpool set multihost=on $TESTPOOL
55
56clear_mmp_history
57log_must set_tunable64 zfs_multihost_interval $MMP_INTERVAL_DEFAULT
58uber_count=$(count_mmp_writes $TESTPOOL 1)
59
60if [ $uber_count -eq 0 ]; then
61	log_fail "mmp writes did not start when zfs_multihost_interval reduced"
62fi
63
64log_pass "mmp threads notified when zfs_multihost_interval reduced"
65