All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] common/attr: make _require_attrs more fine-grained
@ 2020-09-10 19:43 Frank van der Linden
  2020-09-10 19:43 ` [PATCH 2/3] common/attr: set MAX_ATTR values correctly for NFS Frank van der Linden
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Frank van der Linden @ 2020-09-10 19:43 UTC (permalink / raw)
  To: fstests; +Cc: linux-nfs, Frank van der Linden

Filesystems may not support all xattr types. But, _require_attr assumes
that being able to use "user" namespace xattrs means that all namespaces
("trusted", "system", etc) are supported. This breaks on NFS, that only
supports the "user" namespace, and a few cases in the "system" namespace.

Change _require_attrs to optionally take namespace arguments that specify
the namespaces to check for. The default behavior (no arguments) is still
to check for the "user" namespace only.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 common/attr | 49 +++++++++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/common/attr b/common/attr
index 20049de0..c60cb6ed 100644
--- a/common/attr
+++ b/common/attr
@@ -175,30 +175,43 @@ _list_acl()
 
 _require_attrs()
 {
+    local args
+    local nsp
+
+    if [ $# -eq 0 ];
+    then
+      args="user"
+    else
+      args="$*"
+    fi
+
     [ -n "$ATTR_PROG" ] || _notrun "attr command not found"
     [ -n "$GETFATTR_PROG" ] || _notrun "getfattr command not found"
     [ -n "$SETFATTR_PROG" ] || _notrun "setfattr command not found"
 
-    #
-    # Test if chacl is able to write an attribute 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 attributes.  Note that we can't simply list attributes as
-    # various security modules generate synthetic attributes not actually
-    # stored on disk.
-    #
-    touch $TEST_DIR/syscalltest
-    attr -s "user.xfstests" -V "attr" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-    cat $TEST_DIR/syscalltest.out >> $seqres.full
+    for nsp in $args
+    do
+      #
+      # Test if chacl is able to write an attribute 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 attributes.  Note that we can't simply list attributes as
+      # various security modules generate synthetic attributes not actually
+      # stored on disk.
+      #
+      touch $TEST_DIR/syscalltest
+      $SETFATTR_PROG -n "$nsp.xfstests" -v "attr" $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
-      _notrun "kernel does not support attrs"
-    fi
-    if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
-      _notrun "attrs not supported by this filesystem type: $FSTYP"
-    fi
+      if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
+        _notrun "kernel does not support attrs"
+      fi
+      if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
+        _notrun "attr namespace $nsp not supported by this filesystem type: $FSTYP"
+      fi
 
-    rm -f $TEST_DIR/syscalltest.out
+      rm -f $TEST_DIR/syscalltest.out
+    done
 }
 
 _require_attr_v1()
-- 
2.16.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] common/attr: set MAX_ATTR values correctly for NFS
  2020-09-10 19:43 [PATCH 1/3] common/attr: make _require_attrs more fine-grained Frank van der Linden
@ 2020-09-10 19:43 ` Frank van der Linden
  2020-09-10 19:43 ` [PATCH 3/3] fstests: explicitly specify xattr namespace Frank van der Linden
  2020-09-13 16:56 ` [PATCH 1/3] common/attr: make _require_attrs more fine-grained Eryu Guan
  2 siblings, 0 replies; 4+ messages in thread
From: Frank van der Linden @ 2020-09-10 19:43 UTC (permalink / raw)
  To: fstests; +Cc: linux-nfs, Frank van der Linden

Now that NFS can handle user xattrs, set the MAX_ATTR
and MAX_ATTRVAL_SIZE to reflect the applicable limits
for that filesystem.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 common/attr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/attr b/common/attr
index c60cb6ed..fb856449 100644
--- a/common/attr
+++ b/common/attr
@@ -251,7 +251,7 @@ _getfattr()
 
 # set maximum total attr space based on fs type
 case "$FSTYP" in
-xfs|udf|pvfs2|9p|ceph)
+xfs|udf|pvfs2|9p|ceph|nfs)
 	MAX_ATTRS=1000
 	;;
 *)
@@ -271,7 +271,7 @@ xfs|udf|btrfs)
 pvfs2)
 	MAX_ATTRVAL_SIZE=8192
 	;;
