Skip to contentSkip to conversation

common: handle ceph's new mount syntax

PATCH Superseded Jeff Layton 2 participants 3 messages Jan 6, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 common: handle ceph's new mount syntax

Cephfs is introducing a new mount device syntax. Fix the fstests infrastructure to handle the new syntax correctly.

---
 common/config |  8 ++++++++
 common/rc     | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

v2: more rigorous check for ceph mount device in _check_device

common/config +8 -0
index e0a5c5df58ff..2b357746476b 100644
@@ -537,6 +537,14 @@ _check_device()
 		# 9p and virtiofs mount tags are just plain strings, so anything is allowed
 		# tmpfs doesn't use mount source, ignore
 		;;
+	ceph)
+		# ceph has two different possible syntaxes for mount devices. The
+		# network URL check above catches the legacy syntax. Check for the
+		# new-style syntax here.
+		if ( echo $dev | grep -qEv "=/" ); then
+			_fatal "common/config: $name ($dev) is not a valid ceph mount string"
+		fi
+		;;
 	overlay)
 		if [ ! -d "$dev" ]; then
 			_fatal "common/config: $name ($dev) is not a directory for overlay"
common/rc +32 -2
index 7973ceb5fdf8..4fa0b818d840 100644
@@ -1592,7 +1592,7 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$SCRATCH_DEV"
@@ -1601,6 +1601,21 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"
 		fi
 		;;
+	ceph)
+		if [ -z "$SCRATCH_DEV" ]; then
+			_notrun "this test requires a valid \$SCRATCH_DEV"
+		fi
+		echo $SCRATCH_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then
+				_notrun "this test requires a valid \$SCRATCH_DEV"
+			fi
+		fi
+		if [ ! -d "$SCRATCH_MNT" ]; then
+			_notrun "this test requires a valid \$SCRATCH_MNT"
+		fi
+		;;
 	pvfs2)
 		echo $SCRATCH_DEV | grep -q "://" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
@@ -1770,7 +1785,7 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$TEST_DEV"
@@ -1779,6 +1794,21 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
+	ceph)
+		if [ -z "$TEST_DEV" ]; then
+			_notrun "this test requires a valid \$TEST_DEV"
+		fi
+		echo $TEST_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then
+				_notrun "this test requires a valid \$TEST_DEV"
+			fi
+		fi
+		if [ ! -d "$TEST_DIR" ]; then
+			_notrun "this test requires a valid \$TEST_DIR"
+		fi
+		;;
 	cifs)
 		echo $TEST_DEV | grep -q "//" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
Signature · 1 line
2.33.1
#1 lore raw
Quoted 17 lines · Jeff Layton

Cephfs is introducing a new mount device syntax. Fix the fstests infrastructure to handle the new syntax correctly.

---
 common/config |  8 ++++++++
 common/rc     | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

v2: more rigorous check for ceph mount device in _check_device

common/config +0 -0
index e0a5c5df58ff..2b357746476b 100644
@@ -537,6 +537,14 @@ _check_device()
 		# 9p and virtiofs mount tags are just plain strings, so anything is allowed

common/config _check_device() · line 547

Quoted 10 lines
common/config +8 -0
 		# tmpfs doesn't use mount source, ignore
 		;;
+	ceph)
+		# ceph has two different possible syntaxes for mount devices. The
+		# network URL check above catches the legacy syntax. Check for the
+		# new-style syntax here.
+		if ( echo $dev | grep -qEv "=/" ); then
+			_fatal "common/config: $name ($dev) is not a valid ceph mount string"
+		fi
+		;;

I have not objection with this, if the maintainer prefer:

-       if [ -b "$dev" ] || ( echo $dev | grep -qE ":|//" ); then
+       if [ -b "$dev" ] || ( echo $dev | grep -qE ":|//|=/" ); then
                # block device or a network url
                return 0
        fi
Quoted 18 lines
common/config +0 -0
 	overlay)
 		if [ ! -d "$dev" ]; then
 			_fatal "common/config: $name ($dev) is not a directory for overlay"
common/rc +1 -1
index 7973ceb5fdf8..4fa0b818d840 100644
@@ -1592,7 +1592,7 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$SCRATCH_DEV"
@@ -1601,6 +1601,21 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"

common/rc _require_scratch_nocheck() · line 1611

Quoted 10 lines
common/rc +8 -0
 		fi
 		;;
+	ceph)
+		if [ -z "$SCRATCH_DEV" ]; then
+			_notrun "this test requires a valid \$SCRATCH_DEV"
+		fi
+		echo $SCRATCH_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then

Why not combine two "if condition" into one, likes:
echo $SCRATCH_DEV | grep -Eq "=/|:/" >/dev/null 2>&1 if [ "$?" != "0" ] ....

(Sorry I didn't metion this last time...)

Same below:

Quoted 44 lines
common/rc +23 -1
+				_notrun "this test requires a valid \$SCRATCH_DEV"
+			fi
+		fi
+		if [ ! -d "$SCRATCH_MNT" ]; then
+			_notrun "this test requires a valid \$SCRATCH_MNT"
+		fi
+		;;
 	pvfs2)
 		echo $SCRATCH_DEV | grep -q "://" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
