167f72211SAlan Somers#!/bin/sh 267f72211SAlan Somers# Copyright (c) 2019 Axcient 367f72211SAlan Somers# 467f72211SAlan Somers# Redistribution and use in source and binary forms, with or without 567f72211SAlan Somers# modification, are permitted provided that the following conditions 667f72211SAlan Somers# are met: 767f72211SAlan Somers# 1. Redistributions of source code must retain the above copyright 867f72211SAlan Somers# notice, this list of conditions and the following disclaimer. 967f72211SAlan Somers# 2. Redistributions in binary form must reproduce the above copyright 1067f72211SAlan Somers# notice, this list of conditions and the following disclaimer in the 1167f72211SAlan Somers# documentation and/or other materials provided with the distribution. 1267f72211SAlan Somers# 1367f72211SAlan Somers# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1467f72211SAlan Somers# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1567f72211SAlan Somers# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1667f72211SAlan Somers# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1767f72211SAlan Somers# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1867f72211SAlan Somers# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1967f72211SAlan Somers# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2067f72211SAlan Somers# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2167f72211SAlan Somers# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2267f72211SAlan Somers# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2367f72211SAlan Somers# SUCH DAMAGE. 2467f72211SAlan Somers# 2567f72211SAlan Somers 2667f72211SAlan Somers. $(atf_get_srcdir)/conf.sh 2767f72211SAlan Somers 2867f72211SAlan Somers# See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=178473 2967f72211SAlan Somersatf_test_case failloop cleanup 3067f72211SAlan Somersfailloop_head() 3167f72211SAlan Somers{ 3267f72211SAlan Somers atf_set "descr" "A persistent failure in the provider should not cause an infinite loop, nor restore any providers that were faulted by the same bio" 3367f72211SAlan Somers atf_set "require.user" "root" 3467f72211SAlan Somers atf_set "require.config" "allow_sysctl_side_effects" 3567f72211SAlan Somers} 3667f72211SAlan Somersfailloop_body() 3767f72211SAlan Somers{ 3867f72211SAlan Somers sysctl -n kern.geom.notaste > kern.geom.notaste.txt 3967f72211SAlan Somers load_gnop 4067f72211SAlan Somers load_gmultipath 4167f72211SAlan Somers load_dtrace 4267f72211SAlan Somers 4367f72211SAlan Somers md0=$(alloc_md) 4467f72211SAlan Somers md1=$(alloc_md) 4567f72211SAlan Somers name=$(mkname) 4667f72211SAlan Somers atf_check gnop create /dev/${md0} 4767f72211SAlan Somers atf_check gnop create /dev/${md1} 4867f72211SAlan Somers atf_check -s exit:0 gmultipath create "$name" ${md0}.nop ${md1}.nop 4967f72211SAlan Somers sysctl kern.geom.notaste=1 5067f72211SAlan Somers 5167f72211SAlan Somers atf_check gnop configure -r 100 -w 100 ${md0}.nop 5267f72211SAlan Somers atf_check gnop configure -r 100 -w 100 ${md1}.nop 5367f72211SAlan Somers dd_status=`dtrace \ 5467f72211SAlan Somers -o restore_count \ 5567f72211SAlan Somers -i 'geom:multipath:config:restore {@restore = count()}' \ 5667f72211SAlan Somers -c "dd if=/dev/zero of=/dev/multipath/"$name" bs=4096 count=1" \ 5767f72211SAlan Somers 2>&1 | awk '/exited with status/ {print $NF}'` 58819961c5SLi-Wen Hsu if [ ! -f restore_count ]; then 59*8e03a750SLi-Wen Hsu atf_skip "dtrace didn't execute successfully" 60819961c5SLi-Wen Hsu fi 61b9b5a4ddSLi-Wen Hsu # The dd command should've failed ... 62b9b5a4ddSLi-Wen Hsu atf_check_equal 1 $dd_status 63b9b5a4ddSLi-Wen Hsu # and triggered 1 or 2 path restores 6467f72211SAlan Somers if [ `cat restore_count` -gt 2 ]; then 6567f72211SAlan Somers atf_fail "gmultipath restored paths too many times" 6667f72211SAlan Somers fi 6767f72211SAlan Somers} 6867f72211SAlan Somersfailloop_cleanup() 6967f72211SAlan Somers{ 7067f72211SAlan Somers if [ -f kern.geom.notaste.txt ]; then 7167f72211SAlan Somers sysctl kern.geom.notaste=`cat kern.geom.notaste.txt` 7267f72211SAlan Somers fi 7367f72211SAlan Somers common_cleanup 7467f72211SAlan Somers} 7567f72211SAlan Somers 7667f72211SAlan Somersatf_init_test_cases() 7767f72211SAlan Somers{ 7867f72211SAlan Somers atf_add_test_case failloop 7967f72211SAlan Somers} 80