Skip to contentSkip to conversation

xfstest: shared/001: Standard collapse range tests

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

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 5/10 xfstest: shared/001: Standard collapse range tests

From: Namjae Jeon <[email protected]>

This testcase(001) tries to test various corner cases for fcollapse range functionality over different type of extents.

---
 common/punch         |  133 ++++++++++++++++++++++++++++----------------------
 common/rc            |   14 ++++++
 tests/shared/001     |   65 ++++++++++++++++++++++++
 tests/shared/001.out |   53 ++++++++++++++++++++
 tests/shared/group   |    1 +
 5 files changed, 209 insertions(+), 57 deletions(-)
 create mode 100644 tests/shared/001
 create mode 100644 tests/shared/001.out
common/punch +76 -57
index a49638c..f401455 100644
@@ -317,13 +317,23 @@ _test_generic_punch()
 	map_cmd=$4
 	filter_cmd=$5
 	testfile=$6
+	multiple=1
+
+	#
+	# If we are testing collapse range, we increare all the offsets of this
+	# test by a factor of 4. We do this because unlike punch, collapse
+	# range also decreases the size of file hence require bigger offsets.
+	#
+	if [ "$zero_cmd" == "fcollapse" ]; then
+		multiple=4
+	fi
 
 	echo "	1. into a hole"
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "$zero_cmd 4k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -332,9 +342,9 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 0 20k" $sync_cmd \
-		-c "$zero_cmd 4k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 20))k" $sync_cmd \
+		-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -344,9 +354,9 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 0 20k" \
-			-c "$zero_cmd 4k 8k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd 0 $(($multiple * 20))k" \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -356,9 +366,9 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 8k 8k" $sync_cmd \
-		-c "$zero_cmd 4k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite $(($multiple * 8))k $(($multiple * 8))k" $sync_cmd \
+		-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -368,9 +378,9 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 8k 8k" \
-			-c "$zero_cmd 4k 8k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd $(($multiple * 8))k $(($multiple * 8))k" \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -380,9 +390,9 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 0 8k" $sync_cmd \
-		-c "$zero_cmd 4k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 8))k" $sync_cmd \
+		 -c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -392,10 +402,10 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "pwrite 0 8k" $sync_cmd \
-			-c "$alloc_cmd 8k 8k" \
-			-c "$zero_cmd 4k 8k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "pwrite 0 $(($multiple * 8))k" $sync_cmd \
+			-c "$alloc_cmd $(($multiple * 8))k $(($multiple * 8))k" \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -404,9 +414,9 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 0 8k" \
-			-c "$zero_cmd 4k 8k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd 0 $(($multiple * 8))k" \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -415,10 +425,10 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 0 8k" \
-			-c "pwrite 8k 8k" $sync_cmd \
-			-c "$zero_cmd 4k 8k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd 0 $(($multiple * 8))k" \
+			-c "pwrite $(($multiple * 8))k $(($multiple * 8))k" $sync_cmd \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 8))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -428,9 +438,9 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 8k 4k" $sync_cmd \
-		-c "$zero_cmd 4k 12k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite $(($multiple * 8))k $(($multiple * 4))k" $sync_cmd \
+		-c "$zero_cmd $(($multiple * 4))k $(($multiple * 12))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -439,12 +449,12 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "$alloc_cmd 0 20k" \
-		-c "pwrite 0 8k" \
-		-c "pwrite 12k 8k" $sync_cmd \
-		-c "$punch_cmd 8k 4k" \
-		-c "$zero_cmd 4k 12k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "$alloc_cmd 0 $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 8))k" \
+		-c "pwrite $(($multiple * 12))k $(($multiple * 8))k" $sync_cmd \
+		-c "$punch_cmd $(($multiple * 8))k $(($multiple * 4))k" \
+		-c "$zero_cmd $(($multiple * 4))k $(($multiple * 12))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -454,10 +464,10 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 0 20k" \
-			-c "pwrite 8k 4k" $sync_cmd \
-			-c "$zero_cmd 4k 12k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd 0 $(($multiple * 20))k" \
+			-c "pwrite $(($multiple * 8))k $(($multiple * 4))k" $sync_cmd \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 12))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -466,11 +476,11 @@ _test_generic_punch()
 		if [ "$remove_testfile" ]; then
 			rm -f $testfile
 		fi
