All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: fstests@vger.kernel.org
Cc: linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Anand Suveer Jain <asj@kernel.org>, Chao Yu <chao@kernel.org>,
	Christoph Hellwig <hch@infradead.org>
Subject: [PATCH v3 2/6] fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr
Date: Thu,  5 Nov 2026 02:47:32 +0800	[thread overview]
Message-ID: <20261104184736.1564283-3-zlang@kernel.org> (raw)
In-Reply-To: <20261104184736.1564283-1-zlang@kernel.org>

There is heavy overlap between _require_fs_sysfs and
_require_fs_sysfs_dev_attr, and their ambiguous names make it
difficult to tell them apart.

Make _require_fs_sysfs_dev_attr a generic helper that requires both
a device and an attribute, remove _has_fs_sysfs and _require_fs_sysfs,
and add _require_test_sysfs_dev_attr and _require_scratch_sysfs_dev_attr
wrappers.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 common/rc       | 28 +++++++++++++++-------------
 common/xfs      |  6 ++++--
 tests/btrfs/253 |  4 ++--
 tests/btrfs/285 |  2 +-
 tests/btrfs/334 |  2 +-
 tests/f2fs/025  |  2 +-
 tests/xfs/006   |  2 +-
 tests/xfs/177   |  2 +-
 tests/xfs/264   |  6 +++---
 9 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/common/rc b/common/rc
index 43c95930..036b75d4 100644
--- a/common/rc
+++ b/common/rc
@@ -5545,6 +5545,7 @@ _has_fs_sysfs_dev_attr()
 }
 
 # Require the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ATTR
+#
 # All arguments are necessary, and in this order:
 #  - dev: device name, e.g. $SCRATCH_DEV
 #  - attr: path name under /sys/fs/$FSTYP/$dev
@@ -5562,27 +5563,28 @@ _require_fs_sysfs_dev_attr()
 	_notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}"
 }
 
-# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
+# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$TEST_DEV/$ATTR
 #
 # Only one argument is needed:
-#  - attr: path name under /sys/fs/$FSTYP/DEV
+#  - attr: path name under /sys/fs/$FSTYP/$TEST_DEV
 #
 # Usage example:
-#   _has_fs_sysfs error/fail_at_unmount
-_has_fs_sysfs()
+#   _require_test_sysfs_dev_attr error/fail_at_unmount
+_require_test_sysfs_dev_attr()
 {
-	_has_fs_sysfs_dev_attr $TEST_DEV "$@"
+	_require_fs_sysfs_dev_attr $TEST_DEV "$1"
 }
 
-# Require the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
-_require_fs_sysfs()
+# Require the existence of a sysfs entry at /sys/fs/$FSTYP/$SCRATCH_DEV/$ATTR
+#
+# Only one argument is needed:
+#  - attr: path name under /sys/fs/$FSTYP/$SCRATCH_DEV
+#
+# Usage example:
+#   _require_scratch_sysfs_dev_attr error/fail_at_unmount
+_require_scratch_sysfs_dev_attr()
 {
-	_has_fs_sysfs "$@" && return
-
-	local attr=$1
-	local dname=$(_short_dev $TEST_DEV)
-
-	_notrun "This test requires /sys/fs/${FSTYP}/${dname}/${attr}"
+	_require_fs_sysfs_dev_attr $SCRATCH_DEV "$1"
 }
 
 # Generic test for specific filesystem feature.
diff --git a/common/xfs b/common/xfs
index 8bd144e3..d569566f 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1226,13 +1226,15 @@ _xfs_prepare_for_eio_shutdown()
 	_add_dmesg_filter "Internal error"
 
 	# Don't retry any writes during the (presumably) post-shutdown unmount
-	_has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 1
+	_has_fs_sysfs_dev_attr $dev "$ctlfile" && \
+		_set_fs_sysfs_dev_attr $dev "$ctlfile" 1
 
 	# Disable retry of metadata writes that fail with EIO
 	for ctl in max_retries retry_timeout_seconds; do
 		ctlfile="error/metadata/EIO/$ctl"
 
-		_has_fs_sysfs "$ctlfile" && _set_fs_sysfs_dev_attr $dev "$ctlfile" 0
+		_has_fs_sysfs_dev_attr $dev "$ctlfile" && \
+			_set_fs_sysfs_dev_attr $dev "$ctlfile" 0
 	done
 }
 
diff --git a/tests/btrfs/253 b/tests/btrfs/253
index d8b58f49..88ac0b4d 100755
--- a/tests/btrfs/253
+++ b/tests/btrfs/253
@@ -90,8 +90,8 @@ _scratch_mkfs_sized $((10 * 1024 * 1024 * 1024)) >> $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 # Check if there is sufficient sysfs support.
-_require_fs_sysfs allocation/metadata/chunk_size
-_require_fs_sysfs allocation/metadata/force_chunk_alloc
+_require_test_sysfs_dev_attr allocation/metadata/chunk_size
+_require_test_sysfs_dev_attr allocation/metadata/force_chunk_alloc
 
 # Get free space.
 free_space  FREE_SPACE_MB