@@ -1770,7 +1785,7 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$TEST_DEV"
@@ -1779,6 +1794,21 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
+	ceph)
+		if [ -z "$TEST_DEV" ]; then
+			_notrun "this test requires a valid \$TEST_DEV"
+		fi
+		echo $TEST_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then
+				_notrun "this test requires a valid \$TEST_DEV"
+			fi
+		fi
+		if [ ! -d "$TEST_DIR" ]; then
+			_notrun "this test requires a valid \$TEST_DIR"
+		fi
+		;;
 	cifs)
 		echo $TEST_DEV | grep -q "//" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
Signature · 1 line
2.33.1
#2 lore raw
Quoted 32 lines · Zorro Lang
Quoted 17 lines · Jeff Layton

Cephfs is introducing a new mount device syntax. Fix the fstests infrastructure to handle the new syntax correctly.

---
 common/config |  8 ++++++++
 common/rc     | 34 ++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

v2: more rigorous check for ceph mount device in _check_device

common/config +0 -0
index e0a5c5df58ff..2b357746476b 100644
@@ -537,6 +537,14 @@ _check_device()
 		# 9p and virtiofs mount tags are just plain strings, so anything is allowed

common/config _check_device() · line 547

Quoted 10 lines
common/config +8 -0
 		# tmpfs doesn't use mount source, ignore
 		;;
+	ceph)
+		# ceph has two different possible syntaxes for mount devices. The
+		# network URL check above catches the legacy syntax. Check for the
+		# new-style syntax here.
+		if ( echo $dev | grep -qEv "=/" ); then
+			_fatal "common/config: $name ($dev) is not a valid ceph mount string"
+		fi
+		;;

I have not objection with this, if the maintainer prefer:

Review

Quoted 5 lines
(quoted diff) +1 -1
-       if [ -b "$dev" ] || ( echo $dev | grep -qE ":|//" ); then
+       if [ -b "$dev" ] || ( echo $dev | grep -qE ":|//|=/" ); then
                # block device or a network url
                return 0
        fi

The "=/" part of the syntax is (so far) ceph-specific. I don't think we want to accept that for (e.g.) NFS, so it's probably best to allow that only when FSTYP=ceph.

Quoted 33 lines
Quoted 18 lines
common/config +0 -0
 	overlay)
 		if [ ! -d "$dev" ]; then
 			_fatal "common/config: $name ($dev) is not a directory for overlay"
common/rc +1 -1
index 7973ceb5fdf8..4fa0b818d840 100644
@@ -1592,7 +1592,7 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$SCRATCH_DEV"
@@ -1601,6 +1601,21 @@ _require_scratch_nocheck()
 			_notrun "this test requires a valid \$SCRATCH_MNT"

common/rc _require_scratch_nocheck() · line 1611

Quoted 10 lines
common/rc +8 -0
 		fi
 		;;
+	ceph)
+		if [ -z "$SCRATCH_DEV" ]; then
+			_notrun "this test requires a valid \$SCRATCH_DEV"
+		fi
+		echo $SCRATCH_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $SCRATCH_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then

Why not combine two "if condition" into one, likes:
echo $SCRATCH_DEV | grep -Eq "=/|:/" >/dev/null 2>&1 if [ "$?" != "0" ] ....

Quoted 4 lines

(Sorry I didn't metion this last time...)

Same below:

Fair enough -- that's more efficient too. I'll respin with that.

Quoted 36 lines
Quoted 36 lines
common/rc +21 -1
+				_notrun "this test requires a valid \$SCRATCH_DEV"
+			fi
+		fi
+		if [ ! -d "$SCRATCH_MNT" ]; then
+			_notrun "this test requires a valid \$SCRATCH_MNT"
+		fi
+		;;
 	pvfs2)
 		echo $SCRATCH_DEV | grep -q "://" > /dev/null 2>&1
 		if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]; then
@@ -1770,7 +1785,7 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
-	nfs*|ceph)
+	nfs*)
 		echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
 			_notrun "this test requires a valid \$TEST_DEV"
@@ -1779,6 +1794,21 @@ _require_test()
 			_notrun "this test requires a valid \$TEST_DIR"
 		fi
 		;;
+	ceph)
+		if [ -z "$TEST_DEV" ]; then
+			_notrun "this test requires a valid \$TEST_DEV"
+		fi
+		echo $TEST_DEV | grep -q "=/" > /dev/null 2>&1
+		if [ "$?" != "0" ]; then
+			echo $TEST_DEV | grep -q ":/" > /dev/null 2>&1
+			if [ "$?" != "0" ]; then
+				_notrun "this test requires a valid \$TEST_DEV"
+			fi
+		fi
+		if [ ! -d "$TEST_DIR" ]; then
+			_notrun "this test requires a valid \$TEST_DIR"
Quoted 9 lines
Quoted 8 lines
common/rc +2 -0
+		fi
+		;;
 	cifs)
 		echo $TEST_DEV | grep -q "//" > /dev/null 2>&1
 		if [ -z "$TEST_DEV" -o "$?" != "0" ]; then
Signature · 1 line
2.33.1

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>