|
| 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