xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/mmp/mmp_write_uberblocks.ksh (revision 4e5ef1cee66fbfbbd2b3e56b81e2bb5700f4a59e)
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#	Verify MMP behaves correctly when failing to write uberblocks.
24#
25# STRATEGY:
26#	1. Create a mirrored pool and enable multihost
27#	2. Inject a 50% failure rate when writing uberblocks to a device
28#	3. Delay briefly for additional MMP writes to complete
29#	4. Verify the failed uberblock writes did not prevent MMP updates
30#
31
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/mmp/mmp.cfg
34. $STF_SUITE/tests/functional/mmp/mmp.kshlib
35
36verify_runnable "both"
37
38function cleanup
39{
40	zinject -c all
41	default_cleanup_noexit
42	log_must mmp_clear_hostid
43}
44
45log_assert "mmp behaves correctly when failing to write uberblocks."
46log_onexit cleanup
47
48log_must mmp_set_hostid $HOSTID1
49default_mirror_setup_noexit $DISKS
50log_must zpool set multihost=on $TESTPOOL
51log_must zinject -d ${DISK[0]} -e io -T write -f 50 -L uber $TESTPOOL
52clear_mmp_history
53uber_count=$(count_mmp_writes $TESTPOOL 3)
54
55if [ $uber_count -eq 0 ]; then
56	log_fail "mmp writes did not occur when uberblock IO errors injected"
57fi
58
59log_pass "mmp correctly wrote uberblocks when IO errors injected"
60