xfs: test quota's project ID on special files
PATCH 1/1 xfs: test quota's project ID on special files
With addition of FS_IOC_FSSETXATTRAT xfs_quota now can set project ID on filesystem inodes behind special files. Previously, quota reporting didn't count inodes of special files created before project initialization. Only new inodes had project ID set.
---
Notes:
This is part of the patchset which introduces
FS_IOC_FS[GET|SET]XATTRAT:
https://lore.kernel.org/linux-xfs/[email protected]/T/#t
https://lore.kernel.org/linux-xfs/[email protected]/T/#utests/xfs/608 | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/608.out | 10 +++++++ 2 files changed, 83 insertions(+) create mode 100755 tests/xfs/608 create mode 100644 tests/xfs/608.out
tests/xfs/608 new file +73 -0
@@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Red Hat. All Rights Reserved. +# +# FS QA Test 608 +# +# Test that XFS can set quota project ID on special files +# +. ./common/preamble +_begin_fstest auto quota + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* + rm -f $tmp.proects $tmp.projid +} + + +# Import common functions. +. ./common/quota +. ./common/filter + +# Modify as appropriate. +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_user + +_scratch_mkfs >/dev/null 2>&1 +_qmount_option "pquota" +_scratch_mount +_require_test_program "af_unix" +_require_symlinks +_require_mknod + +function create_af_unix () { + $here/src/af_unix $* || echo af_unix failed +} + +function filter_quota() { + _filter_quota | sed "s~$tmp.proects~PROJECTS_FILE~" +} + +projectdir=$SCRATCH_MNT/prj +id=42 + +mkdir $projectdir +mkfifo $projectdir/fifo +mknod $projectdir/chardev c 1 1 +mknod $projectdir/blockdev b 1 1 +create_af_unix $projectdir/socket +touch $projectdir/foo +ln -s $projectdir/foo $projectdir/symlink +touch $projectdir/bar +ln -s $projectdir/bar $projectdir/broken-symlink +rm -f $projectdir/bar + +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "limit -p isoft=20 ihard=20 $id " $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -cp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "report -inN -p" $SCRATCH_DEV +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -Cp $projectdir $id" $SCRATCH_DEV | filter_quota + +# success, all done +status=0 +exit
tests/xfs/608.out new file +10 -0
@@ -0,0 +1,10 @@ +QA output created by 608 +Setting up project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +Checking project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +#0 3 0 0 00 [--------] +#42 8 20 20 00 [--------] + +Clearing project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1).
Signature · 1 line
2.42.0
Quoted 33 lines · Andrey Albershteyn
With addition of
FS_IOC_FSSETXATTRATxfs_quotanow can set project ID on filesystem inodes behind special files. Previously, quota reporting didn't count inodes of special files created before project initialization. Only new inodes had project ID set.Signed-off-by Andrey Albershteyn <[email protected]>---
Notes:
This is part of the patchset which introduces FS_IOC_FS[GET|SET]XATTRAT: https://lore.kernel.org/linux-xfs/[email protected]/T/#t https://lore.kernel.org/linux-xfs/[email protected]/T/#utests/xfs/608 | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/608.out | 10 +++++++ 2 files changed, 83 insertions(+) create mode 100755 tests/xfs/608 create mode 100644 tests/xfs/608.outtests/xfs/608 new file +7
-0@@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Red Hat. All Rights Reserved. +# +# FS QA Test 608 +# +# Test that XFS can set quota project ID on special files
tests/xfs/608 line 17
Quoted 10 lines
tests/xfs/608 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quota + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* + rm -f $tmp.proects $tmp.projid
Not sure why this is "proects" (is that a misspelling of 'projects'?) but the rm above should take care of these, and then you don't need to redefine _cleanup.
Quoted 4 lines
tests/xfs/608 new file +4
-0+} + + +# Import common functions.
tests/xfs/608 line 31
Quoted 10 lines
tests/xfs/608 new file +10
-0+. ./common/quota +. ./common/filter + +# Modify as appropriate. +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_user + +_scratch_mkfs >/dev/null 2>&1
Perhaps dump the output to $seqres.full?
The rest looks ok to me; thank you for including a test with the new functionality!
--D
Quoted 62 lines
tests/xfs/608 new file +42
-0+_qmount_option "pquota" +_scratch_mount +_require_test_program "af_unix" +_require_symlinks +_require_mknod + +function create_af_unix () { + $here/src/af_unix $* || echo af_unix failed +} + +function filter_quota() { + _filter_quota | sed "s~$tmp.proects~PROJECTS_FILE~" +} + +projectdir=$SCRATCH_MNT/prj +id=42 + +mkdir $projectdir +mkfifo $projectdir/fifo +mknod $projectdir/chardev c 1 1 +mknod $projectdir/blockdev b 1 1 +create_af_unix $projectdir/socket +touch $projectdir/foo +ln -s $projectdir/foo $projectdir/symlink +touch $projectdir/bar +ln -s $projectdir/bar $projectdir/broken-symlink +rm -f $projectdir/bar + +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "limit -p isoft=20 ihard=20 $id " $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -cp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "report -inN -p" $SCRATCH_DEV +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -Cp $projectdir $id" $SCRATCH_DEV | filter_quota + +# success, all done +status=0 +exittests/xfs/608.out new file +10
-0@@ -0,0 +1,10 @@ +QA output created by 608 +Setting up project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +Checking project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +#0 3 0 0 00 [--------] +#42 8 20 20 00 [--------] + +Clearing project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1).Signature · 1 line
2.42.0
Quoted 5 lines · Andrey Albershteyn
With addition of
FS_IOC_FSSETXATTRATxfs_quotanow can set project ID on filesystem inodes behind special files. Previously, quota reporting didn't count inodes of special files created before project initialization. Only new inodes had project ID set.
Quoted 8 lines
Signed-off-by Andrey Albershteyn <[email protected]>---
Notes:
This is part of the patchset which introduces FS_IOC_FS[GET|SET]XATTRAT: https://lore.kernel.org/linux-xfs/[email protected]/T/#t https://lore.kernel.org/linux-xfs/[email protected]/T/#u
So this test fails on old xfsprogs and kernel which doesn't support above feature? Do we need a _require_xxxx helper to skip this test? Or you hope to fail on old kernel to clarify this feature missing?
As this test requires some new patches, better to point out:
_wants_kernel_commit xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx _wants_git_commit xfsprogs xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
Quoted 20 lines
tests/xfs/608 | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/608.out | 10 +++++++ 2 files changed, 83 insertions(+) create mode 100755 tests/xfs/608 create mode 100644 tests/xfs/608.outtests/xfs/608 new file +7
-0@@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Red Hat. All Rights Reserved. +# +# FS QA Test 608 +# +# Test that XFS can set quota project ID on special files
tests/xfs/608 line 17
Quoted 10 lines
tests/xfs/608 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quota + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* + rm -f $tmp.proects $tmp.projid
^^^^
projects? (same below)
And won't "rm -f $tmp.*" help to remove $tmp.proects and $tmp.projid ? If it does, we can remove this _cleanup, just use the default one.
tests/xfs/608 line 29
Quoted 12 lines
tests/xfs/608 new file +12
-0+} + + +# Import common functions. +. ./common/quota +. ./common/filter + +# Modify as appropriate. +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_user
Does this patch use "fsgqa" user/group?
tests/xfs/608 line 33
Quoted 4 lines
tests/xfs/608 new file +4
-0+ +_scratch_mkfs >/dev/null 2>&1 +_qmount_option "pquota" +_scratch_mount
If there's not special reason, we generally do all _require_xxx checking at first, then mkfs & mount.
tests/xfs/608 line 36
Quoted 3 lines
tests/xfs/608 new file +3
-0+_require_test_program "af_unix" +_require_symlinks +_require_mknod
So you might can move above 3 lines over the _scratch_mkfs, looks like they don't need a SCRATCH_DEV with $FSTYP.
tests/xfs/608 line 38
Quoted 2 lines
tests/xfs/608 new file +2
-0+ +function create_af_unix () {
We generally don't use "function", but that's fine if you intend that :)
Thanks,
Zorro
Quoted 55 lines
tests/xfs/608 new file +35
-0+ $here/src/af_unix $* || echo af_unix failed +} + +function filter_quota() { + _filter_quota | sed "s~$tmp.proects~PROJECTS_FILE~" +} + +projectdir=$SCRATCH_MNT/prj +id=42 + +mkdir $projectdir +mkfifo $projectdir/fifo +mknod $projectdir/chardev c 1 1 +mknod $projectdir/blockdev b 1 1 +create_af_unix $projectdir/socket +touch $projectdir/foo +ln -s $projectdir/foo $projectdir/symlink +touch $projectdir/bar +ln -s $projectdir/bar $projectdir/broken-symlink +rm -f $projectdir/bar + +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -sp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "limit -p isoft=20 ihard=20 $id " $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -cp $projectdir $id" $SCRATCH_DEV | filter_quota +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "report -inN -p" $SCRATCH_DEV +$XFS_QUOTA_PROG -D $tmp.proects -P $tmp.projid -x \ + -c "project -Cp $projectdir $id" $SCRATCH_DEV | filter_quota + +# success, all done +status=0 +exittests/xfs/608.out new file +10
-0@@ -0,0 +1,10 @@ +QA output created by 608 +Setting up project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +Checking project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1). +#0 3 0 0 00 [--------] +#42 8 20 20 00 [--------] + +Clearing project 42 (path SCRATCH_MNT/prj)... +Processed 1 (PROJECTS_FILE and cmdline) paths for project 42 with recursion depth infinite (-1).Signature · 1 line
2.42.0
Quoted 15 lines · Zorro Lang
Quoted 5 lines · Andrey Albershteyn
With addition of
FS_IOC_FSSETXATTRATxfs_quotanow can set project ID on filesystem inodes behind special files. Previously, quota reporting didn't count inodes of special files created before project initialization. Only new inodes had project ID set.Quoted 8 lines
Signed-off-by Andrey Albershteyn <[email protected]>---
Notes:
This is part of the patchset which introduces FS_IOC_FS[GET|SET]XATTRAT: https://lore.kernel.org/linux-xfs/[email protected]/T/#t https://lore.kernel.org/linux-xfs/[email protected]/T/#u
Quoted 7 lines
So this test fails on old xfsprogs and kernel which doesn't support above feature? Do we need a
_require_xxxxhelper to skip this test? Or you hope to fail on old kernel to clarify this feature missing?As this test requires some new patches, better to point out:
_wants_kernel_commitxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx_wants_git_commitxfsprogs xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
Sure, thanks, will add it.
Quoted 67 lines
Quoted 21 lines
tests/xfs/608 | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/608.out | 10 +++++++ 2 files changed, 83 insertions(+) create mode 100755 tests/xfs/608 create mode 100644 tests/xfs/608.outtests/xfs/608 new file +7
-0@@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Red Hat. All Rights Reserved. +# +# FS QA Test 608 +# +# Test that XFS can set quota project ID on special filestests/xfs/608 line 17
Quoted 10 lines
tests/xfs/608 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quota + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* + rm -f $tmp.proects $tmp.projid^^^^
projects? (same below)And won't "rm -f $tmp.*" help to remove $tmp.proects and $tmp.projid ? If it does, we can remove this
_cleanup, just use the default one.tests/xfs/608 line 29
Quoted 12 lines
tests/xfs/608 new file +12
-0+} + + +# Import common functions. +. ./common/quota +. ./common/filter + +# Modify as appropriate. +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_userDoes this patch use "fsgqa" user/group?
tests/xfs/608 line 33
Quoted 4 lines
tests/xfs/608 new file +4
-0+ +_scratch_mkfs >/dev/null 2>&1 +_qmount_option "pquota" +_scratch_mountIf there's not special reason, we generally do all
_require_xxxchecking at first, then mkfs & mount.tests/xfs/608 line 36
Quoted 3 lines
tests/xfs/608 new file +3
-0+_require_test_program "af_unix" +_require_symlinks +_require_mknodSo you might can move above 3 lines over the
_scratch_mkfs, looks like they don't need aSCRATCH_DEVwith $FSTYP.
Quoted 8 lines
tests/xfs/608 line 38
Quoted 2 lines
tests/xfs/608 new file +2
-0+ +function create_af_unix () {We generally don't use "function", but that's fine if you intend that :)
Thanks,
Zorro
Thanks, will apply all your suggestions above.
Signature · 1 line
- Andrey