Skip to contentSkip to conversation

fstests: fix _require_debugfs and call it properly

PATCH Superseded Zorro Lang 4 participants 8 messages Apr 29, 2024 – Jun 5, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 fstests: fix _require_debugfs and call it properly

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +1 -0
index 9672f95d..6421cc4b 100755
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs
 
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
#1 lore raw
Quoted 63 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +0 -0
index 9672f95d..6421cc4b 100755

tests/xfs/499 _register_cleanup "_cleanup" BUS · line 21

Quoted 4 lines
tests/xfs/499 +1 -0
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs

This test doesn't mess around with debugfs per se; it actually wants tracefs. Perhaps this should be _require_ftrace instead?

--D

Quoted 6 lines
tests/xfs/499 +0 -0
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
#2 lore raw
Quoted 63 lines · Darrick J. Wong
Quoted 62 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +0 -0
index 9672f95d..6421cc4b 100755
Quoted 8 lines

tests/xfs/499 _register_cleanup "_cleanup" BUS · line 21

Quoted 5 lines
tests/xfs/499 +1 -0
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs

This test doesn't mess around with debugfs per se; it actually wants tracefs. Perhaps this should be _require_ftrace instead?

Sure, but if it depends tracefs only, should we use /sys/kernel/debug/tracing or /sys/kernel/tracing ? If we use /sys/kernel/debug/tracing, is the debugfs needed at first?

Thanks,
Zorro

Quoted 10 lines

--D

Quoted 6 lines
tests/xfs/499 +0 -0
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
#3 lore raw
Quoted 64 lines · Zorro Lang
Quoted 63 lines · Darrick J. Wong
Quoted 62 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +0 -0
index 9672f95d..6421cc4b 100755
Quoted 8 lines
Quoted 8 lines

tests/xfs/499 _register_cleanup "_cleanup" BUS · line 21

Quoted 5 lines
tests/xfs/499 +1 -0
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs

This test doesn't mess around with debugfs per se; it actually wants tracefs. Perhaps this should be _require_ftrace instead?

Oh, I just found you've created a _require_ftrace helper in common/tracing:

FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/"

  _require_ftrace() {
          test -d "$FTRACE_INSTANCES_DIR" || \
                  _notrun "kernel does not support ftrace"
  }

Newer kernel has /sys/kernel/tracing/, to avoid the dependence of debugfs. But there's still /sys/kernel/debug/tracing/, so I'm wondering if we should try to use /sys/kernel/debug/tracing at first?

For example:

