On 04/07/2022 17:03, Christoph Hellwig wrote:
Various tests have more or less copy and pasted code to enable and
disable block layer "fail make request" error injection. Move that
to a set of common helpers and use those in the drivers.
btrfs/150 differened from the other two in a few ways, like selecting
a not quite as big number to fail all requests in the small critical
section and clearing a bunch of never set attributes in the failure
injection configuration, but none of those matter for the test
execution.
Hm. more below.
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
common/inject | 33 +++++++++++++++++++++++++++++++++
tests/btrfs/088 | 24 +++++-------------------
tests/btrfs/150 | 27 +++++----------------------
tests/generic/019 | 44 +++++++++-----------------------------------
4 files changed, 52 insertions(+), 76 deletions(-)
diff --git a/common/inject b/common/inject
index 6b590804..137ff5fd 100644
--- a/common/inject
+++ b/common/inject
@@ -111,3 +111,36 @@ _scratch_inject_error()
_fail "Cannot inject error ${type} value ${value}."
fi
}
+
+# enable block error injection globally
+_enable_fail_make_request()
+{
+ echo 100 > $DEBUGFS_MNT/fail_make_request/probability
+ echo 9999999 > $DEBUGFS_MNT/fail_make_request/times
Instead, can we do
printf %#x -1 > $DEBUGFS_MNT/fail_make_request/times
(as in the documentation).
<snip>
@@ -25,24 +26,6 @@ _require_fail_make_request
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2
-SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
-enable_io_failure()
-{
- echo 100 > $DEBUGFS_MNT/fail_make_request/probability
- echo 1000 > $DEBUGFS_MNT/fail_make_request/times
- echo 0 > $DEBUGFS_MNT/fail_make_request/verbose
- echo 1 > $DEBUGFS_MNT/fail_make_request/task-filter
Only extra line in btrfs/150 is the above line (or did I miss any)?
Which is deleted in this patch.
Per 'task-filter' documentation
--------------
- /sys/kernel/debug/fail*/task-filter:
Format: { 'Y' | 'N' }
A value of 'N' disables filtering by process (default).
Any positive value limits failures to only processes indicated by
/proc/<pid>/make-it-fail==1.
--------------
<snip>
- enable_io_failure
-
+ _enable_fail_make_request
+ _start_fail_dev $SCRATCH_DEV
result=$(bash -c "
if [ \$((\$\$ % 2)) == 1 ]; then
echo 1 > /proc/\$\$/make-it-fail
So this won't work now.
Thanks, Anand