Skip to content

Commit 072478d

Browse files
committed
ZTS: add mount_loopback to test zfs behind loop dev
Add a test case to reproduce issue openzfs#17277: 1. Make a pool 2. Write a file to the pool 3. Mount the file as a loopback device 4. Make an XFS filesystem on the loopback device 5. Mount the XFS filesystem... <hangs> Signed-off-by: Tony Hutter <[email protected]>
1 parent b1ccab1 commit 072478d

File tree

5 files changed

+112
-1
lines changed

5 files changed

+112
-1
lines changed

.github/workflows/scripts/qemu-6-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ esac
9696
# run functional testings and save exitcode
9797
cd /var/tmp
9898
TAGS=$2/$3
99+
TAGS=mount
99100
if [ "$4" == "quick" ]; then
100101
export RUNFILES="sanity.run"
101102
fi

tests/runfiles/linux.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ tests = ['mmp_on_thread', 'mmp_on_uberblocks', 'mmp_on_off', 'mmp_interval',
165165
tags = ['functional', 'mmp']
166166

167167
[tests/functional/mount:Linux]
168-
tests = ['umount_unlinked_drain']
168+
tests = ['umount_unlinked_drain', 'mount_loopback']
169169
tags = ['functional', 'mount']
170170

171171
[tests/functional/pam:Linux]

tests/zfs-tests/include/commands.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export SYSTEM_FILES_LINUX='attr
146146
lscpu
147147
lsmod
148148
lsscsi
149+
mkfs.xfs
149150
mkswap
150151
modprobe
151152
mountpoint

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
16731673
functional/mmp/setup.ksh \
16741674
functional/mount/cleanup.ksh \
16751675
functional/mount/setup.ksh \
1676+
functional/mount/mount_loopback.ksh \
16761677
functional/mount/umount_001.ksh \
16771678
functional/mount/umountall_001.ksh \
16781679
functional/mount/umount_unlinked_drain.ksh \
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/ksh -p
2+
# SPDX-License-Identifier: CDDL-1.0
3+
#
4+
# CDDL HEADER START
5+
#
6+
# The contents of this file are subject to the terms of the
7+
# Common Development and Distribution License (the "License").
8+
# You may not use this file except in compliance with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or https://opensource.org/licenses/CDDL-1.0.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
24+
# Copyright (c) 2025 by Lawrence Livermore National Security, LLC.
25+
26+
. $STF_SUITE/include/libtest.shlib
27+
28+
#
29+
# DESCRIPTION:
30+
# Verify that we can make an xfs filesystem on a ZFS-backed loopback device.
31+
#
32+
# See:
33+
# https://github.com/openzfs/zfs/pull/17298
34+
# https://github.com/openzfs/zfs/issues/17277
35+
#
36+
# STRATEGY:
37+
# 1. Make a pool
38+
# 2. Make a file on the pool or create zvol
39+
# 3. Mount the file/zvol behind a loopback device
40+
# 4. Create & mount an xfs filesystem on the loopback device
41+
42+
function cleanup
43+
{
44+
if [ -d $TEST_BASE_DIR/mnt ] ; then
45+
umount $TEST_BASE_DIR/mnt
46+
log_must rmdir $TEST_BASE_DIR/mnt
47+
fi
48+
if [ -n "$DEV" ] ; then
49+
log_must losetup -d $DEV
50+
fi
51+
destroy_pool $TESTPOOL2
52+
log_must rm -f $TEST_BASE_DIR/file1
53+
}
54+
55+
log_assert "Make an xfs filesystem on a ZFS-backed loopback device"
56+
log_onexit cleanup
57+
58+
TESTPOOL2=testpool2
59+
# fio options
60+
export NUMJOBS=2
61+
export RUNTIME=3
62+
export PERF_RANDSEED=1234
63+
export PERF_COMPPERCENT=66
64+
export PERF_COMPCHUNK=0
65+
export BLOCKSIZE=128K
66+
export SYNC_TYPE=0
67+
export FILE_SIZE=$(( 1024 * 1024 ))
68+
69+
function do_test
70+
{
71+
imgfile=$1
72+
log_note "Running test on $imgfile"
73+
log_must losetup -f $imgfile
74+
DEV=$(losetup --associated $imgfile | grep -Eo '^/dev/loop[0-9]+')
75+
log_note "DEV: $DEV"
76+
log_must mkfs.xfs $DEV
77+
mkdir $TEST_BASE_DIR/mnt
78+
log_must mount $DEV $TEST_BASE_DIR/mnt
79+
export DIRECTORY=$TEST_BASE_DIR/mnt
80+
81+
for d in 0 1 ; do
82+
# fio options
83+
export DIRECT=$d
84+
log_must fio $FIO_SCRIPTS/mkfiles.fio
85+
log_must fio $FIO_SCRIPTS/random_reads.fio
86+
done
87+
log_must umount $TEST_BASE_DIR/mnt
88+
log_must rmdir $TEST_BASE_DIR/mnt
89+
log_must losetup -d $DEV
90+
DEV=""
91+
}
92+
93+
truncate -s 1G $TEST_BASE_DIR/file1
94+
log_must zpool create $TESTPOOL2 $TEST_BASE_DIR/file1
95+
log_must truncate -s 512M /$TESTPOOL2/img
96+
do_test /$TESTPOOL2/img
97+
log_must rm /$TESTPOOL2/img
98+
log_must zfs create -V 512M $TESTPOOL2/vol
99+
100+
block_device_wait "$ZVOL_DEVDIR/$TESTPOOL2/vol"
101+
if [ ! -e "$ZVOL_DEVDIR/$TESTPOOL2/vol" ] ; then
102+
blkdev=/dev/zd0
103+
else
104+
blkdev=${ZVOL_DEVDIR}/$TESTPOOL2/vol
105+
fi
106+
do_test $blkdev
107+
108+
log_pass "Verified xfs filesystem on a ZFS-backed loopback device"

0 commit comments

Comments
 (0)