diff mbox

[1/3,v2] XFS TESTS: Fix 252 Failure: Relax fiemap filter

Message ID 1309235247-32650-2-git-send-email-achender@linux.vnet.ibm.com
State Not Applicable, archived
Headers show

Commit Message

Allison Henderson June 28, 2011, 4:27 a.m. UTC
The current test 252 tests punch hole by collecting fiemap information
on the test file.  However this does not work for all file systems since
not all file systems layout their extents in the same way.

This patch corrects this by adding a -h flag to the fiemap filter that ignores
the extent types in the fiemaps.  The result is that the fiemap contains only
"extent" or "hole", instead of "unwritten", "data" or "hole".  A checksum has
also been added to each test to help ensure the file contents are correct.

Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
---
v1 -> v2
Moved new golden output for 252 into a seperate patch to help make the set
easier to read

:100755 100755 5efa243... 1289094... M	252
:100644 100644 ddf63b0... d3c89eb... M	common.punch
 252          |    8 ++++----
 common.punch |   38 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 6 deletions(-)

Comments

Dave Chinner June 28, 2011, 4:59 a.m. UTC | #1
On Mon, Jun 27, 2011 at 09:27:25PM -0700, Allison Henderson wrote:
> The current test 252 tests punch hole by collecting fiemap information
> on the test file.  However this does not work for all file systems since
> not all file systems layout their extents in the same way.
> 
> This patch corrects this by adding a -h flag to the fiemap filter that ignores
> the extent types in the fiemaps.  The result is that the fiemap contains only
> "extent" or "hole", instead of "unwritten", "data" or "hole".  A checksum has
> also been added to each test to help ensure the file contents are correct.
> 
> Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
> ---
> v1 -> v2
> Moved new golden output for 252 into a seperate patch to help make the set
> easier to read
> 
> :100755 100755 5efa243... 1289094... M	252
> :100644 100644 ddf63b0... d3c89eb... M	common.punch
>  252          |    8 ++++----
>  common.punch |   38 ++++++++++++++++++++++++++++++++++++--
>  2 files changed, 40 insertions(+), 6 deletions(-)
> 
> diff --git a/252 b/252
> index 5efa243..1289094 100755
> --- a/252
> +++ b/252
> @@ -53,15 +53,15 @@ _require_xfs_io_fiemap
>  testfile=$TEST_DIR/252.$$
>  
>  # Standard punch hole tests
> -_test_generic_punch falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
> +_test_generic_punch falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
>  
>  # Delayed allocation punch hole tests
> -_test_generic_punch -d falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
> +_test_generic_punch -d falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
>  
>  # Multi hole punch tests
> -_test_generic_punch -k falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
> +_test_generic_punch -k falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
>  
>  # Delayed allocation multi punch hole tests
> -_test_generic_punch -d -k falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
> +_test_generic_punch -d -k falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
>  
>  status=0 ; exit
> diff --git a/common.punch b/common.punch
> index ddf63b0..d3c89eb 100644
> --- a/common.punch
> +++ b/common.punch
> @@ -203,17 +203,34 @@ _coalesce_extents()
>  
>  _filter_fiemap()
>  {
> +
> +	UNWRITTEN_EX="\"unwritten\""
> +	DATA_EX="\"data\""
> +	OPTIND=1
> +	while getopts 'h' OPTION
> +	do
> +		case $OPTION in
> +		h)      UNWRITTEN_EX="\"extent\""
> +			DATA_EX="\"extent\""
> +		;;
> +		?)      echo Invalid flag
> +		exit 1
> +		;;
> +		esac
> +	done
> +	shift $(($OPTIND - 1))
> +
>  	awk --posix '
>  		$3 ~ /hole/ {
>  			print $1, $2, $3;
>  			next;
>  		}
>  		$5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ {
> -			print $1, $2, "unwritten";
> +			print $1, $2, '$UNWRITTEN_EX';
>  			next;
>  		}
>  		$5 ~ /0x[[:digit:]]+/ {
> -			print $1, $2, "data";
> +			print $1, $2, '$DATA_EX';
>  		}' |
>  	_coalesce_extents
>  }

I seriously dislike conditional parameter passing in shell scripts
at the best of times, but for filter functions I really think it is
the wrong thing to do. It significantly obfuscates the working of
the function for no really good reason.

Just write a new filter function, and factor out the common parts of
them if the amount of code duplication is sufficient to make it
desirable to do so.

> +	md5sum $testfile | cut -d ' ' -f1

Why cut out the file name? It's not like it changes at all....

Cheers,

Dave.
Allison Henderson June 28, 2011, 5:17 a.m. UTC | #2
On 06/27/2011 09:59 PM, Dave Chinner wrote:
> On Mon, Jun 27, 2011 at 09:27:25PM -0700, Allison Henderson wrote:
> I seriously dislike conditional parameter passing in shell scripts
> at the best of times, but for filter functions I really think it is
> the wrong thing to do. It significantly obfuscates the working of
> the function for no really good reason.
>
> Just write a new filter function, and factor out the common parts of
> them if the amount of code duplication is sufficient to make it
> desirable to do so.
>

Ok, it doesn't look like a lot of code, I can separate them into their
own functions.

>> +	md5sum $testfile | cut -d ' ' -f1
>
> Why cut out the file name? It's not like it changes at all....
>

Oh, it looked like there's a pid attached to the file name, so I thought 
I should remove that from the output

