Skip to contentSkip to conversation

xfstest: Add test case to test multiple collapse range call

PATCH Superseded Namjae Jeon 1 participant 1 message Sep 8, 2013 VFS

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 6/7 xfstest: Add test case to test multiple collapse range call

From: Namjae Jeon <[email protected]>

We execute collapse range multiple times on same file. Each collapse range call collapses a single alternate block. After the test execution, file will be left with 80 blocks and as much number of extents.
We also check for file system consistency after the completion.

---
 tests/shared/317     |   96 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/317.out |   85 ++++++++++++++++++++++++++++++++++++++++++++
 tests/shared/group   |    1 +
 3 files changed, 182 insertions(+)
 create mode 100644 tests/shared/317
 create mode 100644 tests/shared/317.out
tests/shared/317 new file +96 -0
new file mode 100644
index 0000000..1d7c384
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 317
+#
+# Test multiple fallocate collapse range calls
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Samsung Electronics.  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
+#
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs ext4
+_supported_os Linux
+
+_require_scratch
+_require_xfs_io_fiemap
+_require_xfs_io_falloc_collapse
+_do_die_on_error=y
+test=$SCRATCH_MNT/test
+testfile=$SCRATCH_MNT/317.$$
+BSIZE=4096
+BLOCKS=10240
+
+# Filters fiemap output
+_filter_fiemap()
+{
+	awk --posix '
+		$3 ~ /hole/ {
+			print $1, $2, $3;
+			next;
+		}
+		$5 ~ /0x[[:xdigit:]]+/ {
+			print $1, $2, "extent";
+		}'
+}
+
+case $FSTYP in
+	ext4)
+		export MKFS_OPTIONS="-F -b $BSIZE"
+		;;
+	xfs)
+		export MKFS_OPTIONS="-f -b size=$BSIZE"
+		;;
+esac
+
+# make filesystem on scratch with 4KB blocksize
+_do 'make filesystem on $SCRATCH_DEV' '_scratch_mkfs'
+_do 'mount filesytem' '_scratch_mount'
+
+# Write file
+length=$(($BLOCKS*$BSIZE))
+$XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null
+
+# Collapse alternate blocks
+for (( i = 1; i <= 7; i++ )); do
+	for(( j=0 ; j < $(($BLOCKS/(2**$i))) ; j++ )); do
+		offset=$(($j*$BSIZE))
+		$XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null
+	done
+done
+
+# Check if 80 extents are present
+$XFS_IO_PROG -c "fiemap -v" $testfile | _filter_fiemap
+
+_do 'unmount $SCRATCH_DEV' 'umount $SCRATCH_DEV'
+_do 'repair filesystem' '_check_scratch_fs'
+
+# success, all done
+status=0; exit
tests/shared/317.out new file +85 -0

85 lines not on this page · raw message

tests/shared/group +1 -0
index 3a69294..80ff7ec 100644
@@ -12,3 +12,4 @@
 298 auto trim
 305 aio dangerous enospc rw stress
 316 auto quick collapse
+317 auto collapse
Signature · 6 lines
1.7.9.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs