test online label ioctl
PATCH v2 1/1 test online label ioctl
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated xfs_io with the label command and a filesystem that supports it
A slight change here to _require_xfs_io_command as well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.
---
(urgh send as proper new thread, sorry)
This passes on btrfs, _notruns on xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long as xfs_io has the new capability)
V2: Add a max label length helper
Set the proper btrfs max label length o_O oops Filter trailing whitespace from blkid output
common/rc +29 -1
@@ -2158,6 +2158,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands.
@@ -2196,7 +2199,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
@@ -3802,6 +3805,31 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, not including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + MAXLEN=12 + ;; + btrfs) + MAXLEN=255 + ;; + *) + MAXLEN=0 + ;; + esac + + echo $MAXLEN +} + +_require_label_get_max() +{ + if [ $(_label_get_max) -eq 0 ]; then + _notrun "$FSTYP does not define maximum label length" + fi +} + init_rc ################################################################################
tests/generic/479 +0 -0
tests/generic/485 new file +90 -0
90 lines not on this page · raw message
tests/generic/485.out new file +9 -0
@@ -0,0 +1,9 @@ +QA output created by 485 +label = "label.485" +label = "label.485" +SCRATCH_DEV: LABEL="label.485" +SCRATCH_DEV: LABEL="label.485" +label = "label.485" +label: Invalid argument +label = "MAXLABEL" +label: Invalid argument
tests/generic/group +1 -0
@@ -487,3 +487,4 @@ 482 auto metadata replay 483 auto quick log metadata 484 auto quick +485 auto quick
Quoted 53 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports itA slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen <[email protected]>---
(urgh send as proper new thread, sorry)
This passes on btrfs,
_notrunson xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long asxfs_iohas the new capability)V2: Add a max label length helper
Set the proper btrfs max label lengtho_Ooops Filter trailing whitespace from blkid outputcommon/rc +6
-1@@ -2158,6 +2158,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands.@@ -2196,7 +2199,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"@@ -3802,6 +3805,31 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, not including terminating NULL +_label_get_max()
common/rc _require_scratch_feature() · line 3819
Quoted 10 lines
common/rc +10
-0+{ + case $FSTYP in + xfs) + MAXLEN=12 + ;; + btrfs) + MAXLEN=255 + ;; + *) + MAXLEN=0
Why not just _notrun here?
common/rc _require_scratch_feature() · line 3830
Quoted 11 lines
common/rc +11
-0+ ;; + esac + + echo $MAXLEN +} + +_require_label_get_max() +{ + if [ $(_label_get_max) -eq 0 ]; then + _notrun "$FSTYP does not define maximum label length" + fi
And this check can go away?
Also, shouldn't it be _require_online_label_change() ? And then maybe you can move the xfs_io label command check inside it?
Quoted 15 lines
common/rc +15
-0+# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs generic +_supported_os Linux +_require_scratch +_require_xfs_io_command "label" +_require_label_get_max + +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount + +# Make sure we can set & clear the label
common/rc _require_scratch_feature()
Quoted 10 lines
common/rc +10
-0+$XFS_IO_PROG -c "label label.$seq" $SCRATCH_MNT +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that userspace can see it now, while mounted +# NB: some blkid has trailing whitespace, filter it out here +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" + +# And that the it is still there when it's unmounted +_scratch_unmount +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"
Ok, so "LABEL" here is a special blkid match token....
common/rc
Quoted 6 lines
common/rc +6
-0+# And that it persists after a remount +_scratch_mount +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that a too-long label is rejected, beyond the interface max: +LABEL=$(perl -e "print 'l' x 257;")
And now you use it as a variable. Nasty and confusing. Using lower case for local variables is the norm, right? I thought we were only supposed to use upper case for global test harness variables...
But even making it "label" is problematic:
Quoted 1 line
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT
because "label" is an xfs_io command. Perhaps call it "fs_label"?
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 13 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports itA slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen <[email protected]>---
<snip>
Quoted 6 lines
Quoted 6 lines
common/rc +6
-0+# The maximum filesystem label length, not including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + MAXLEN=12
Quoted 8 lines
common/rc _require_scratch_feature() · line 3819
Quoted 6 lines
common/rc +6
-0+ ;; + btrfs) + MAXLEN=255 + ;; + *) + MAXLEN=0Why not just
_notrunhere?
do we want to go through the other steps only to get here and notrun halfway through?
Quoted 5 lines
Quoted 5 lines
common/rc +5
-0+ ;; + esac + + echo $MAXLEN +}
Quoted 8 lines
common/rc _require_scratch_feature() · line 3830
Quoted 6 lines
common/rc +6
-0+ +_require_label_get_max() +{ + if [ $(_label_get_max) -eq 0 ]; then + _notrun "$FSTYP does not define maximum label length" + fiAnd this check can go away?
We'd like to know if all the validations in this can complete before we get started, right? That's why I did it this way.
Quoted 2 lines
Also, shouldn't it be
_require_online_label_change()? And then maybe you can move thexfs_iolabel command check inside it?
Well, we want to know a lot of things:
1) can the kernel code for this filesystem support online label
2) does xfs_io support the label command
3) does this test know the maximum label length to test for this fs
the above stuff is for 3)
Quoted 19 lines
Quoted 19 lines
tests/generic/485 new file +19
-0+# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs generic +_supported_os Linux +_require_scratch +_require_xfs_io_command "label" +_require_label_get_max + +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount + +# Make sure we can set & clear the label +$XFS_IO_PROG -c "label label.$seq" $SCRATCH_MNT +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that userspace can see it now, while mounted
Quoted 8 lines
tests/generic/485 line 68
Quoted 6 lines
tests/generic/485 new file +6
-0+# NB: some blkid has trailing whitespace, filter it out here +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g" + +# And that the it is still there when it's unmounted +_scratch_unmount +blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"Ok, so "LABEL" here is a special blkid match token....
yep
Quoted 10 lines
tests/generic/485 line 75
Quoted 6 lines
tests/generic/485 new file +6
-0+# And that it persists after a remount +_scratch_mount +$XFS_IO_PROG -c "label" $SCRATCH_MNT + +# And that a too-long label is rejected, beyond the interface max: +LABEL=$(perl -e "print 'l' x 257;")And now you use it as a variable. Nasty and confusing. Using lower case for local variables is the norm, right? I thought we were only supposed to use upper case for global test harness variables...
I guess I didn't know about that convention (or forgot)
ok, yeah, that's a little confusing I guess. *shrug* I can change it if you prefer. Obviously the "blkid -s LABEL" must remain "LABEL"
Quoted 5 lines
But even making it "label" is problematic:
Quoted 1 line
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT
because "label" is an
xfs_iocommand. Perhaps call it "fs_label"?
ok
-Eric
Quoted 49 lines · Eric Sandeen
Quoted 13 lines · Dave Chinner
Quoted 12 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports itA slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen <[email protected]>---
<snip>
Quoted 6 lines
Quoted 6 lines
common/rc +6
-0+# The maximum filesystem label length, not including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + MAXLEN=12Quoted 8 lines
common/rc _require_scratch_feature() · line 3819
Quoted 6 lines
common/rc +6
-0+ ;; + btrfs) + MAXLEN=255 + ;; + *) + MAXLEN=0Why not just
_notrunhere?do we want to go through the other steps only to get here and notrun halfway through?
Quoted 5 lines
Quoted 5 lines
common/rc +5
-0+ ;; + esac + + echo $MAXLEN +}Quoted 8 lines
common/rc _require_scratch_feature() · line 3830
Quoted 6 lines
common/rc +6
-0+ +_require_label_get_max() +{ + if [ $(_label_get_max) -eq 0 ]; then + _notrun "$FSTYP does not define maximum label length" + fiAnd this check can go away?
Quoted 2 lines
We'd like to know if all the validations in this can complete before we get started, right? That's why I did it this way.
Sure, just trying to be a bit defensive as people often forget _requires directives when writing new tests....
Quoted 10 lines
Quoted 2 lines
Also, shouldn't it be
_require_online_label_change()? And then maybe you can move thexfs_iolabel command check inside it?Well, we want to know a lot of things:
1) can the kernel code for this filesystem support online label
2) doesxfs_iosupport the label command
3) does this test know the maximum label length to test for this fsthe above stuff is for 3)
What I was suggesting was doing all of these in one function similar to _require_xfs_sparse_inodes, _require_meta_uuid, etc:
_require_online_label_change()
{
# need xfs_io support
_require_xfs_io_command "label"
# need fstests knowledge of label size
[ $(_label_get_max) -eq 0 ] && _notrun "$FSTYP does not define maximum label length"
# need kernel support
$XFS_IO_PROG -c label $TEST_DIR > /dev/null 2>&1
[ $? -ne 0 ] && _notrun "Kernel does not support FS_IOC_GETLABEL"
}Which also means that the label_f command in xfs_io needs to set the exitcode to non-zero when the ioctl fails so that xfs_io returns non-zero on failure...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v3 1/1 test online label ioctl
In reply to Eric SandeenThis tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated xfs_io with the label command and a filesystem that supports it
A slight change here to _require_xfs_io_command as well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.
---
(urgh send as proper new thread, sorry)
This passes on btrfs, _notruns on xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long as xfs_io has the new capability)
V2: Add a max label length helper
Set the proper btrfs max label length o_O oops Filter trailing whitespace from blkid output
V3: lowercase local vars, simplify max label len function
common/rc +27 -1
@@ -2144,6 +2144,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands.
@@ -2182,7 +2185,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
@@ -3788,6 +3791,29 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, /not/ including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + echo 12 + ;; + btrfs) + echo 255 + ;; + *) + _notrun "$FSTYP does not define maximum label length" + ;; + esac +} + +# Helper to check above early in a script +_require_label_get_max() +{ + # Just call _label_get_max which will notrun if appropriate + dummy=$(_label_get_max) +} + init_rc ################################################################################
tests/generic/479 +0 -0
tests/generic/488 new file +90 -0
90 lines not on this page · raw message
tests/generic/488.out new file +9 -0
@@ -0,0 +1,9 @@ +QA output created by 488 +label = "label.488" +label = "label.488" +SCRATCH_DEV: LABEL="label.488" +SCRATCH_DEV: LABEL="label.488" +label = "label.488" +label: Invalid argument +label = "MAXLABEL" +label: Invalid argument
tests/generic/group +1 -0
@@ -490,3 +490,4 @@ 485 auto quick insert 486 auto quick attr 487 auto quick +488 auto quick
Quoted 19 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports itA slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen <[email protected]>---
(urgh send as proper new thread, sorry)
This passes on btrfs,
_notrunson xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long asxfs_iohas the new capability)
Quoted 5 lines
V2: Add a max label length helper
Set the proper btrfs max label lengtho_Ooops Filter trailing whitespace from blkid outputV3: lowercase local vars, simplify max label len function
Looks good now, but I wondered about one thing the test doesn't
cover: can you clear the label by setting it to a null string? i.e you check max length bounds, but don't check empty string behaviour...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 24 lines · Dave Chinner
Quoted 23 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports itA slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen<[email protected]>---
(urgh send as proper new thread, sorry)
This passes on btrfs,
_notrunson xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long asxfs_iohas the new capability)V2: Add a max label length helper
Set the proper btrfs max label lengtho_Ooops Filter trailing whitespace from blkid output
Quoted 5 lines
Quoted 1 line
V3: lowercase local vars, simplify max label len function
Looks good now, but I wondered about one thing the test doesn't
cover: can you clear the label by setting it to a null string? i.e you check max length bounds, but don't check empty string behaviour...
hohum, yes. I'll fix that, which will also require a change to xfs_io to be able to set a null string.
Will send a V3 in a bit.
-Eric
PATCH v4 1/1 test online label ioctl
In reply to Eric SandeenThis tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated xfs_io with the label command and a filesystem that supports it
A slight change here to _require_xfs_io_command as well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.
---
Now with new and improved sequential V4 versioning!
This passes on btrfs, _notruns on xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long as xfs_io has the new capability)
V2: Add a max label length helper
Set the proper btrfs max label length o_O oops Filter trailing whitespace from blkid output
V3: lowercase local vars, simplify max label len function
V4: use/test new -s / -c options to set and clear
common/rc +27 -1
@@ -2144,6 +2144,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands.
@@ -2182,7 +2185,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
@@ -3788,6 +3791,29 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, /not/ including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + echo 12 + ;; + btrfs) + echo 255 + ;; + *) + _notrun "$FSTYP does not define maximum label length" + ;; + esac +} + +# Helper to check above early in a script +_require_label_get_max() +{ + # Just call _label_get_max which will notrun if appropriate + dummy=$(_label_get_max) +} + init_rc ################################################################################
tests/generic/488 new file +95 -0
95 lines not on this page · raw message
tests/generic/488.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 488 +label = "label.488" +label = "label.488" +label = "" +label = "" +label = "label.488" +label = "label.488" +SCRATCH_DEV: LABEL="label.488" +SCRATCH_DEV: LABEL="label.488" +label = "label.488" +label: Invalid argument +label = "MAXLABEL" +label: Invalid argument
tests/generic/group +1 -0
@@ -490,3 +490,4 @@ 485 auto quick insert 486 auto quick attr 487 auto quick +488 auto quick
Quoted 6 lines · Eric Sandeen
This tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated
xfs_iowith the label command and a filesystem that supports it
Quoted 8 lines
A slight change here to
_require_xfs_io_commandas well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.Signed-off-by Eric Sandeen <[email protected]>---
Now with new and improved sequential V4 versioning!
Looks good now.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v3 1/1 test online label ioctl
In reply to Eric SandeenThis tests the online label ioctl that btrfs has, which has been recently proposed for XFS.
To run, it requires an updated xfs_io with the label command and a filesystem that supports it
A slight change here to _require_xfs_io_command as well, so that tests which simply fail with "Inappropriate ioctl" can be caught in the common case.
---
This passes on btrfs, _notruns on xfs/ext4 of yore, and passes on xfs w/ my online label patchset (as long as xfs_io has the new capability)
V2: Add a max label length helper
Set the proper btrfs max label length o_O oops Filter trailing whitespace from blkid output
V3: use/test new -s / -c options to set and clear
common/rc +27 -1
@@ -2144,6 +2144,9 @@ _require_xfs_io_command() echo $testio | grep -q "Inappropriate ioctl" && \ _notrun "xfs_io $command support is missing" ;; + "label") + testio=`$XFS_IO_PROG -c "label" $TEST_DIR 2>&1` + ;; "open") # -c "open $f" is broken in xfs_io <= 4.8. Along with the fix, # a new -C flag was introduced to execute one shot commands.
@@ -2182,7 +2185,7 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ _notrun "xfs_io $command support is missing" - echo $testio | grep -q "Operation not supported" && \ + echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ _notrun "xfs_io $command failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)"
@@ -3788,6 +3791,29 @@ _require_scratch_feature() esac } +# The maximum filesystem label length, /not/ including terminating NULL +_label_get_max() +{ + case $FSTYP in + xfs) + echo 12 + ;; + btrfs) + echo 255 + ;; + *) + _notrun "$FSTYP does not define maximum label length" + ;; + esac +} + +# Helper to check above early in a script +_require_label_get_max() +{ + # Just call _label_get_max which will notrun if appropriate + dummy=$(_label_get_max) +} + init_rc ################################################################################
tests/generic/488 new file +95 -0
95 lines not on this page · raw message
tests/generic/488.out new file +13 -0
@@ -0,0 +1,13 @@ +QA output created by 488 +label = "label.488" +label = "label.488" +label = "" +label = "" +label = "label.488" +label = "label.488" +SCRATCH_DEV: LABEL="label.488" +SCRATCH_DEV: LABEL="label.488" +label = "label.488" +label: Invalid argument +label = "MAXLABEL" +label: Invalid argument
tests/generic/group +1 -0
@@ -490,3 +490,4 @@ 485 auto quick insert 486 auto quick attr 487 auto quick +488 auto quick