Skip to contentSkip to conversation

xfs/259: handle minimum block size more precisely

PATCH In review Eryu Guan 3 participants 8 messages Apr 7, 2016 – Apr 12, 2016

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

PATCH 1/1 xfs/259: handle minimum block size more precisely

Currently xfs/259 checks $TEST_DIR for CRC support status to determine if 512 block size should be tested. But this doesn't always work. For example, when TEST_DEV is mkfs'ed with "-m crc=0" mkfs option, using mkfs.xfs binary with CRC being the default.

What should be really checked is whether mkfs.xfs creates CRC enabled XFS by default. So introduce a new flag XFS_MKFS_CRC_DEFAULT for this purpose, and do the check based on it in xfs/259.

---

This is actually the second attempt to fix this issue, because Christoph was not satisfied with the first attempt, and me either (after thinking about it more :-)). Hope it works this time.

 common/config | 8 ++++++++
 tests/xfs/259 | 4 +---
 2 files changed, 9 insertions(+), 3 deletions(-)
common/config +8 -0
index cacd815..13bd307 100644
@@ -270,8 +270,16 @@ $MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
 if [ $? -ne 0 ]; then
 	XFS_MKFS_HAS_NO_META_SUPPORT=true
 fi
+# check if v5 xfs is default
+XFS_MKFS_CRC_DEFAULT=0
+$MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m 2>&1 | grep -q crc=1
+if [ $? -eq 0 ]; then
+	XFS_MKFS_CRC_DEFAULT=1
+fi
 rm -f /tmp/crc_check.img
+
 export XFS_MKFS_HAS_NO_META_SUPPORT
+export XFS_MKFS_CRC_DEFAULT
 
 # new doesn't need config file parsed, we can stop here
 if [ "$iam" == "new" ]; then
tests/xfs/259 +1 -3
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then
 	blocksize=1024
 	sizes_to_check="1024 2048 4096"
 	echo "Trying to make (4 TB - 512) B long xfs fs image"
Signature · 1 line
2.5.5
#2 lore raw
In reply to Eryu Guan
Quoted 25 lines · Eryu Guan

Currently xfs/259 checks $TEST_DIR for CRC support status to determine if 512 block size should be tested. But this doesn't always work. For example, when TEST_DEV is mkfs'ed with "-m crc=0" mkfs option, using mkfs.xfs binary with CRC being the default.

What should be really checked is whether mkfs.xfs creates CRC enabled XFS by default. So introduce a new flag XFS_MKFS_CRC_DEFAULT for this purpose, and do the check based on it in xfs/259.

---

This is actually the second attempt to fix this issue, because Christoph was not satisfied with the first attempt, and me either (after thinking about it more :-)). Hope it works this time.

 common/config | 8 ++++++++
 tests/xfs/259 | 4 +---
 2 files changed, 9 insertions(+), 3 deletions(-)
common/config +0 -0
index cacd815..13bd307 100644

common/config $MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \ · line 279

Quoted 10 lines
common/config +6 -0
@@ -270,8 +270,16 @@ $MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
 if [ $? -ne 0 ]; then
 	XFS_MKFS_HAS_NO_META_SUPPORT=true
 fi
+# check if v5 xfs is default
+XFS_MKFS_CRC_DEFAULT=0
+$MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m 2>&1 | grep -q crc=1
+if [ $? -eq 0 ]; then
+	XFS_MKFS_CRC_DEFAULT=1
+fi
 rm -f /tmp/crc_check.img

That tests the mkfs configuration that is applied to the scratch device....

tests/xfs/259 testfile=$TEST_DIR/259.image · line 55

Quoted 10 lines
tests/xfs/259 +0 -2
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs

This tests the configuration of the test device, which is not controlled by the test harness, so can be different to the configuration being used for the scratch device.

tests/xfs/259 testfile=$TEST_DIR/259.image · line 54

Quoted 2 lines
tests/xfs/259 +1 -1
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then

IOWs, this is not an not equivalent test.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw
Quoted 15 lines · Dave Chinner

tests/xfs/259 testfile=$TEST_DIR/259.image · line 55

Quoted 10 lines
tests/xfs/259 +0 -2
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs

This tests the configuration of the test device, which is not controlled by the test harness, so can be different to the configuration being used for the scratch device.

Quoted 4 lines

tests/xfs/259 testfile=$TEST_DIR/259.image · line 54

Quoted 2 lines
tests/xfs/259 +1 -1
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then

IOWs, this is not an not equivalent test.

And I think that's the whole point of this change :)

Previously it tested what the TEST_DIR did, which was wrong for this test. Now it tests what mkfs does by default (including for the scratch dev), which is what we really want here.

#4 lore raw
Quoted 21 lines · Christoph Hellwig
Quoted 15 lines · Dave Chinner

tests/xfs/259 testfile=$TEST_DIR/259.image · line 55

Quoted 10 lines
tests/xfs/259 +0 -2
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs

This tests the configuration of the test device, which is not controlled by the test harness, so can be different to the configuration being used for the scratch device.

Quoted 4 lines

tests/xfs/259 testfile=$TEST_DIR/259.image · line 54

Quoted 2 lines
tests/xfs/259 +1 -1
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then

IOWs, this is not an not equivalent test.

Quoted 5 lines

And I think that's the whole point of this change :)

Previously it tested what the TEST_DIR did, which was wrong for this test. Now it tests what mkfs does by default (including for the scratch dev), which is what we really want here.

