Skip to contentSkip to conversation

fstests: add appropriate checks for fs features for some tests

PATCH Superseded Jeff Layton 4 participants 15 messages Aug 24, 2023 – Aug 28, 2023

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

v2 cover fstests: add appropriate checks for fs features for some tests

A number of fstests fail on NFS, primarily because it lacks certain features that are widely supported on local filesystems. This set fixes up the test for POSIX ACLs and adds new checks for FIEMAP and file capability support on tests that require these features.

---
Jeff Layton (3):
common/attr: fix the _require_acl test generic/513: limit to filesystems that support capabilities generic/578: only run on filesystems that support FIEMAP

 common/attr       |  9 ++++-----
 common/rc         | 26 ++++++++++++++++++++++++++
 tests/generic/513 |  1 +
 tests/generic/578 |  1 +
 4 files changed, 32 insertions(+), 5 deletions(-)

---
base-commit: 8de535c53887bb49adae74a1b2e83e77d7e8457d
change-id: 20230824-fixes-914cc3f9ef72

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/3 common/attr: fix the _require_acl test

_require_acl tests whether you're able to fetch the ACL from a file using chacl, and then tests for an -EOPNOTSUPP error return. Unfortunately, filesystems that don't support them (like NFSv4) just return -ENODATA when someone calls getxattr for the POSIX ACL, so the test doesn't work.

Fix the test to have chacl set an ACL on the file instead, which should reliably fail on filesystems that don't support them.

---
 common/attr | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
common/attr +4 -5
index cce4d1b201b2..3ebba682c894 100644
@@ -163,13 +163,12 @@ _require_acls()
     [ -n "$CHACL_PROG" ] || _notrun "chacl command not found"
 
     #
-    # Test if chacl is able to list ACLs on the target filesystems.  On really
-    # old kernels the system calls might not be implemented at all, but the
-    # more common case is that the tested filesystem simply doesn't support
-    # ACLs.
+    # Test if chacl is able to set an ACL on a file.  On really old kernels
+    # the system calls might not be implemented at all, but the more common
+    # case is that the tested filesystem simply doesn't support ACLs.
     #
     touch $TEST_DIR/syscalltest
-    chacl -l $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+    chacl 'u::rw-,g::---,o::---' $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
     cat $TEST_DIR/syscalltest.out >> $seqres.full
 
     if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
Signature · 1 line
2.41.0
author maintainer
#2 lore raw

PATCH v2 2/3 generic/513: limit to filesystems that support capabilities

