common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / xfs / 147
index 73ff7f9fb47f0dee668e5b04cd5056ca7580b846..5cc363aab11d58410d7b8f18fd50a7582759142b 100755 (executable)
@@ -1,26 +1,12 @@
 #! /bin/bash
-# FSQA Test No. 147
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
 #
-# Dmapi get/set_region
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-#-----------------------------------------------------------------------
+# FS QA Test No. 147
 #
+# Make sure we validate realtime extent size alignment for fallocate modes.
+# This is a regression test for fe341eb151ec ("xfs: ensure that fpunch,
+# fcollapse, and finsert operations are aligned to rt extent size")
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
@@ -29,25 +15,54 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1    # failure is the default!
-trap "exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
 
 # get standard environment, filters and checks
 . ./common/rc
 . ./common/filter
-. ./common/dmapi
 
 # real QA test starts here
 _supported_fs xfs
-_supported_os Linux IRIX
-
 _require_scratch
-_scratch_mkfs_xfs >/dev/null 2>&1
-_dmapi_scratch_mount
+_require_realtime
+_require_xfs_io_command "fcollapse"
+_require_xfs_io_command "finsert"
+_require_xfs_io_command "funshare"
+_require_xfs_io_command "fzero"
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+# Format filesystem with a 256k realtime extent size
+_scratch_mkfs -r extsize=256k > $seqres.full
+_scratch_mount >> $seqres.full
+
+blksz=$(_get_block_size $SCRATCH_MNT)
+rextsize=$($XFS_INFO_PROG $SCRATCH_MNT | grep realtime.*extsz | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g')
+rextblks=$((rextsize / blksz))
+
+echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
+
+# Make sure the root directory has rtinherit set so our test file will too
+_xfs_force_bdev realtime $SCRATCH_MNT
 
-mkdir -p $SCRATCH_MNT/dmapi
+sz=$((rextsize * 100))
+range="$((blksz * 3)) $blksz"
 
-# run DMAPI test using verbose output
-${DMAPI_QASUITE2_DIR}src/test_region -v $DMAPI_LS_TO_COPY_PATH $SCRATCH_MNT
+for verb in fpunch finsert fcollapse fzero funshare falloc; do
+       echo "test $verb"
+       $XFS_IO_PROG -f -c "falloc 0 $sz" "$SCRATCH_MNT/b"
+       $XFS_IO_PROG -f -c "$verb $range" "$SCRATCH_MNT/b"
+       rm -f "$SCRATCH_MNT/b"
+       _scratch_cycle_mount
+done
 
+# success, all done
 status=0
-exit 
+exit