-9p|ceph)
+9p|ceph|nfs)
 	MAX_ATTRVAL_SIZE=65536
 	;;
 *)
-- 
2.16.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] fstests: explicitly specify xattr namespace
  2020-09-10 19:43 [PATCH 1/3] common/attr: make _require_attrs more fine-grained Frank van der Linden
  2020-09-10 19:43 ` [PATCH 2/3] common/attr: set MAX_ATTR values correctly for NFS Frank van der Linden
@ 2020-09-10 19:43 ` Frank van der Linden
  2020-09-13 16:56 ` [PATCH 1/3] common/attr: make _require_attrs more fine-grained Eryu Guan
  2 siblings, 0 replies; 4+ messages in thread
From: Frank van der Linden @ 2020-09-10 19:43 UTC (permalink / raw)
  To: fstests; +Cc: linux-nfs, Frank van der Linden

Explicitly specify the xattr namespace required for tests.
This allows tests to be skipped correctly for filesystems
that don't support all xattr namespaces.

This changes all tests that require anything other than
the "user" xattr namespace. When called without arguments
as before, _require_attrs() still defaults to the "user"
namespace, so those tests do not need to be changed.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 tests/generic/062 | 4 ++++
 tests/generic/093 | 2 +-
 tests/generic/097 | 2 +-
 tests/generic/403 | 2 +-
 tests/generic/449 | 2 +-
 tests/overlay/011 | 2 +-
 tests/overlay/026 | 2 +-
 tests/overlay/038 | 2 +-
 tests/overlay/041 | 2 +-
 tests/overlay/045 | 2 +-
 tests/overlay/046 | 2 +-
 tests/overlay/056 | 2 +-
 tests/xfs/063     | 2 +-
 tests/xfs/267     | 2 +-
 tests/xfs/268     | 2 +-
 15 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/tests/generic/062 b/tests/generic/062
index cab4b4fa..78c1c95c 100755
--- a/tests/generic/062
+++ b/tests/generic/062
@@ -82,6 +82,10 @@ else
     ATTR_MODES="user trusted"
     ATTR_FILTER="^(user|trusted)"
 fi
+
+_require_attrs $ATTR_MODES
+
+
 for nsp in $ATTR_MODES; do
 	for inode in reg dir lnk dev/b dev/c dev/p; do
 
diff --git a/tests/generic/093 b/tests/generic/093
index 10fdcfc7..7ffcfb7d 100755
--- a/tests/generic/093
+++ b/tests/generic/093
@@ -35,7 +35,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_test
-_require_attrs
+_require_attrs security
 _require_user
 _require_test_program "writemod"
 _require_command "$SETCAP_PROG" "setcap"
diff --git a/tests/generic/097 b/tests/generic/097
index 39730bb0..c2c82460 100755
--- a/tests/generic/097
+++ b/tests/generic/097
@@ -48,7 +48,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_test
-_require_attrs
+_require_attrs user trusted
 
 echo -e "\ncreate file foo"
 rm -f $file
diff --git a/tests/generic/403 b/tests/generic/403
index 39c64061..9d9ea539 100755
--- a/tests/generic/403
+++ b/tests/generic/403
@@ -36,7 +36,7 @@ rm -f $seqres.full
 _supported_fs generic
 _supported_os Linux
 _require_scratch
-_require_attrs
+_require_attrs trusted
 
 _scratch_mkfs > $seqres.full 2>&1 || _fail "mkfs"
 _scratch_mount
diff --git a/tests/generic/449 b/tests/generic/449
index 21b920bf..129ac9a8 100755
--- a/tests/generic/449
+++ b/tests/generic/449
@@ -39,7 +39,7 @@ _supported_os Linux
 _require_scratch
 _require_test
 _require_acls
-_require_attrs
+_require_attrs trusted
 
 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
 _scratch_mount || _fail "mount failed"
diff --git a/tests/overlay/011 b/tests/overlay/011
index 1d09341b..b491c37a 100755
--- a/tests/overlay/011
+++ b/tests/overlay/011
@@ -37,7 +37,7 @@ _supported_fs overlay
 _supported_os Linux
 _require_test
 _require_scratch
-_require_attrs
+_require_attrs trusted
 
 # Remove all files from previous tests
 _scratch_mkfs
diff --git a/tests/overlay/026 b/tests/overlay/026
index d0d2a5bf..84fc2412 100755
--- a/tests/overlay/026
+++ b/tests/overlay/026
@@ -53,7 +53,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch
-_require_attrs
+_require_attrs trusted
 
 # Remove all files from previous tests
 _scratch_mkfs
diff --git a/tests/overlay/038 b/tests/overlay/038
index 25f9979b..98267d33 100755
--- a/tests/overlay/038
+++ b/tests/overlay/038
@@ -32,7 +32,7 @@ _supported_os Linux
 # Use non-default scratch underlying overlay dirs, we need to check
 # them explicity after test.
 _require_scratch_nocheck
-_require_attrs
+_require_attrs trusted
 _require_test_program "t_dir_type"
 
 rm -f $seqres.full
diff --git a/tests/overlay/041 b/tests/overlay/041
index 277fb913..d23de4f9 100755
--- a/tests/overlay/041
+++ b/tests/overlay/041
@@ -35,7 +35,7 @@ _supported_os Linux
 # them explicity after test.
 _require_scratch_nocheck
 _require_test
-_require_attrs
+_require_attrs trusted
 _require_test_program "t_dir_type"
 
 rm -f $seqres.full
diff --git a/tests/overlay/045 b/tests/overlay/045
index 34b7ce4c..e5e65734 100755
--- a/tests/overlay/045
+++ b/tests/overlay/045
@@ -33,7 +33,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch_nocheck
-_require_attrs
+_require_attrs trusted
 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
 
 OVL_XATTR_OPAQUE_VAL=y
diff --git a/tests/overlay/046 b/tests/overlay/046
index 36c74207..fe912ff3 100755
--- a/tests/overlay/046
+++ b/tests/overlay/046
@@ -33,7 +33,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch_nocheck
-_require_attrs
+_require_attrs trusted
 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
 
 # remove all files from previous tests
diff --git a/tests/overlay/056 b/tests/overlay/056
index dc7b98cb..35169c36 100755
--- a/tests/overlay/056
+++ b/tests/overlay/056
@@ -33,7 +33,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch_nocheck
-_require_attrs
+_require_attrs trusted
 _require_command "$FSCK_OVERLAY_PROG" fsck.overlay
 
 OVL_XATTR_IMPURE_VAL=y
diff --git a/tests/xfs/063 b/tests/xfs/063
index b6d4c03a..85ab1aa8 100755
--- a/tests/xfs/063
+++ b/tests/xfs/063
@@ -32,7 +32,7 @@ _cleanup()
 _supported_fs xfs
 _supported_os Linux
 
-_require_attrs
+_require_attrs trusted user
 
 # create files with EAs
 _create_dumpdir_fill_ea
diff --git a/tests/xfs/267 b/tests/xfs/267
index d13ec19a..f0c60350 100755
--- a/tests/xfs/267
+++ b/tests/xfs/267
@@ -52,7 +52,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_tape $TAPE_DEV
-_require_attrs
+_require_attrs trusted
 
 _create_files
 _erase_hard
diff --git a/tests/xfs/268 b/tests/xfs/268
index fa5b9283..07034671 100755
--- a/tests/xfs/268
+++ b/tests/xfs/268
@@ -55,7 +55,7 @@ _supported_fs xfs
 _supported_os Linux
 
 _require_tape $TAPE_DEV
-_require_attrs
+_require_attrs trusted user
 
 _create_files
 _erase_hard
-- 
2.16.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] common/attr: make _require_attrs more fine-grained
  2020-09-10 19:43 [PATCH 1/3] common/attr: make _require_attrs more fine-grained Frank van der Linden
  2020-09-10 19:43 ` [PATCH 2/3] common/attr: set MAX_ATTR values correctly for NFS Frank van der Linden
  2020-09-10 19:43 ` [PATCH 3/3] fstests: explicitly specify xattr namespace Frank van der Linden
@ 2020-09-13 16:56 ` Eryu Guan
  2 siblings, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2020-09-13 16:56 UTC (permalink / raw)
  To: Frank van der Linden; +Cc: fstests, linux-nfs

