Skip to contentSkip to conversation

test online label ioctl

PATCH Superseded Eric Sandeen 3 participants 4 messages Apr 30, 2018 – May 14, 2018 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---

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)

common/rc +4 -1
index 9ffab7f..c53a721 100644
@@ -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?)"
tests/generic/485 new file +99 -0

99 lines not on this page · raw message

tests/generic/485.out new file +9 -0
new file mode 100644
index 0000000..bc54684
@@ -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
index 19be926..cf6ac49 100644
@@ -487,3 +487,4 @@
 482 auto metadata replay
 483 auto quick log metadata
 484 auto quick
+485 auto quick
#1 lore raw
Quoted 118 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_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)

common/rc +4 -1
index 9ffab7f..c53a721 100644
@@ -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?)"
tests/generic/485 new file +72 -0
new file mode 100755
index 0000000..79902c2
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test 485
+#
+# Test the online filesystem label set/get ioctls
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
+# Author: Eric Sandeen <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# 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"
+
+_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
+blkid -s LABEL $SCRATCH_DEV | _filter_scratch
+
+# And that the it is still there when it's unmounted
+_scratch_unmount
+blkid -s LABEL $SCRATCH_DEV | _filter_scratch
+
+# 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:

tests/generic/485 line 82

Quoted 10 lines
tests/generic/485 new file +10 -0
+LABEL=$(perl -e "print 'l' x 257;")
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT
+
+# And that it succeeds right at the filesystem max:
+case $FSTYP in
+xfs)
+	MAXLEN=12;
+	;;
+btrfs)
+	MAXLEN=256

Seems this should be 255, otherwise I got failure like:

-label = "MAXLABEL"
+label: Invalid argument

and MAXLEN=255 makes the test pass with btrfs.

tests/generic/485 line 86

Quoted 4 lines
tests/generic/485 new file +4 -0
+	;;
+*)
+	MAXLEN=256
+	echo "Your filesystem supports online label, please add max length"

Perhaps we can introduce a new helper similar to _require_acl_get_max() and _notrun the test if current $FSTYP doesn't define a maxlen on filesystem label?

Quoted 19 lines
tests/generic/485 new file +13 -0
+	;;
+esac
+LABEL=$(perl -e "print 'o' x $MAXLEN;")
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/'
+
+# And that it fails just past the filesystem max:
+let TOOLONG=MAXLEN+1
+LABEL=$(perl -e "print 'o' x $TOOLONG;")
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
tests/generic/485.out new file +0 -0
new file mode 100644
index 0000000..bc54684

tests/generic/485.out line 5

Quoted 5 lines
tests/generic/485.out new file +5 -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" 

There're trailing whitespaces in above two lines, I thought they're the output from xfs_io label command at first, but actually I have to remove the spaces to make test pass.

Thanks,
Eryu

Quoted 18 lines
tests/generic/485.out new file +4 -0
+label = "label.485"
+label: Invalid argument
+label = "MAXLABEL"
+label: Invalid argument
tests/generic/group +1 -1
index 19be926..cf6ac49 100644
@@ -487,3 +487,4 @@
 482 auto metadata replay
 483 auto quick log metadata
 484 auto quick
+485 auto quick
 
--

To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 14 lines · Eryu Guan
Quoted 13 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_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.

---

...

Quoted 13 lines

tests/generic/485 line 82

Quoted 7 lines
tests/generic/485 new file +7 -0
+# And that it succeeds right at the filesystem max:
+case $FSTYP in
+xfs)
+	MAXLEN=12;
+	;;
+btrfs)
+	MAXLEN=256

Seems this should be 255, otherwise I got failure like:

(quoted diff) +1 -1
-label = "MAXLABEL"
+label: Invalid argument
Quoted 1 line

and MAXLEN=255 makes the test pass with btrfs.

You are correct, I missed that they exclude the trailing null from the length. (Sorry, thought I tested this :( )

Quoted 8 lines

tests/generic/485 line 86

Quoted 4 lines
tests/generic/485 new file +4 -0
+	;;
+*)
+	MAXLEN=256
+	echo "Your filesystem supports online label, please add max length"

Perhaps we can introduce a new helper similar to _require_acl_get_max() and _notrun the test if current $FSTYP doesn't define a maxlen on filesystem label?

Ok, sure.

Quoted 20 lines
Quoted 20 lines
tests/generic/485 new file +13 -0
+	;;
+esac
+LABEL=$(perl -e "print 'o' x $MAXLEN;")
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/'
+
+# And that it fails just past the filesystem max:
+let TOOLONG=MAXLEN+1
+LABEL=$(perl -e "print 'o' x $TOOLONG;")
+$XFS_IO_PROG -c "label $LABEL" $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
tests/generic/485.out new file +1 -0
new file mode 100644
index 0000000..bc54684
@@ -0,0 +1,9 @@
+QA output created by 485
Quoted 8 lines

tests/generic/485.out line 5

Quoted 4 lines
tests/generic/485.out new file +4 -0
+label = "label.485"
+label = "label.485"
+SCRATCH_DEV: LABEL="label.485" 
+SCRATCH_DEV: LABEL="label.485" 

There're trailing whitespaces in above two lines, I thought they're the output from xfs_io label command at first, but actually I have to remove the spaces to make test pass.

It might need a filter, this is output from blkid; it might have changed. I noticed the whitespace as well but IIRC it works here.

Will look into these and fix stuff up.

Thanks!
-Eric

Quoted 3 lines

Thanks,
Eryu

#3 lore raw
In reply to 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_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

common/rc +29 -1
index 9ffab7fd..88a99cff 100644
@@ -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
old mode 100644
new mode 100755
tests/generic/485 new file +90 -0

90 lines not on this page · raw message

tests/generic/485.out new file +9 -0
new file mode 100644
index 00000000..24efca8c
@@ -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
index 19be9267..9ac5bbd1 100644
@@ -487,3 +487,4 @@
 482 auto metadata replay
 483 auto quick log metadata
 484 auto quick
+485 auto quick