Allison Henderson


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Chinner June 28, 2011, 8:49 a.m. UTC | #3
On Mon, Jun 27, 2011 at 10:17:12PM -0700, Allison Henderson wrote:
> On 06/27/2011 09:59 PM, Dave Chinner wrote:
> >On Mon, Jun 27, 2011 at 09:27:25PM -0700, Allison Henderson wrote:
> >I seriously dislike conditional parameter passing in shell scripts
> >at the best of times, but for filter functions I really think it is
> >the wrong thing to do. It significantly obfuscates the working of
> >the function for no really good reason.
> >
> >Just write a new filter function, and factor out the common parts of
> >them if the amount of code duplication is sufficient to make it
> >desirable to do so.
> >
> 
> Ok, it doesn't look like a lot of code, I can separate them into their
> own functions.
> 
> >>+	md5sum $testfile | cut -d ' ' -f1
> >
> >Why cut out the file name? It's not like it changes at all....
> >
> 
> Oh, it looked like there's a pid attached to the file name, so I
> thought I should remove that from the output

Oh, it does too. My mistake, too trigger happy, just looking for
ways to keep things relatively simple. Maybe using a wrapper
function so if we ever need to modify it we only need to change one
line of code would acheive the same thing?

Cheers,

Dave.
diff mbox

Patch

diff --git a/252 b/252
index 5efa243..1289094 100755
--- a/252
+++ b/252
@@ -53,15 +53,15 @@  _require_xfs_io_fiemap
 testfile=$TEST_DIR/252.$$
 
 # Standard punch hole tests
-_test_generic_punch falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
+_test_generic_punch falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
 
 # Delayed allocation punch hole tests
-_test_generic_punch -d falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
+_test_generic_punch -d falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
 
 # Multi hole punch tests
-_test_generic_punch -k falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
+_test_generic_punch -k falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
 
 # Delayed allocation multi punch hole tests
-_test_generic_punch -d -k falloc fpunch fpunch fiemap _filter_fiemap $testfile -F
+_test_generic_punch -d -k falloc fpunch fpunch fiemap "_filter_fiemap -h" $testfile -F
 
 status=0 ; exit
diff --git a/common.punch b/common.punch
index ddf63b0..d3c89eb 100644
--- a/common.punch
+++ b/common.punch
@@ -203,17 +203,34 @@  _coalesce_extents()
 
 _filter_fiemap()
 {
+
+	UNWRITTEN_EX="\"unwritten\""
+	DATA_EX="\"data\""
+	OPTIND=1
+	while getopts 'h' OPTION
+	do
+		case $OPTION in
+		h)      UNWRITTEN_EX="\"extent\""
+			DATA_EX="\"extent\""
+		;;
+		?)      echo Invalid flag
+		exit 1
+		;;
+		esac
+	done
+	shift $(($OPTIND - 1))
+
 	awk --posix '
 		$3 ~ /hole/ {
 			print $1, $2, $3;
 			next;
 		}
 		$5 ~ /0x[[:digit:]]*8[[:digit:]]{2}/ {
-			print $1, $2, "unwritten";
+			print $1, $2, '$UNWRITTEN_EX';
 			next;
 		}
 		$5 ~ /0x[[:digit:]]+/ {
-			print $1, $2, "data";
+			print $1, $2, '$DATA_EX';
 		}' |
 	_coalesce_extents
 }
@@ -305,6 +322,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	2. into allocated space"
 	if [ "$remove_testfile" ]; then
@@ -315,6 +333,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	3. into unwritten space"
 	if [ "$remove_testfile" ]; then
@@ -325,6 +344,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	4. hole -> data"
 	if [ "$remove_testfile" ]; then
@@ -335,6 +355,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	5. hole -> unwritten"
 	if [ "$remove_testfile" ]; then
@@ -345,6 +366,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	6. data -> hole"
 	if [ "$remove_testfile" ]; then
@@ -355,6 +377,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	7. data -> unwritten"
 	if [ "$remove_testfile" ]; then
@@ -366,6 +389,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	8. unwritten -> hole"
 	if [ "$remove_testfile" ]; then
@@ -376,6 +400,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	9. unwritten -> data"
 	if [ "$remove_testfile" ]; then
@@ -387,6 +412,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	10. hole -> data -> hole"
 	if [ "$remove_testfile" ]; then
@@ -397,6 +423,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 12k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	11. data -> hole -> data"
 	if [ "$remove_testfile" ]; then
@@ -410,6 +437,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 12k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	12. unwritten -> data -> unwritten"
 	if [ "$remove_testfile" ]; then
@@ -421,6 +449,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 12k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	13. data -> unwritten -> data"
 	if [ "$remove_testfile" ]; then
@@ -433,6 +462,7 @@  _test_generic_punch()
 		-c "$zero_cmd 4k 12k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	14. data -> hole @ EOF"
 	rm -f $testfile
@@ -441,6 +471,7 @@  _test_generic_punch()
 		-c "$zero_cmd 12k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	15. data -> hole @ 0"
 	if [ "$remove_testfile" ]; then
@@ -451,6 +482,7 @@  _test_generic_punch()
 		-c "$zero_cmd 0k 8k" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	16. data -> cache cold ->hole"
 	if [ "$remove_testfile" ]; then
@@ -470,6 +502,7 @@  _test_generic_punch()
 	diff $testfile $testfile.2
 	[ $? -ne 0 ] && die_now
 	rm -f $testfile.2
+	md5sum $testfile | cut -d ' ' -f1
 
 	echo "	17. data -> hole in single block file"
 	if [ "$remove_testfile" ]; then
@@ -481,5 +514,6 @@  _test_generic_punch()
 		-c "$zero_cmd 128 128" \
 		-c "$map_cmd -v" $testfile | $filter_cmd
 	[ $? -ne 0 ] && die_now
+	md5sum $testfile | cut -d ' ' -f1
 
 }