diff --git a/tests/btrfs/285 b/tests/btrfs/285
index 5ceb69d4..d8a70572 100755
--- a/tests/btrfs/285
+++ b/tests/btrfs/285
@@ -16,7 +16,7 @@ sysfs_size_classes() {
 
 _require_scratch
 _require_btrfs_fs_sysfs
-_require_fs_sysfs allocation/data/size_classes
+_require_test_sysfs_dev_attr allocation/data/size_classes
 
 f="$SCRATCH_MNT/f"
 small=$((16 * 1024))
diff --git a/tests/btrfs/334 b/tests/btrfs/334
index 08b66dc7..5f97ec20 100755
--- a/tests/btrfs/334
+++ b/tests/btrfs/334
@@ -13,7 +13,7 @@ _begin_fstest auto quick
 . ./common/filter
 
 _require_test
-_require_fs_sysfs_dev_attr $TEST_DEV allocation/data/chunk_size
+_require_test_sysfs_dev_attr allocation/data/chunk_size
 
 _verify_sysfs_syntax $TEST_DEV allocation/data/chunk_size 256m
 
diff --git a/tests/f2fs/025 b/tests/f2fs/025
index 31dd56a8..433f900e 100755
--- a/tests/f2fs/025
+++ b/tests/f2fs/025
@@ -21,7 +21,7 @@ _require_scratch_shutdown
 _require_xfs_io_command "pwrite"
 _require_xfs_io_command "truncate"
 _require_f2fs_io_command gc_urgent
-_require_fs_sysfs_dev_attr $TEST_DEV gc_urgent
+_require_test_sysfs_dev_attr gc_urgent
 _require_check_dmesg
 
 # Clear options to avoid interference from external configurations
diff --git a/tests/xfs/006 b/tests/xfs/006
index e03ade1d..b9816051 100755
--- a/tests/xfs/006
+++ b/tests/xfs/006
@@ -25,7 +25,7 @@ _cleanup()
 
 _require_scratch
 _require_dm_target error
-_require_fs_sysfs error/fail_at_unmount
+_require_test_sysfs_dev_attr error/fail_at_unmount
 
 _scratch_mkfs > $seqres.full 2>&1
 _dmerror_init
diff --git a/tests/xfs/177 b/tests/xfs/177
index 38b68a7d..33030f42 100755
--- a/tests/xfs/177
+++ b/tests/xfs/177
@@ -48,7 +48,7 @@ _require_scratch
 
 # We require /sys/fs/xfs/$device/stats/stats to monitor per-filesystem inode
 # cache usage.
-_require_fs_sysfs stats/stats
+_require_test_sysfs_dev_attr stats/stats
 
 count_xfs_inode_objs() {
 	_get_fs_sysfs_dev_attr $SCRATCH_DEV stats/stats | awk '/vnodes/ {print $2}'
diff --git a/tests/xfs/264 b/tests/xfs/264
index c8a2f714..171e703d 100755
--- a/tests/xfs/264
+++ b/tests/xfs/264
@@ -24,9 +24,9 @@ _cleanup()
 
 _require_scratch
 _require_dm_target error
-_require_fs_sysfs error/fail_at_unmount
-_require_fs_sysfs error/metadata/EIO/max_retries
-_require_fs_sysfs error/metadata/EIO/retry_timeout_seconds
+_require_test_sysfs_dev_attr error/fail_at_unmount
+_require_test_sysfs_dev_attr error/metadata/EIO/max_retries
+_require_test_sysfs_dev_attr error/metadata/EIO/retry_timeout_seconds
 
 _scratch_mkfs >> $seqres.full 2>&1
 _dmerror_init
-- 
2.56.0


  parent reply	other threads:[~2026-11-04 18:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 18:47 [PATCH v3 0/6] Refactor *_fs_sysfs_* helpers Zorro Lang
2026-11-04 18:47 ` [PATCH v3 1/6] fstests: rename _*_fs_sysfs_attr helpers to _*_fs_sysfs_dev_attr Zorro Lang
2026-11-04 18:47 ` Zorro Lang [this message]
2026-11-05  7:50   ` [PATCH v3 2/6] fstests: consolidate _require_fs_sysfs and _require_fs_sysfs_dev_attr Christoph Hellwig
2026-11-04 18:47 ` [PATCH v3 3/6] common: move btrfs-only sysfs policy helpers out of common/sysfs Zorro Lang
2026-11-04 18:47 ` [PATCH v3 4/6] common/rc: add helpers for /sys/fs/$FSTYP/features/ Zorro Lang
2026-11-04 18:47 ` [PATCH v3 5/6] common/rc: use common helper in _require_fanotify_ioerrors for f2fs Zorro Lang
2026-11-04 18:47 ` [PATCH v3 6/6] fstests: replace btrfs specific helpers with common sysfs helpers Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261104184736.1564283-3-zlang@kernel.org \
    --to=zlang@kernel.org \
    --cc=asj@kernel.org \
    --cc=chao@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.