1*9350e923SAlan Somers# SPDX-License-Identifier: BSD-2-Clause 2*9350e923SAlan Somers# 3*9350e923SAlan Somers# Copyright (c) 2024 ConnectWise 4*9350e923SAlan Somers# All rights reserved. 5*9350e923SAlan Somers# 6*9350e923SAlan Somers# Redistribution and use in source and binary forms, with or without 7*9350e923SAlan Somers# modification, are permitted provided that the following conditions 8*9350e923SAlan Somers# are met: 9*9350e923SAlan Somers# 1. Redistributions of source code must retain the above copyright 10*9350e923SAlan Somers# notice, this list of conditions and the following disclaimer. 11*9350e923SAlan Somers# 2. Redistributions in binary form must reproduce the above copyright 12*9350e923SAlan Somers# notice, this list of conditions and the following disclaimer in the 13*9350e923SAlan Somers# documentation and/or other materials provided with the distribution. 14*9350e923SAlan Somers# 15*9350e923SAlan Somers# THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16*9350e923SAlan Somers# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17*9350e923SAlan Somers# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18*9350e923SAlan Somers# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19*9350e923SAlan Somers# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20*9350e923SAlan Somers# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*9350e923SAlan Somers# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*9350e923SAlan Somers# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*9350e923SAlan Somers# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24*9350e923SAlan Somers# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*9350e923SAlan Somers 26*9350e923SAlan Somers. $(atf_get_srcdir)/../../cam/ctl/ctl.subr 27*9350e923SAlan Somers 28*9350e923SAlan Somers# Regression test for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283402 29*9350e923SAlan Somers# 30*9350e923SAlan Somers# Almost any fuse file system would work, but this tests uses fusefs-ext2 31*9350e923SAlan Somers# because it's simple and its download is very small. 32*9350e923SAlan Somersatf_test_case remove_lun_with_atime cleanup 33*9350e923SAlan Somersremove_lun_with_atime_head() 34*9350e923SAlan Somers{ 35*9350e923SAlan Somers atf_set "descr" "Remove a fuse-backed CTL LUN when atime is enabled" 36*9350e923SAlan Somers atf_set "require.user" "root" 37*9350e923SAlan Somers atf_set "require.progs" "fuse-ext2 mkfs.ext2" 38*9350e923SAlan Somers} 39*9350e923SAlan Somersremove_lun_with_atime_body() 40*9350e923SAlan Somers{ 41*9350e923SAlan Somers MOUNTPOINT=$PWD/mnt 42*9350e923SAlan Somers atf_check mkdir $MOUNTPOINT 43*9350e923SAlan Somers atf_check truncate -s 1g ext2.img 44*9350e923SAlan Somers atf_check mkfs.ext2 -q ext2.img 45*9350e923SAlan Somers # Note: both default_permissions and atime must be enabled 46*9350e923SAlan Somers atf_check fuse-ext2 -o default_permissions,allow_other,rw+ ext2.img \ 47*9350e923SAlan Somers $MOUNTPOINT 48*9350e923SAlan Somers 49*9350e923SAlan Somers atf_check truncate -s 1m $MOUNTPOINT/file 50*9350e923SAlan Somers create_block -o file=$MOUNTPOINT/file 51*9350e923SAlan Somers 52*9350e923SAlan Somers # Force fusefs to open the file, and dirty its atime 53*9350e923SAlan Somers atf_check dd if=/dev/$dev of=/dev/null count=1 status=none 54*9350e923SAlan Somers 55*9350e923SAlan Somers # Finally, remove the LUN. Hopefully it won't panic. 56*9350e923SAlan Somers atf_check -o ignore ctladm remove -b block -l $LUN 57*9350e923SAlan Somers 58*9350e923SAlan Somers rm lun-create.txt # So we don't try to remove the LUN twice 59*9350e923SAlan Somers} 60*9350e923SAlan Somersremove_lun_with_atime_cleanup() 61*9350e923SAlan Somers{ 62*9350e923SAlan Somers cleanup 63*9350e923SAlan Somers umount $PWD/mnt 64*9350e923SAlan Somers} 65*9350e923SAlan Somers 66*9350e923SAlan Somersatf_init_test_cases() 67*9350e923SAlan Somers{ 68*9350e923SAlan Somers atf_add_test_case remove_lun_with_atime 69*9350e923SAlan Somers} 70