Skip to contentSkip to conversation

source fs specific common file properly

PATCH In review Zorro Lang 4 participants 9 messages May 25, 2022 – May 26, 2022

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

cover source fs specific common file properly

It starts with generic/402 always fails on overlayfs as:

QA output created by 402
./common/rc: line 2441: _xfs_timestamp_range: command not found ./common/rc: line 2403: [: syntax error: '-1' unexpected ./common/rc: line 2408: [: -le: unary operator expected ./common/rc: line 2441: _xfs_timestamp_range: command not found 0;0 != 1;1
0;0 != 1;1
Silence is golden

Due to if FSTYP is overlay, we only source common/overlay file. But we still need the helpers of the underlying filesystem. So I think we need to source the common/$OVL_BASE_FSTYP in common/overlay.

Besides overlayfs, I'd like to extend other uplying fs support its BASE_FSTYP, so other uplying fs (e.g. nfs, cifs, glusterfs ...) will do like this.

Thanks,
Zorro

author
#1 lore raw

PATCH 1/2 common: source base fs specific common file

When tests overlayfs, sometimes we need the underlying fs specific helpers, e.g. common/rc has:
_filesystem_timestamp_range $OVL_BASE_TEST_DEV $OVL_BASE_FSTYP

So when we source common/overlay, better to source OVL_BASE_FSTYP too.

---
 common/config  | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 common/overlay |  4 ++++
 common/rc      | 49 +----------------------------------------
 3 files changed, 64 insertions(+), 48 deletions(-)
common/config +59 -0
index c6428f90..558f148b 100644
@@ -481,6 +481,65 @@ _fsck_opts()
 	esac
 }
 
+# check necessary running dependences then source sepcific fs helpers
+_source_specific_fs()
+{
+	local fs=$1
+
+	if [ -z "$fs" ];then
+		fs=$FSTYP
+	fi
+
+	case "$fs" in
+	xfs)
+		[ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
+		[ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
+		[ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
+		[ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
+		[ "$XFS_INFO_PROG" = "" ] && _fatal "xfs_info not found"
+
+		. ./common/xfs
+		;;
+	udf)
+		[ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
+		;;
+	btrfs)
+		[ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
+
+		. ./common/btrfs
+		;;
+	ext4)
+		[ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
+		;;
+	f2fs)
+		[ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
+		;;
+	nfs)
+		. ./common/nfs
+		;;
+	cifs)
+		;;
+	9p)
+		;;
+	ceph)
+		. ./common/ceph
+		;;
+	glusterfs)
+		;;
+	overlay)
+		. ./common/overlay
+		;;
+	reiser4)
+		[ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
+		;;
+	pvfs2)
+		;;
+	ubifs)
+		[ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
+		;;
+	esac
+}
+
 known_hosts()
 {
 	[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
common/overlay +4 -0
index c4e7ee58..e35419d0 100644
@@ -12,6 +12,10 @@ export OVL_XATTR_NLINK="trusted.overlay.nlink"
 export OVL_XATTR_UPPER="trusted.overlay.upper"
 export OVL_XATTR_METACOPY="trusted.overlay.metacopy"
 
+if [ -n "$OVL_BASE_FSTYP" ];then
+	_source_specific_fs $OVL_BASE_FSTYP
+fi
+
 # helper function to do the actual overlayfs mount operation
 _overlay_mount_dirs()
 {
common/rc +1 -48

55 lines not on this page · raw message

Signature · 1 line
2.31.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] common: source base fs specific common file

Quoted 9 lines · Zorro Lang

When tests overlayfs, sometimes we need the underlying fs specific helpers, e.g. common/rc has:
_filesystem_timestamp_range $OVL_BASE_TEST_DEV $OVL_BASE_FSTYP

So when we source common/overlay, better to source OVL_BASE_FSTYP too.

Makes sense.

Quoted 154 lines
---
 common/config  | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 common/overlay |  4 ++++
 common/rc      | 49 +----------------------------------------
 3 files changed, 64 insertions(+), 48 deletions(-)
common/config +59 -0
index c6428f90..558f148b 100644
@@ -481,6 +481,65 @@ _fsck_opts()
        esac
 }
 
+# check necessary running dependences then source sepcific fs helpers
+_source_specific_fs()
+{
+       local fs=$1
+
+       if [ -z "$fs" ];then
+               fs=$FSTYP
+       fi
+
+       case "$fs" in
+       xfs)
+               [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
+               [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
+               [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
+               [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
+               [ "$XFS_INFO_PROG" = "" ] && _fatal "xfs_info not found"
+
+               . ./common/xfs
+               ;;
+       udf)
+               [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
+               ;;
+       btrfs)
+               [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
+
+               . ./common/btrfs
+               ;;
+       ext4)
+               [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
+               ;;
+       f2fs)
+               [ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
+               ;;
+       nfs)
+               . ./common/nfs
+               ;;
+       cifs)
+               ;;
+       9p)
+               ;;
+       ceph)
+               . ./common/ceph
+               ;;
+       glusterfs)
+               ;;
+       overlay)
+               . ./common/overlay
+               ;;
+       reiser4)
+               [ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
+               ;;
+       pvfs2)
+               ;;
+       ubifs)
+               [ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
+               ;;
+       esac
+}
+
 known_hosts()
 {
        [ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
common/overlay +4 -0
index c4e7ee58..e35419d0 100644
@@ -12,6 +12,10 @@ export OVL_XATTR_NLINK="trusted.overlay.nlink"
 export OVL_XATTR_UPPER="trusted.overlay.upper"
 export OVL_XATTR_METACOPY="trusted.overlay.metacopy"
 
+if [ -n "$OVL_BASE_FSTYP" ];then
+       _source_specific_fs $OVL_BASE_FSTYP
+fi
+
 # helper function to do the actual overlayfs mount operation
 _overlay_mount_dirs()
 {
common/rc +1 -49
index 70a15f9c..2f31ca46 100644
@@ -96,54 +96,7 @@ _log_err()
 umask 022
 
 # check for correct setup and source the $FSTYP specific functions now
-case "$FSTYP" in
-    xfs)
-        [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
-        [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
-        [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
-        [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
-        [ "$XFS_INFO_PROG" = "" ] && _fatal "xfs_info not found"
-
-        . ./common/xfs
-        ;;
-    udf)
-        [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
-        ;;
-    btrfs)
-        [ "$MKFS_BTRFS_PROG" = "" ] && _fatal "mkfs.btrfs not found"
-
-        . ./common/btrfs
-        ;;
-    ext4)
-        [ "$MKFS_EXT4_PROG" = "" ] && _fatal "mkfs.ext4 not found"
-        ;;
-    f2fs)
-        [ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
-        ;;
-    nfs)
-        . ./common/nfs
-        ;;
-    cifs)
-        ;;
-    9p)
-        ;;
-    ceph)
-        . ./common/ceph
-        ;;
-    glusterfs)
-        ;;
-    overlay)
-        . ./common/overlay
-        ;;
-    reiser4)
-        [ "$MKFS_REISER4_PROG" = "" ] && _fatal "mkfs.reiser4 not found"
-        ;;
-    pvfs2)
-       ;;
-    ubifs)
-       [ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
-       ;;
-esac
+_source_specific_fs $FSTYP
 
 if [ ! -z "$REPORT_LIST" ]; then
        . ./common/report
--

2.31.1

author
#3 lore raw

PATCH 2/2 tests: remove redundant common/$FSTYP importing

In reply to Zorro Lang

As fstests intensively source specific common/$FSTYP files in common/rc, at the beginning of ./check running. Each single case doesn't need to import that again.

---
 tests/btrfs/177 | 1 -
 tests/btrfs/258 | 1 -
 tests/btrfs/259 | 1 -
 tests/xfs/422   | 1 -
 tests/xfs/423   | 1 -
 tests/xfs/517   | 1 -
 6 files changed, 6 deletions(-)
tests/btrfs/177 +0 -1
index 2fd11e89..7b004b83 100755
@@ -10,7 +10,6 @@
 _begin_fstest auto quick swap balance
 
 . ./common/filter
-. ./common/btrfs
 
 # Modify as appropriate.
 _supported_fs btrfs
tests/btrfs/258 +0 -1
index 158eaf79..8fc828df 100755
@@ -11,7 +11,6 @@
 _begin_fstest auto defrag quick
 
 . ./common/btrfs
-. ./common/filter
 
 # real QA test starts here
 
tests/btrfs/259 +0 -1
index e7bd8ddd..92d0b9a6 100755
@@ -12,7 +12,6 @@ _begin_fstest auto quick defrag
 
 # Import common functions.
 . ./common/filter
-. ./common/btrfs
 
 # real QA test starts here
 
tests/xfs/422 +0 -1
index 77db492e..175253aa 100755
@@ -17,7 +17,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/423 +0 -1
index be56f311..c9dfaece 100755
@@ -18,7 +18,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/517 +0 -1
index 512f795f..88c4f43b 100755
@@ -23,7 +23,6 @@ _cleanup()
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
Signature · 1 line
2.31.1
#4 lore raw

Re: [PATCH 2/2] tests: remove redundant common/$FSTYP importing

Quoted 31 lines · Zorro Lang

As fstests intensively source specific common/$FSTYP files in common/rc, at the beginning of ./check running. Each single case doesn't need to import that again.

---
 tests/btrfs/177 | 1 -
 tests/btrfs/258 | 1 -
 tests/btrfs/259 | 1 -
 tests/xfs/422   | 1 -
 tests/xfs/423   | 1 -
 tests/xfs/517   | 1 -
 6 files changed, 6 deletions(-)
tests/btrfs/177 +0 -1
index 2fd11e89..7b004b83 100755
@@ -10,7 +10,6 @@
 _begin_fstest auto quick swap balance
 
 . ./common/filter
-. ./common/btrfs
 
 # Modify as appropriate.
 _supported_fs btrfs
tests/btrfs/258 +0 -0
index 158eaf79..8fc828df 100755

tests/btrfs/258 line 14

Quoted 4 lines
tests/btrfs/258 +0 -1
@@ -11,7 +11,6 @@
 _begin_fstest auto defrag quick
 
 . ./common/btrfs
-. ./common/filter

I think you removed the wrong line here.

-Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#5 lore raw

Re: [PATCH 2/2] tests: remove redundant common/$FSTYP importing

Quoted 34 lines · Dave Chinner
Quoted 33 lines · Zorro Lang

As fstests intensively source specific common/$FSTYP files in common/rc, at the beginning of ./check running. Each single case doesn't need to import that again.

---
 tests/btrfs/177 | 1 -
 tests/btrfs/258 | 1 -
 tests/btrfs/259 | 1 -
 tests/xfs/422   | 1 -
 tests/xfs/423   | 1 -
 tests/xfs/517   | 1 -
 6 files changed, 6 deletions(-)
tests/btrfs/177 +0 -1
index 2fd11e89..7b004b83 100755
@@ -10,7 +10,6 @@
 _begin_fstest auto quick swap balance
 
 . ./common/filter
-. ./common/btrfs
 
 # Modify as appropriate.
 _supported_fs btrfs
tests/btrfs/258 +0 -0
index 158eaf79..8fc828df 100755
@@ -11,7 +11,6 @@
 _begin_fstest auto defrag quick
 
Quoted 4 lines

tests/btrfs/258 line 14

Quoted 2 lines
tests/btrfs/258 +0 -1
 . ./common/btrfs
-. ./common/filter

I think you removed the wrong line here.

Oh, sorry, we resend this patch again.

Thanks,
Zorro

Quoted 6 lines

-Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#6 lore raw

PATCH v2 2/2 tests: remove redundant common/$FSTYP importing

In reply to Zorro Lang

As fstests intensively source specific common/$FSTYP files in common/rc, at the beginning of ./check running. Each single case doesn't need to import that again.

---

I removed "./common/filter" in btrfs/258 uncarefully, fix that in this V2.

Thanks,
Zorro

 tests/btrfs/177 | 1 -
 tests/btrfs/258 | 1 -
 tests/btrfs/259 | 1 -
 tests/xfs/422   | 1 -
 tests/xfs/423   | 1 -
 tests/xfs/517   | 1 -
 6 files changed, 6 deletions(-)
tests/btrfs/177 +0 -1
index 2fd11e89..7b004b83 100755
@@ -10,7 +10,6 @@
 _begin_fstest auto quick swap balance
 
 . ./common/filter
-. ./common/btrfs
 
 # Modify as appropriate.
 _supported_fs btrfs
tests/btrfs/258 +0 -1
index 158eaf79..da073333 100755
@@ -10,7 +10,6 @@
 . ./common/preamble
 _begin_fstest auto defrag quick
 
-. ./common/btrfs
 . ./common/filter
 
 # real QA test starts here
tests/btrfs/259 +0 -1
index e7bd8ddd..92d0b9a6 100755
@@ -12,7 +12,6 @@ _begin_fstest auto quick defrag
 
 # Import common functions.
 . ./common/filter
-. ./common/btrfs
 
 # real QA test starts here
 
tests/xfs/422 +0 -1
index 77db492e..175253aa 100755
@@ -17,7 +17,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/423 +0 -1
index be56f311..c9dfaece 100755
@@ -18,7 +18,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/517 +0 -1
index 512f795f..88c4f43b 100755
@@ -23,7 +23,6 @@ _cleanup()
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
Signature · 1 line
2.31.1
Reviewed-by on v2 2/2
#8 lore raw

Re: [PATCH v2 2/2] tests: remove redundant common/$FSTYP importing

In reply to Zorro Lang
Quoted 7 lines · Zorro Lang

As fstests intensively source specific common/$FSTYP files in common/rc, at the beginning of ./check running. Each single case doesn't need to import that again.

---

Looks fine.

Quoted 89 lines

I removed "./common/filter" in btrfs/258 uncarefully, fix that in this V2.

Thanks,
Zorro

 tests/btrfs/177 | 1 -
 tests/btrfs/258 | 1 -
 tests/btrfs/259 | 1 -
 tests/xfs/422   | 1 -
 tests/xfs/423   | 1 -
 tests/xfs/517   | 1 -
 6 files changed, 6 deletions(-)
tests/btrfs/177 +0 -1
index 2fd11e89..7b004b83 100755
@@ -10,7 +10,6 @@
 _begin_fstest auto quick swap balance
 
 . ./common/filter
-. ./common/btrfs
 
 # Modify as appropriate.
 _supported_fs btrfs
tests/btrfs/258 +0 -1
index 158eaf79..da073333 100755
@@ -10,7 +10,6 @@
 . ./common/preamble
 _begin_fstest auto defrag quick
 
-. ./common/btrfs
 . ./common/filter
 
 # real QA test starts here
tests/btrfs/259 +0 -1
index e7bd8ddd..92d0b9a6 100755
@@ -12,7 +12,6 @@ _begin_fstest auto quick defrag
 
 # Import common functions.
 . ./common/filter
-. ./common/btrfs
 
 # real QA test starts here
 
tests/xfs/422 +0 -1
index 77db492e..175253aa 100755
@@ -17,7 +17,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/423 +0 -1
index be56f311..c9dfaece 100755
@@ -18,7 +18,6 @@ _register_cleanup "_cleanup" BUS
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/517 +0 -2
index 512f795f..88c4f43b 100755
@@ -23,7 +23,6 @@ _cleanup()
 . ./common/filter
 . ./common/fuzzy
 . ./common/inject
-. ./common/xfs
 
 # real QA test starts here
 _supported_fs xfs
--

2.31.1