common/attr: make _require_attrs more fine-grained
Subsystems (2)
PATCH 1/3 common/attr: make _require_attrs more fine-grained
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.
--- common/attr | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-)
common/attr +31 -18
@@ -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()
Signature · 1 line
2.16.6
PATCH 2/3 common/attr: set MAX_ATTR values correctly for NFS
Now that NFS can handle user xattrs, set the MAX_ATTR and MAX_ATTRVAL_SIZE to reflect the applicable limits for that filesystem.
--- common/attr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/attr +2 -2
@@ -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 ;; *)
Signature · 1 line
2.16.6
PATCH 3/3 fstests: explicitly specify xattr namespace
In reply to Frank van der LindenExplicitly 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.
--- 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(-)
tests/generic/062 +4 -0
@@ -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
tests/generic/093 +1 -1
@@ -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"
tests/generic/097 +1 -1
@@ -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
tests/generic/403 +1 -1
@@ -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
tests/generic/449 +1 -1
@@ -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"
tests/overlay/011 +1 -1
@@ -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
tests/overlay/026 +1 -1
@@ -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
tests/overlay/038 +1 -1
@@ -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
tests/overlay/041 +1 -1
@@ -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
tests/overlay/045 +1 -1
@@ -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
tests/overlay/046 +1 -1
@@ -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
tests/overlay/056 +1 -1
@@ -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
tests/xfs/063 +1 -1
@@ -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
tests/xfs/267 +1 -1
@@ -52,7 +52,7 @@ _supported_fs xfs _supported_os Linux _require_tape $TAPE_DEV -_require_attrs +_require_attrs trusted _create_files _erase_hard
tests/xfs/268 +1 -1
@@ -55,7 +55,7 @@ _supported_fs xfs _supported_os Linux _require_tape $TAPE_DEV -_require_attrs +_require_attrs trusted user _create_files _erase_hard
Signature · 1 line
2.16.6
Quoted 10 lines · Frank van der Linden
Filesystems may not support all xattr types. But,
_require_attrassumes 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_attrsto 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 <[email protected]>
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 :)
Quoted 9 lines
--- common/attr | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-)common/attr +0
-0
common/attr _list_acl() · line 182
Quoted 8 lines
common/attr +5
-0@@ -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
common/attr _list_acl() · line 186
Quoted 4 lines
common/attr +4
-0+ 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).
Quoted 8 lines
common/attr +1
-3+ [ -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,
common/attr _list_acl() · line 193
Quoted 10 lines
common/attr +2
-8- # 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
Quoted 33 lines
common/attr +19
-7+ # + # 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()Signature · 1 line
2.16.6