On Thu, Sep 10, 2020 at 07:43:53PM +0000, Frank van der Linden wrote:
> Filesystems may not support all xattr types. But, _require_attr assumes
> that being able to use "user" namespace xattrs means that all namespaces
> ("trusted", "system", etc) are supported. This breaks on NFS, that only
> supports the "user" namespace, and a few cases in the "system" namespace.
> 
> Change _require_attrs to optionally take namespace arguments that specify
> the namespaces to check for. The default behavior (no arguments) is still
> to check for the "user" namespace only.
> 
> Signed-off-by: Frank van der Linden <fllinden@amazon.com>

This patchset looks great to me, thanks!

Some minor nits below (and I've fixed them on commit, so there's no need
to resend :)

> ---
>  common/attr | 49 +++++++++++++++++++++++++++++++------------------
>  1 file changed, 31 insertions(+), 18 deletions(-)
> 
> diff --git a/common/attr b/common/attr
> index 20049de0..c60cb6ed 100644
> --- a/common/attr
> +++ b/common/attr
> @@ -175,30 +175,43 @@ _list_acl()
>  
>  _require_attrs()
>  {
> +    local args
> +    local nsp
> +
> +    if [ $# -eq 0 ];
> +    then

We prefer the following coding style in fstests

	if [ $# -eq 0 ]; then
		args="user"
	else
		args="$*"
	fi

> +      args="user"
> +    else
> +      args="$*"
> +    fi

And you've almost re-written the whole _require_attrs(), it's better to
use tab as indention instead of 4 spaces (we're in the (very slow)
progress converting all 4-spaces indention to tab, except there're old
code using 4-spaces around).

> +
>      [ -n "$ATTR_PROG" ] || _notrun "attr command not found"
>      [ -n "$GETFATTR_PROG" ] || _notrun "getfattr command not found"
>      [ -n "$SETFATTR_PROG" ] || _notrun "setfattr command not found"
>  
> -    #
> -    # Test if chacl is able to write an attribute 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 attributes.  Note that we can't simply list attributes as
> -    # various security modules generate synthetic attributes not actually
> -    # stored on disk.
> -    #
> -    touch $TEST_DIR/syscalltest
> -    attr -s "user.xfstests" -V "attr" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
> -    cat $TEST_DIR/syscalltest.out >> $seqres.full
> +    for nsp in $args
> +    do

Same here, use the format below

	for nsp in $args; do
		<do things here>
	done

Thanks,
Eryu

> +      #
> +      # Test if chacl is able to write an attribute 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 attributes.  Note that we can't simply list attributes as
> +      # various security modules generate synthetic attributes not actually
> +      # stored on disk.
> +      #
> +      touch $TEST_DIR/syscalltest
> +      $SETFATTR_PROG -n "$nsp.xfstests" -v "attr" $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
> -      _notrun "kernel does not support attrs"
> -    fi
> -    if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
> -      _notrun "attrs not supported by this filesystem type: $FSTYP"
> -    fi
> +      if grep -q 'Function not implemented' $TEST_DIR/syscalltest.out; then
> +        _notrun "kernel does not support attrs"
> +      fi
> +      if grep -q 'Operation not supported' $TEST_DIR/syscalltest.out; then
> +        _notrun "attr namespace $nsp not supported by this filesystem type: $FSTYP"
> +      fi
>  
> -    rm -f $TEST_DIR/syscalltest.out
> +      rm -f $TEST_DIR/syscalltest.out
> +    done
>  }
>  
>  _require_attr_v1()
> -- 
> 2.16.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-13 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 19:43 [PATCH 1/3] common/attr: make _require_attrs more fine-grained Frank van der Linden
2020-09-10 19:43 ` [PATCH 2/3] common/attr: set MAX_ATTR values correctly for NFS Frank van der Linden
2020-09-10 19:43 ` [PATCH 3/3] fstests: explicitly specify xattr namespace Frank van der Linden
2020-09-13 16:56 ` [PATCH 1/3] common/attr: make _require_attrs more fine-grained Eryu Guan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.