_require_ftrace() {
if [ -d /sys/kernel/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"
elif [ -d /sys/kernel/debug/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/debug/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances"
else
_notrun "The ftrace is not supported, or tracefs is not mounted"
fi
}

Thanks,
Zorro

Quoted 18 lines

Sure, but if it depends tracefs only, should we use /sys/kernel/debug/tracing or /sys/kernel/tracing ? If we use /sys/kernel/debug/tracing, is the debugfs needed at first?

Thanks,
Zorro

Quoted 10 lines

--D

Quoted 6 lines
tests/xfs/499 +0 -0
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
#4 lore raw
Quoted 76 lines · Zorro Lang
Quoted 64 lines · Zorro Lang
Quoted 63 lines · Darrick J. Wong
Quoted 62 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +0 -0
index 9672f95d..6421cc4b 100755
Quoted 8 lines
Quoted 8 lines

tests/xfs/499 _register_cleanup "_cleanup" BUS · line 21

Quoted 5 lines
tests/xfs/499 +1 -0
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs

This test doesn't mess around with debugfs per se; it actually wants tracefs. Perhaps this should be _require_ftrace instead?

Oh, I just found you've created a _require_ftrace helper in common/tracing:

Quoted 8 lines

FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/"

  _require_ftrace() {
          test -d "$FTRACE_INSTANCES_DIR" || \
                  _notrun "kernel does not support ftrace"
  }

Newer kernel has /sys/kernel/tracing/, to avoid the dependence of debugfs.

Ah, I didn't realize that! I wonder how long that's been in place...

Quoted 5 lines

But there's still /sys/kernel/debug/tracing/, so I'm wondering if we should try to use /sys/kernel/debug/tracing at first?

For example:

Quoted 11 lines

_require_ftrace() {
if [ -d /sys/kernel/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"
elif [ -d /sys/kernel/debug/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/debug/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances"
else
_notrun "The ftrace is not supported, or tracefs is not mounted"
fi
}

Yes.

--D

Quoted 22 lines

Thanks,
Zorro

Quoted 18 lines

Sure, but if it depends tracefs only, should we use /sys/kernel/debug/tracing or /sys/kernel/tracing ? If we use /sys/kernel/debug/tracing, is the debugfs needed at first?

Thanks,
Zorro

Quoted 10 lines

--D

Quoted 6 lines
tests/xfs/499 +0 -0
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
author
#5 lore raw
Quoted 79 lines · Darrick J. Wong
Quoted 78 lines · Zorro Lang
Quoted 64 lines · Zorro Lang
Quoted 63 lines · Darrick J. Wong
Quoted 62 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +8 -2
index 56f1afb6..6f0bdf60 100644
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)
+		[ "$type" = "debugfs" ] && return 0
+	fi
+
+	_notrun "Cannot find debugfs on $DEBUGFS_MNT"
 }
 
 #
tests/btrfs/150 +1 -0
index a02bdafc..fd386d92 100755
@@ -17,6 +17,7 @@ _begin_fstest auto quick dangerous read_repair compress
 . ./common/fail_make_request
 
 _supported_fs btrfs
+_require_debugfs
 _require_scratch
 _require_fail_make_request
 _require_scratch_dev_pool 2
tests/ceph/001 +1 -1
index 060c4c45..79a5f58a 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick copy_range
 
 # real QA test starts here
 _supported_fs ceph
-
+_require_debugfs
 _require_xfs_io_command "copy_range"
 _exclude_test_mount_option "test_dummy_encryption"
 _require_attrs
tests/xfs/499 +0 -0
index 9672f95d..6421cc4b 100755
Quoted 8 lines
Quoted 8 lines

tests/xfs/499 _register_cleanup "_cleanup" BUS · line 21

Quoted 5 lines
tests/xfs/499 +1 -0
@@ -18,6 +18,7 @@ _register_cleanup "_cleanup" BUS
 # real QA test starts here
 _supported_fs xfs
 _require_command "$CC_PROG" "cc"
+_require_debugfs

This test doesn't mess around with debugfs per se; it actually wants tracefs. Perhaps this should be _require_ftrace instead?

Oh, I just found you've created a _require_ftrace helper in common/tracing:

FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/"

Quoted 8 lines
Quoted 6 lines
  _require_ftrace() {
          test -d "$FTRACE_INSTANCES_DIR" || \
                  _notrun "kernel does not support ftrace"
  }

Newer kernel has /sys/kernel/tracing/, to avoid the dependence of debugfs.

Ah, I didn't realize that! I wonder how long that's been in place...

Looks like it happened in 2015, by cc31004a4aa7 ("tracefs: Add directory /sys/kernel/tracing"):

https://lwn.net/Articles/630526/

Quoted 18 lines
Quoted 6 lines

But there's still /sys/kernel/debug/tracing/, so I'm wondering if we should try to use /sys/kernel/debug/tracing at first?

For example:

Quoted 11 lines

_require_ftrace() {
if [ -d /sys/kernel/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"
elif [ -d /sys/kernel/debug/tracing/instances/ ];then
FTRACE_DIR="/sys/kernel/debug/tracing" FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances"
else
_notrun "The ftrace is not supported, or tracefs is not mounted"
fi
}

Quoted 1 line

Yes.

Oh, I found you set FTRACE_DIR="$FTRACE_INSTANCES_DIR/fstests.$seq". If we don't need the root path of tracefs, I can just set FTRACE_INSTANCES_DIR.

Thanks,
Zorro

Quoted 26 lines

--D

Quoted 22 lines

Thanks,
Zorro

Quoted 18 lines

Sure, but if it depends tracefs only, should we use /sys/kernel/debug/tracing or /sys/kernel/tracing ? If we use /sys/kernel/debug/tracing, is the debugfs needed at first?

Thanks,
Zorro

Quoted 10 lines

--D

Quoted 6 lines
tests/xfs/499 +0 -0
 cprog=$tmp.ftrace.c
 oprog=$tmp.ftrace
Signature · 1 line
2.44.0
#6 lore raw
In reply to Zorro Lang
Quoted 17 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +0 -0
index 56f1afb6..6f0bdf60 100644

common/rc _require_sparse_files() · line 2984

Quoted 9 lines
common/rc +4 -2
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)

With:

-S debugfs

On debian this returns nothing. Removing that fixes it on debian. I'll send patch.

Luis

#7 lore raw
Quoted 30 lines · Luis Chamberlain
Quoted 17 lines · Zorro Lang

The old _require_debugfs helper doesn't work now, fix it to check a system supports debugfs. And then call this helper in cases which need $DEBUGFS_MNT.

---
 common/rc       | 10 ++++++++--
 tests/btrfs/150 |  1 +
 tests/ceph/001  |  2 +-
 tests/xfs/499   |  1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
common/rc +0 -0
index 56f1afb6..6f0bdf60 100644

common/rc _require_sparse_files() · line 2984

Quoted 9 lines
common/rc +4 -2
@@ -2978,8 +2978,14 @@ _require_sparse_files()
 
 _require_debugfs()
 {
-    #boot_params always present in debugfs
-    [ -d "$DEBUGFS_MNT/boot_params" ] || _notrun "Debugfs not mounted"
+	local type
+
+	if [ -d "$DEBUGFS_MNT" ];then
+		type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE)

With:

Quoted 4 lines

-S debugfs

On debian this returns nothing. Removing that fixes it on debian. I'll send patch.

What version? This is what I see:

$ findmnt -rncv -T /sys/kernel/debug -S debugfs -o FSTYPE
debugfs
$ cat /etc/debian_version
12.5

(Did something break again?)

--D

Quoted 3 lines

Luis