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# zfs_multihost_history should report both writes issued and gaps 23# 24# STRATEGY: 25# 1. Create a 2-vdev pool with mmp enabled 26# 2. Delay writes by 2*MMP_INTERVAL_DEFAULT 27# 3. Check multihost_history for both issued writes, and for gaps where 28# no write could be issued because all vdevs are busy 29# 30# During the first MMP_INTERVAL period 2 MMP writes will be issued - one to 31# each vdev. At the third scheduled attempt to write, at time t0+MMP_INTERVAL, 32# both vdevs will still have outstanding writes, so a skipped write entry will 33# be recorded in the multihost_history. 34 35 36. $STF_SUITE/include/libtest.shlib 37. $STF_SUITE/tests/functional/mmp/mmp.cfg 38. $STF_SUITE/tests/functional/mmp/mmp.kshlib 39 40verify_runnable "both" 41 42function cleanup 43{ 44 log_must zinject -c all 45 mmp_pool_destroy $MMP_POOL $MMP_DIR 46 log_must mmp_clear_hostid 47} 48 49log_assert "zfs_multihost_history records writes and skipped writes" 50log_onexit cleanup 51 52mmp_pool_create_simple $MMP_POOL $MMP_DIR 53log_must zinject -d $MMP_DIR/vdev1 -D$((2*MMP_INTERVAL_DEFAULT)):10 $MMP_POOL 54log_must zinject -d $MMP_DIR/vdev2 -D$((2*MMP_INTERVAL_DEFAULT)):10 $MMP_POOL 55 56mmp_writes=$(count_mmp_writes $MMP_POOL $((MMP_INTERVAL_DEFAULT/1000))) 57mmp_skips=$(count_skipped_mmp_writes $MMP_POOL $((MMP_INTERVAL_DEFAULT/1000))) 58 59if [ $mmp_writes -lt 1 ]; then 60 log_fail "mmp writes entries missing when delays injected" 61fi 62 63if [ $mmp_skips -lt 1 ]; then 64 log_fail "mmp skipped write entries missing when delays injected" 65fi 66 67log_pass "zfs_multihost_history records writes and skipped writes" 68