In reply to Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +13 -0
index 5c4429ed0425..33e74d20c28b 100644
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "File capabilities are not supported on this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}
+
 _getcap()
 {
 	$GETCAP_PROG "$@" | _filter_getcap
tests/generic/513 +1 -0
index dc082787ae4e..52f9eb916b4a 100755
@@ -18,6 +18,7 @@ _supported_fs generic
 _require_scratch_reflink
 _require_command "$GETCAP_PROG" getcap
 _require_command "$SETCAP_PROG" setcap
+_require_setcap
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
Signature · 1 line
2.41.0
#3 lore raw

Re: [PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

Quoted 15 lines · Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 5c4429ed0425..33e74d20c28b 100644

common/rc _require_mknod() · line 5056

Quoted 9 lines
common/rc +6 -0
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1

Actually we talked about the capabilities checking helper last year, as below:

https://lore.kernel.org/fstests/20220323023845.saj5en74km7aibdx@zlang-mailbox/

As you bring this discussion back, how about the _require_capabilities() in above link?

Thanks,
Zorro

Quoted 26 lines
common/rc +7 -0
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "File capabilities are not supported on this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}
+
 _getcap()
 {
 	$GETCAP_PROG "$@" | _filter_getcap
tests/generic/513 +1 -0
index dc082787ae4e..52f9eb916b4a 100755
@@ -18,6 +18,7 @@ _supported_fs generic
 _require_scratch_reflink
 _require_command "$GETCAP_PROG" getcap
 _require_command "$SETCAP_PROG" setcap
+_require_setcap
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount
Signature · 2 lines
-- 
2.41.0
author maintainer
#4 lore raw

Re: [PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

Quoted 28 lines · Zorro Lang
Quoted 15 lines · Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 5c4429ed0425..33e74d20c28b 100644

common/rc _require_mknod() · line 5056

Quoted 9 lines
common/rc +6 -0
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1

Actually we talked about the capabilities checking helper last year, as below:

Quoted 5 lines

https://lore.kernel.org/fstests/20220323023845.saj5en74km7aibdx@zlang-mailbox/

As you bring this discussion back, how about the _require_capabilities() in above link?

I was testing a similar patch, but your version looks better. Should I drop mine and you re-post yours?

Thanks,
--
Jeff Layton <[email protected]>

#5 lore raw

Re: [PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

Quoted 29 lines · Jeff Layton
Quoted 28 lines · Zorro Lang
Quoted 15 lines · Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 5c4429ed0425..33e74d20c28b 100644

common/rc _require_mknod() · line 5056

Quoted 9 lines
common/rc +6 -0
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1

Actually we talked about the capabilities checking helper last year, as below:

Quoted 8 lines
Quoted 5 lines

https://lore.kernel.org/fstests/20220323023845.saj5en74km7aibdx@zlang-mailbox/

As you bring this discussion back, how about the _require_capabilities() in above link?

I was testing a similar patch, but your version looks better. Should I drop mine and you re-post yours?

Actually we decided to use _require_attrs security, rather than a new _require_capabilities() helper. We need a chance/requirement to add that helper (when a test case really need it).

So I hope know is _require_attrs security enough for you? Or you really need a specific _require_capabilities helper?

Thanks,
Zorro

Quoted 5 lines

Thanks,
--
Jeff Layton <[email protected]>

author maintainer
#6 lore raw

Re: [PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

Quoted 43 lines · Zorro Lang
Quoted 29 lines · Jeff Layton
Quoted 28 lines · Zorro Lang
Quoted 15 lines · Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 5c4429ed0425..33e74d20c28b 100644

common/rc _require_mknod() · line 5056

Quoted 9 lines
common/rc +6 -0
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1

Actually we talked about the capabilities checking helper last year, as below:

Quoted 8 lines
Quoted 5 lines

https://lore.kernel.org/fstests/20220323023845.saj5en74km7aibdx@zlang-mailbox/

As you bring this discussion back, how about the _require_capabilities() in above link?

I was testing a similar patch, but your version looks better. Should I drop mine and you re-post yours?

Actually we decided to use _require_attrs security, rather than a new _require_capabilities() helper. We need a chance/requirement to add that helper (when a test case really need it).

Quoted 7 lines

So I hope know is _require_attrs security enough for you? Or you really need a specific _require_capabilities helper?

Thanks,
Zorro

Yeah, it looks like that should work:

generic/513 [not run] attr namespace security not supported by this filesystem type: nfs

I'll plan to respin this patch to add that instead.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>
#7 lore raw

Re: [PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

Quoted 53 lines · Jeff Layton
Quoted 43 lines · Zorro Lang
Quoted 29 lines · Jeff Layton
Quoted 28 lines · Zorro Lang
Quoted 15 lines · Jeff Layton

This test requires being able to set file capabilities which some filesystems (namely NFS) do not support. Add a _require_setcap test and only run it on filesystems that pass it.

---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 5c4429ed0425..33e74d20c28b 100644

common/rc _require_mknod() · line 5056

Quoted 9 lines
common/rc +6 -0
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1

Actually we talked about the capabilities checking helper last year, as below:

Quoted 8 lines
Quoted 5 lines

https://lore.kernel.org/fstests/20220323023845.saj5en74km7aibdx@zlang-mailbox/

As you bring this discussion back, how about the _require_capabilities() in above link?

I was testing a similar patch, but your version looks better. Should I drop mine and you re-post yours?

Actually we decided to use _require_attrs security, rather than a new _require_capabilities() helper. We need a chance/requirement to add that helper (when a test case really need it).

Quoted 7 lines

So I hope know is _require_attrs security enough for you? Or you really need a specific _require_capabilities helper?

Thanks,
Zorro

Quoted 5 lines

Yeah, it looks like that should work:

generic/513 [not run] attr namespace security not supported by this filesystem type: nfs

I'll plan to respin this patch to add that instead.

Thanks:) I saw you've sent a V3:
[PATCH fstests v3 0/2] fstests: add appropriate checks for fs features for some tests

so will you sent a V4 contains 3 patches?

Thanks,
Zorro

Quoted 5 lines

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#8 lore raw

PATCH v2 3/3 generic/578: only run on filesystems that support FIEMAP

In reply to Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +13 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +1 -0
index b024f6ff90b4..903055b2ca58 100755
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap
 
 compare() {
 	for i in $(seq 1 8); do
Signature · 1 line
2.41.0
#9 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 19 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +2 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
+_require_fiemap()
+{

common/rc _require_metadata_journaling() · line 3899

Quoted 10 lines
common/rc +10 -0
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

--D

Quoted 20 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +1 -0
index b024f6ff90b4..903055b2ca58 100755
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap
 
 compare() {
 	for i in $(seq 1 8); do
Signature · 2 lines
-- 
2.41.0
author maintainer
#10 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
Quoted 16 lines

common/rc _require_metadata_journaling() · line 3899

Quoted 12 lines
common/rc +12 -0
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

Ok, I figured we'd probably do this test after testing for that separately, but you're correct that we do require it here.

If we add that, should we also do this, at least in all of the general tests?

s/_require_xfs_io_command "fiemap"/_require_fiemap/

I think we end up excluding some of those tests on NFS for other reasons, but other filesystems that don't support fiemap might still try to run these tests.

Quoted 20 lines
Quoted 20 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +1 -0
index b024f6ff90b4..903055b2ca58 100755
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap
 
 compare() {
 	for i in $(seq 1 8); do
Signature · 2 lines
-- 
2.41.0
Signature · 1 line
Jeff Layton <[email protected]>
#11 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 39 lines · Jeff Layton
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
Quoted 16 lines

common/rc _require_metadata_journaling() · line 3899

Quoted 12 lines
common/rc +12 -0
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

Ok, I figured we'd probably do this test after testing for that separately, but you're correct that we do require it here.

Quoted 8 lines

If we add that, should we also do this, at least in all of the general tests?

s/_require_xfs_io_command "fiemap"/_require_fiemap/

I think we end up excluding some of those tests on NFS for other reasons, but other filesystems that don't support fiemap might still try to run these tests.

We have lots of cases contains _require_xfs_io_command "fiemap", so I think we can keep this "tradition", don't bring a new _require_fiemap for now, so ...

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +0 -0
index b024f6ff90b4..903055b2ca58 100755

tests/generic/578 _require_test_program "mmap-write-concurrent" · line 29

Quoted 4 lines
tests/generic/578 +1 -0
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap

_require_xfs_io_command "fiemap"

Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
tests/generic/578 +0 -0
 compare() {
 	for i in $(seq 1 8); do
 
Signature · 1 line
2.41.0
Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#12 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 54 lines · Zorro Lang
Quoted 39 lines · Jeff Layton
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
Quoted 16 lines

common/rc _require_metadata_journaling() · line 3899

Quoted 12 lines
common/rc +12 -0
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

Ok, I figured we'd probably do this test after testing for that separately, but you're correct that we do require it here.

Quoted 8 lines

If we add that, should we also do this, at least in all of the general tests?

s/_require_xfs_io_command "fiemap"/_require_fiemap/

I think we end up excluding some of those tests on NFS for other reasons, but other filesystems that don't support fiemap might still try to run these tests.

We have lots of cases contains _require_xfs_io_command "fiemap", so I think we can keep this "tradition", don't bring a new _require_fiemap for now, so ...

Quoted 1 line
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +0 -0
Quoted 8 lines
Quoted 8 lines

tests/generic/578 _require_test_program "mmap-write-concurrent" · line 29

Quoted 8 lines

index b024f6ff90b4..903055b2ca58 100755

tests/generic/578 +1 -0
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap

_require_xfs_io_command "fiemap"

That's not sufficient -- there is already a call to that in this test.

_require_xfs_io_command just validates that the xfs_io binary has plumbing for that command (which just issues an ioctl to the file). Even if the binary has support, the underlying filesystem has to support the ioctl.

Many don't, so we need to test for that specifically.

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
tests/generic/578 +0 -0
 compare() {
 	for i in $(seq 1 8); do
 
Signature · 1 line
2.41.0
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>
#13 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 72 lines · Jeff Layton
Quoted 54 lines · Zorro Lang
Quoted 39 lines · Jeff Layton
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
Quoted 16 lines

common/rc _require_metadata_journaling() · line 3899

Quoted 12 lines
common/rc +12 -0
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

Ok, I figured we'd probably do this test after testing for that separately, but you're correct that we do require it here.

Quoted 8 lines

If we add that, should we also do this, at least in all of the general tests?

s/_require_xfs_io_command "fiemap"/_require_fiemap/

I think we end up excluding some of those tests on NFS for other reasons, but other filesystems that don't support fiemap might still try to run these tests.

We have lots of cases contains _require_xfs_io_command "fiemap", so I think we can keep this "tradition", don't bring a new _require_fiemap for now, so ...

Quoted 1 line
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +0 -0
Quoted 8 lines
Quoted 8 lines

tests/generic/578 _require_test_program "mmap-write-concurrent" · line 29

Quoted 8 lines

index b024f6ff90b4..903055b2ca58 100755

tests/generic/578 +1 -0
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap

_require_xfs_io_command "fiemap"

Quoted 8 lines

That's not sufficient -- there is already a call to that in this test.

_require_xfs_io_command just validates that the xfs_io binary has plumbing for that command (which just issues an ioctl to the file). Even if the binary has support, the underlying filesystem has to support the ioctl.

Many don't, so we need to test for that specifically.

It /does/ test the kernel support for fiemap...

_require_xfs_io_command()
{
...

	"fiemap")
		# If 'ranged' is passed as argument then we check to see if fiemap supports
		# ranged query params
		if echo "$param" | grep -q "ranged"; then
			param=$(echo "$param" | sed "s/ranged//")
			$XFS_IO_PROG -c "help fiemap" | grep -q "\[offset \[len\]\]"
			[ $? -eq 0 ] || _notrun "xfs_io $command ranged support is missing"
		fi
		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
			-c "fiemap -v $param" $testfile 2>&1`
		param_checked="$param"
		;;

--D

Quoted 15 lines
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
tests/generic/578 +0 -0
 compare() {
 	for i in $(seq 1 8); do
 
Signature · 1 line
2.41.0
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#14 lore raw

Re: [PATCH fstests v2 3/3] generic/578: only run on filesystems that support FIEMAP

Quoted 87 lines · Darrick J. Wong
Quoted 72 lines · Jeff Layton
Quoted 54 lines · Zorro Lang
Quoted 39 lines · Jeff Layton
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Jeff Layton

Some filesystems (e.g. NFS) don't support FIEMAP. Limit generic/578 to filesystems that do.

---
 common/rc         | 13 +++++++++++++
 tests/generic/578 |  1 +
 2 files changed, 14 insertions(+)
common/rc +0 -0
index 33e74d20c28b..98d27890f6f7 100644
@@ -3885,6 +3885,19 @@ _require_metadata_journaling()
 	fi
 }
 
Quoted 16 lines

common/rc _require_metadata_journaling() · line 3899

Quoted 12 lines
common/rc +12 -0
+_require_fiemap()
+{
+	local testfile=$TEST_DIR/fiemaptest.$$
+
+	touch $testfile
+	$XFS_IO_PROG -r -c "fiemap" $testfile 1>$testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "FIEMAP is not supported by this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}

_require_xfs_io_command "fiemap" ?

Ok, I figured we'd probably do this test after testing for that separately, but you're correct that we do require it here.

Quoted 8 lines

If we add that, should we also do this, at least in all of the general tests?

s/_require_xfs_io_command "fiemap"/_require_fiemap/

I think we end up excluding some of those tests on NFS for other reasons, but other filesystems that don't support fiemap might still try to run these tests.

We have lots of cases contains _require_xfs_io_command "fiemap", so I think we can keep this "tradition", don't bring a new _require_fiemap for now, so ...

Quoted 1 line
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
common/rc +1 -0
+
 _count_extents()
 {
 	$XFS_IO_PROG -r -c "fiemap" $1 | tail -n +2 | grep -v hole | wc -l
tests/generic/578 +0 -0
Quoted 8 lines
Quoted 8 lines

tests/generic/578 _require_test_program "mmap-write-concurrent" · line 29

Quoted 8 lines

index b024f6ff90b4..903055b2ca58 100755

tests/generic/578 +1 -0
@@ -26,6 +26,7 @@ _require_test_program "mmap-write-concurrent"
 _require_command "$FILEFRAG_PROG" filefrag
 _require_test_reflink
 _require_cp_reflink
+_require_fiemap

_require_xfs_io_command "fiemap"

Quoted 8 lines

That's not sufficient -- there is already a call to that in this test.

_require_xfs_io_command just validates that the xfs_io binary has plumbing for that command (which just issues an ioctl to the file). Even if the binary has support, the underlying filesystem has to support the ioctl.

Many don't, so we need to test for that specifically.

It /does/ test the kernel support for fiemap...

_require_xfs_io_command()
{
...

Quoted 13 lines
	"fiemap")
		# If 'ranged' is passed as argument then we check to see if fiemap supports
		# ranged query params
		if echo "$param" | grep -q "ranged"; then
			param=$(echo "$param" | sed "s/ranged//")
			$XFS_IO_PROG -c "help fiemap" | grep -q "\[offset \[len\]\]"
			[ $? -eq 0 ] || _notrun "xfs_io $command ranged support is missing"
		fi
		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
			-c "fiemap -v $param" $testfile 2>&1`
		param_checked="$param"
		;;

I stand corrected! We just need to add this to generic/578, like Zorro suggested:

_require_xfs_io_command "fiemap"

I'll respin the patch to just do that instead.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>