Skip to contentSkip to conversation

xfstest: shared/001: Standard collapse range tests

PATCH RESEND Superseded Namjae Jeon 2 participants 3 messages Feb 2, 2014 – Feb 4, 2014 VFS

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 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
#1 lore raw
Quoted 7 lines · Namjae Jeon

From: Namjae Jeon <[email protected]>

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

Couple of things:

Quoted 6 lines
common/punch +0 -0
 			-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

common/punch _test_generic_punch() · line 432

Quoted 10 lines
common/punch +4 -4
 		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

This is unreadable, and therefore I'd consider that these changes render _test_generic_punch unmaintainable.

Either it needs tobe factored to be more readable, or we need a more readable way of representing the offsets and sizes if we want them to be variable. For example:

_4k="$((multiple * 4))k"
_8k="$((multiple * 8))k"
_20k="$((multiple * 20))k"

leads to:

		$XFS_IO_PROG -f -c "truncate $_20k" \
			-c "$alloc_cmd 0 $_8k" \
			-c "pwrite $_8k $_8k" $sync_cmd \
			-c "$zero_cmd $_4k $_8k" \
			-c "$map_cmd -v" $testfile | $filter_cmd

which is still readable and allows us to arbitrarily scale the parameters. It even allows us to handle different filesystem block sizes if we really want to....

common/punch _test_generic_punch() · line 516

Quoted 12 lines
(quoted diff) +0 -0
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
common/punch +8 -0
 	_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

No need to remove the test files here - we remove them at test startup to ensure we have a known initial state....

tests/shared/001.out line 49

Quoted 8 lines

+0: [0..63]: extent

tests/shared/001.out new file +7 -0
+bb7df04e1b0a2570657527a7e108ae23
+	13. data -> unwritten -> data
+0: [0..63]: extent
+0f0151cbed83e4bf6e5bde26e82ab115
+	14. data -> hole @ EOF
+fallocate: Invalid argument
+0: [0..159]: extent

This error appears in all the golden outputs. If it's correct, then perhaps it should be filtered out or commented somewhere to explain why it is expected.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

2014-02-04, Dave Chinner <[email protected]>:

Quoted 11 lines · Namjae Jeon
Quoted 7 lines

From: Namjae Jeon <[email protected]>

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

Couple of things:

Quoted 17 lines
Quoted 6 lines
common/punch +0 -0
 			-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

common/punch _test_generic_punch() · line 432

Quoted 10 lines
common/punch +4 -4
 		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

Hi. Dave.

Quoted 19 lines

This is unreadable, and therefore I'd consider that these changes render _test_generic_punch unmaintainable.

Either it needs tobe factored to be more readable, or we need a more readable way of representing the offsets and sizes if we want them to be variable. For example:

_4k="$((multiple * 4))k"
_8k="$((multiple * 8))k"
_20k="$((multiple * 20))k"

leads to:

		$XFS_IO_PROG -f -c "truncate $_20k" \
			-c "$alloc_cmd 0 $_8k" \
			-c "pwrite $_8k $_8k" $sync_cmd \
			-c "$zero_cmd $_4k $_8k" \
			-c "$map_cmd -v" $testfile | $filter_cmd
Quoted 3 lines

which is still readable and allows us to arbitrarily scale the parameters. It even allows us to handle different filesystem block sizes if we really want to....

Okay, I will change it as you suggest.

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now

_md5_checksum $testfile

Quoted 11 lines

common/punch _test_generic_punch() · line 516

Quoted 8 lines
common/punch +8 -0
+	# 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

No need to remove the test files here - we remove them at test startup to ensure we have a known initial state....

Okay.

Quoted 13 lines

tests/shared/001.out line 49

Quoted 9 lines

+0: [0..63]: extent

tests/shared/001.out new file +7 -0
+bb7df04e1b0a2570657527a7e108ae23
+	13. data -> unwritten -> data
+0: [0..63]: extent
+0f0151cbed83e4bf6e5bde26e82ab115
+	14. data -> hole @ EOF
+fallocate: Invalid argument
+0: [0..159]: extent

This error appears in all the golden outputs. If it's correct, then perhaps it should be filtered out or commented somewhere to explain why it is expected.

Okay, I will add the comments to explain about this.

Thanks for your review :)

Quoted 8 lines

Cheers,

Dave.
--
Dave Chinner
[email protected]

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