-		$XFS_IO_PROG -f -c "truncate 20k" \
-			-c "$alloc_cmd 0 20k" \
-			-c "pwrite 0k 8k" $sync_cmd \
-			-c "pwrite 12k 8k" -c "fsync" \
-			-c "$zero_cmd 4k 12k" \
+		$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+			-c "$alloc_cmd 0 $(($multiple * 20))k" \
+			-c "pwrite 0k $(($multiple * 4))k" $sync_cmd \
+			-c "pwrite $(($multiple * 12))k $(($multiple * 8))k" -c "fsync" \
+			-c "$zero_cmd $(($multiple * 4))k $(($multiple * 12))k" \
 			-c "$map_cmd -v" $testfile | $filter_cmd
 		[ $? -ne 0 ] && die_now
 		_md5_checksum $testfile
@@ -478,9 +488,9 @@ _test_generic_punch()
 
 	echo "	14. data -> hole @ EOF"
 	rm -f $testfile
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 0 20k" $sync_cmd \
-		-c "$zero_cmd 12k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 20))k" $sync_cmd \
+		-c "$zero_cmd $(($multiple * 12))k $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
@@ -489,13 +499,22 @@ _test_generic_punch()
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 0 20k" $sync_cmd \
-		-c "$zero_cmd 0k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 20))k" $sync_cmd \
+		-c "$zero_cmd 0 $(($multiple * 8))k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
 	_md5_checksum $testfile
 
+	# If zero_cmd is fcollpase, don't check unaligned offsets
+	if [ "$zero_cmd" == "fcollapse" ]; then
+		if [ "$remove_testfile" ]; then
+			rm -f $testfile
+			rm -f $testfile.2
+		fi
+		return
+	fi
+	
 	echo "	16. data -> cache cold ->hole"
 	if [ "$remove_testfile" ]; then
 		rm -f $testfile
@@ -503,12 +522,12 @@ _test_generic_punch()
 	else
 		cp $testfile $testfile.2
 	fi
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 8k 12k" -c "fsync" $testfile.2 \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite $(($multiple * 8))k $(($multiple * 12))k" -c "fsync" $testfile.2 \
 		> /dev/null
-	$XFS_IO_PROG -f -c "truncate 20k" \
-		-c "pwrite 0 20k" $sync_cmd \
-		-c "$zero_cmd 0k 8k" \
+	$XFS_IO_PROG -f -c "truncate $(($multiple * 20))k" \
+		-c "pwrite 0 $(($multiple * 20))k" $sync_cmd \
+		-c "$zero_cmd 0k $(($multiple * 8))k" \
 		-c "fadvise -d" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	diff $testfile $testfile.2
common/rc +14 -0
index 5f61d57..3be4721 100644
@@ -1259,6 +1259,20 @@ _require_xfs_io_falloc_punch()
 		_notrun "xfs_io fallocate punch command failed (no fs support?)"
 }
 
+# check that xfs_io, kernel and filesystem all support fallocate with collapse
+# range
+_require_xfs_io_falloc_collapse()
+{
+	testfile=$TEST_DIR/$$.falloc
+	testio=`$XFS_IO_PROG -f -c "pwrite 0 20k" -c "fsync" \
+		-c "fcollapse 4k 8k" $testfile 2>&1`
+	rm -f $testfile 2>&1 > /dev/null
+	echo $testio | grep -q "not found" && \
+		_notrun "xfs_io fallocate collapse range support is missing"
+	echo $testio | grep -q "Operation not supported" && \
+		_notrun "xfs_io fallocate collapse range failed (no fs support?)"
+}
+
 # check that xfs_io, kernel and filesystem support fiemap
 _require_xfs_io_fiemap()
 {
tests/shared/001 new file +65 -0

65 lines not on this page · raw message

tests/shared/001.out new file +53 -0

53 lines not on this page · raw message

tests/shared/group +1 -0
index 0ad640b..5562f92 100644
@@ -3,6 +3,7 @@
 # - do not start group names with a digit
 # - comment line before each group is "new" description
 #
+001 auto prealloc
 032 mkfs auto quick
 051 acl udf auto quick
 218 auto fsr quick
Signature · 6 lines
1.7.9.5

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