Which is not at all clear from the patch description.

Seriously, though, this does not belong in common/config. We already have a helper function to check what mkfs supports (i.e.
_scratch_mkfs_xfs_supported()), and if we just want a bare check
then factor this into a _mkfs_xfs_supported() and supply the parameters specific to the test.

Indeed, this is basically what we do with _require_xfs_mkfs_crc(); the same thing should be done, but without the "notrun" if -m crc s not supported...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#5 lore raw
Quoted 28 lines · Dave Chinner
Quoted 21 lines · Christoph Hellwig
Quoted 15 lines · Dave Chinner

tests/xfs/259 testfile=$TEST_DIR/259.image · line 55

Quoted 10 lines
tests/xfs/259 +0 -2
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs

This tests the configuration of the test device, which is not controlled by the test harness, so can be different to the configuration being used for the scratch device.

Quoted 4 lines

tests/xfs/259 testfile=$TEST_DIR/259.image · line 54

Quoted 2 lines
tests/xfs/259 +1 -1
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then

IOWs, this is not an not equivalent test.

Quoted 5 lines

And I think that's the whole point of this change :)

Previously it tested what the TEST_DIR did, which was wrong for this test. Now it tests what mkfs does by default (including for the scratch dev), which is what we really want here.

Quoted 7 lines

Which is not at all clear from the patch description.

Seriously, though, this does not belong in common/config. We already have a helper function to check what mkfs supports (i.e.
_scratch_mkfs_xfs_supported()), and if we just want a bare check
then factor this into a _mkfs_xfs_supported() and supply the parameters specific to the test.

Will do.

Quoted 4 lines

Indeed, this is basically what we do with _require_xfs_mkfs_crc(); the same thing should be done, but without the "notrun" if -m crc s not supported...

Thanks for reviewing!

Eryu

author
#6 lore raw
In reply to Dave Chinner
Quoted 36 lines · Dave Chinner
Quoted 21 lines · Christoph Hellwig
Quoted 15 lines · Dave Chinner

tests/xfs/259 testfile=$TEST_DIR/259.image · line 55

Quoted 10 lines
tests/xfs/259 +0 -2
index 16c1935..3150ff3 100755
@@ -51,9 +51,7 @@ testfile=$TEST_DIR/259.image
 # Test various sizes slightly less than 4 TB. Need to handle different
 # minimum block sizes for CRC enabled filesystems, but use a small log so we
 # don't write lots of zeros unnecessarily.
-xfs_info $TEST_DIR | _filter_mkfs 2> $tmp.mkfs > /dev/null
-. $tmp.mkfs

This tests the configuration of the test device, which is not controlled by the test harness, so can be different to the configuration being used for the scratch device.

Quoted 4 lines

tests/xfs/259 testfile=$TEST_DIR/259.image · line 54

Quoted 2 lines
tests/xfs/259 +1 -1
-if [ $_fs_has_crcs -eq 1 ]; then
+if [ $XFS_MKFS_CRC_DEFAULT -eq 1 ]; then

IOWs, this is not an not equivalent test.

Quoted 5 lines

And I think that's the whole point of this change :)

Previously it tested what the TEST_DIR did, which was wrong for this test. Now it tests what mkfs does by default (including for the scratch dev), which is what we really want here.

Which is not at all clear from the patch description.

Seriously, though, this does not belong in common/config. We already have a helper function to check what mkfs supports (i.e.
_scratch_mkfs_xfs_supported()), and if we just want a bare check
then factor this into a _mkfs_xfs_supported() and supply the parameters specific to the test.

Quoted 3 lines

Indeed, this is basically what we do with _require_xfs_mkfs_crc(); the same thing should be done, but without the "notrun" if -m crc s not supported...

Looking into _require_xfs_mkfs_crc() and _scratch_mkfs_xfs_supported(), I noticed that they are not the helpers I want. They are testing whether mkfs.xfs supports CRC (or other mkfs options), what I want is what's the default behavior of mkfs.xfs (CRC enabled or not).

Maybe I can just move the detection code to common/rc?

Thanks,
Eryu

#7 lore raw
Quoted 9 lines · Eryu Guan
Quoted 8 lines · Dave Chinner

Which is not at all clear from the patch description.

Seriously, though, this does not belong in common/config. We already have a helper function to check what mkfs supports (i.e.
_scratch_mkfs_xfs_supported()), and if we just want a bare check
then factor this into a _mkfs_xfs_supported() and supply the parameters specific to the test.

Quoted 8 lines
Quoted 3 lines

Indeed, this is basically what we do with _require_xfs_mkfs_crc(); the same thing should be done, but without the "notrun" if -m crc s not supported...

Looking into _require_xfs_mkfs_crc() and _scratch_mkfs_xfs_supported(), I noticed that they are not the helpers I want. They are testing whether mkfs.xfs supports CRC (or other mkfs options), what I want is what's the default behavior of mkfs.xfs (CRC enabled or not).

All this, just to avoid testing on an invalid block size when CRCs are enabled. I really don't see why this needs changes to generic infrastructure - it's a test specific problem.

How about you simply reverse the block size order that is tested, and capture the output of the actual mkfs command that is being tested, and determine if 512 byte block sizes should be tested based on that output? i.e.

for b in 4096 2038 1024 512; do

	if [ $b -eq 512 -a $_fs_has_crcs -ne 1 ]; then
		break;
	fi
....
	mkfs -b $b ....
	. $tmp.mkfs

done

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]