block: null_blk: make fault-injection configurable via configfs
Subsystems (5)
Akinobu Mita
maintainercover block: null_blk: make fault-injection configurable via configfs
This patch set makes null_blk driver-specific fault-injection dynamically configurable per device via configfs.
Since the null_blk driver supports configuration such as device creation via configfs, it is natural to configure fault-injection via configfs as well.
Currently, only the debugfs interface is provided for dynamically configuring fault-injection, so this introduces a compatible interface via configfs.
Akinobu Mita (2):
fault-inject: allow configuration via configfs
block: null_blk: make fault-injection dynamically configurable per
device
.../fault-injection/fault-injection.rst | 8 + drivers/block/null_blk/Kconfig | 2 +- drivers/block/null_blk/main.c | 93 +++++++-- drivers/block/null_blk/null_blk.h | 7 +- include/linux/fault-inject.h | 22 ++ lib/Kconfig.debug | 13 +- lib/fault-inject.c | 191 ++++++++++++++++++ 7 files changed, 312 insertions(+), 24 deletions(-)
Signature · 1 line
2.34.1
Akinobu Mita
maintainerPATCH 1/2 fault-inject: allow configuration via configfs
This provides a helper function to allow configuration of fault-injection for configfs-based drivers.
The config items created by this function have the same interface as the one created under debugfs by fault_create_debugfs_attr().
--- include/linux/fault-inject.h | 22 ++++ lib/Kconfig.debug | 13 ++- lib/fault-inject.c | 191 +++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+), 1 deletion(-)
include/linux/fault-inject.h +22 -0
@@ -6,6 +6,7 @@#include <linux/types.h> #include <linux/debugfs.h> +#include <linux/configfs.h> #include <linux/ratelimit.h> #include <linux/atomic.h>
@@ -65,6 +66,27 @@ static inline struct dentry *fault_create_debugfs_attr(const char *name,#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ +#ifdef CONFIG_FAULT_INJECTION_CONFIGFS + +struct fault_config { +struct fault_attr attr; +struct config_group group; +}; + +void fault_config_init (struct fault_config *config,const char *name); + +#else /* CONFIG_FAULT_INJECTION_CONFIGFS */ + +struct fault_config { +}; + +static inline void fault_config_init (struct fault_config *config, +const char *name) +{ +} + +#endif /* CONFIG_FAULT_INJECTION_CONFIGFS */ +#endif /* CONFIG_FAULT_INJECTION */ struct kmem_cache ;
lib/Kconfig.debug +12 -1
@@ -1977,9 +1977,20 @@ config FAIL_SUNRPC Provide fault-injection capability for SunRPC and its consumers. +config FAULT_INJECTION_CONFIGFS + bool "Configfs interface for fault-injection capabilities" + depends on FAULT_INJECTION && CONFIGFS_FS + help + This option allows configfs-based drivers to dynamically configure + fault-injection via configfs. Each parameter for driver-specific + fault-injection can be made visible as a configfs attribute in a + configfs group. + + config FAULT_INJECTION_STACKTRACE_FILTER bool "stacktrace filter for fault-injection capabilities" - depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT + depends on FAULT_INJECTION + depends on (FAULT_INJECTION_DEBUG_FS || FAULT_INJECTION_CONFIGFS) && STACKTRACE_SUPPORT select STACKTRACE depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86 help
lib/fault-inject.c +191 -0
194 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 1/2] fault-inject: allow configuration via configfs
Hi Mita-san,
Quoted 7 lines · Akinobu Mita
This provides a helper function to allow configuration of fault-injection for configfs-based drivers.
The config items created by this function have the same interface as the one created under debugfs by
fault_create_debugfs_attr().Signed-off-by Akinobu Mita <[email protected]>
Thanks for your patch, which is now commit 4668c7a2940d134b ("fault-inject: allow configuration via configfs") in linux-next (to be tagged soon as next-20140414).
lib/Kconfig.debug config FAIL_SUNRPC · line 1982
Quoted 9 lines
lib/Kconfig.debug +3
-0@@ -1977,9 +1977,20 @@ config FAIL_SUNRPC Provide fault-injection capability for SunRPC and its consumers. +config FAULT_INJECTION_CONFIGFS + bool "Configfs interface for fault-injection capabilities" + depends on FAULT_INJECTION && CONFIGFS_FS
[email protected] reported build failures for e.g. m68k-allmodconfig
http://kisskb.ellerman.id.au/kisskb/buildresult/14911188/:
fault-inject.c:(.text+0x1ee): undefined reference to `config_group_init_type_name'
This fails because FAULT_INJECTION=y but CONFIGFS_FS=m.
lib/Kconfig.debug config FAIL_SUNRPC · line 1989
Quoted 7 lines
lib/Kconfig.debug +7
-0+ help + This option allows configfs-based drivers to dynamically configure + fault-injection via configfs. Each parameter for driver-specific + fault-injection can be made visible as a configfs attribute in a + configfs group. + +
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Akinobu Mita
maintainerRe: [PATCH 1/2] fault-inject: allow configuration via configfs
2023年4月15日(土) 23:53 Geert Uytterhoeven <[email protected]>:
Quoted 29 lines
Hi Mita-san,
Quoted 7 lines · Akinobu Mita
This provides a helper function to allow configuration of fault-injection for configfs-based drivers.
The config items created by this function have the same interface as the one created under debugfs by
fault_create_debugfs_attr().Signed-off-by Akinobu Mita <[email protected]>Thanks for your patch, which is now commit
4668c7a2940d134b("fault-inject: allow configuration via configfs") in linux-next (to be tagged soon as next-20140414).lib/Kconfig.debug config FAIL_SUNRPC · line 1982
Quoted 9 lines
lib/Kconfig.debug +3
-0@@ -1977,9 +1977,20 @@ config FAIL_SUNRPC Provide fault-injection capability for SunRPC and its consumers. +config FAULT_INJECTION_CONFIGFS + bool "Configfs interface for fault-injection capabilities" + depends on FAULT_INJECTION && CONFIGFS_FS[email protected] reported build failures for e.g. m68k-allmodconfig
http://kisskb.ellerman.id.au/kisskb/buildresult/14911188/:
Quoted 4 lines
fault-inject.c:(.text+0x1ee): undefined reference to `config_group_init_type_name'
This fails because FAULT_INJECTION=y but CONFIGFS_FS=m.
Oh, I just sent that build fix patch.
https://lore.kernel.org/all/[email protected]/
Could you please check if this is the correct way to fix it?
Akinobu Mita
maintainerPATCH 2/2 block: null_blk: make fault-injection dynamically configurable per device
In reply to Akinobu MitaThe null_blk driver has multiple driver-specific fault injection mechanisms. Each fault injection configuration can only be specified by a module parameter and cannot be reconfigured without reloading the driver. Also, each configuration is common to all devices and is initialized every time a new device is added.
This change adds the following subdirectories for each null_blk device.
/sys/kernel/config/nullb/<disk>/timeout_inject /sys/kernel/config/nullb/<disk>/requeue_inject /sys/kernel/config/nullb/<disk>/init_hctx_fault_inject
Each fault injection attribute can be dynamically set per device by a corresponding file in these directories.
--- .../fault-injection/fault-injection.rst | 8 ++ drivers/block/null_blk/Kconfig | 2 +- drivers/block/null_blk/main.c | 93 ++++++++++++++----- drivers/block/null_blk/null_blk.h | 7 +- 4 files changed, 87 insertions(+), 23 deletions(-)
Documentation/fault-injection/fault-injection.rst +8 -0
@@ -52,6 +52,14 @@ Available fault injection capabilities status code is NVME_SC_INVALID_OPCODE with no retry. The status code and retry flag can be set via the debugfs. +- Null test block driver fault injection + + inject IO timeouts by setting config items under + /sys/kernel/config/nullb/<disk>/timeout_inject, + inject requeue requests by setting config items under + /sys/kernel/config/nullb/<disk>/requeue_inject, and + inject init_hctx() errors by setting config items under + /sys/kernel/config/nullb/<disk>/init_hctx_fault_inject. Configure fault-injection capabilities behavior -----------------------------------------------
drivers/block/null_blk/Kconfig +1 -1
@@ -9,4 +9,4 @@ config BLK_DEV_NULL_BLK config BLK_DEV_NULL_BLK_FAULT_INJECTION bool "Support fault injection for Null test block driver" - depends on BLK_DEV_NULL_BLK && FAULT_INJECTION + depends on BLK_DEV_NULL_BLK && FAULT_INJECTION_CONFIGFS
drivers/block/null_blk/main.c +72 -21
168 lines not on this page · raw message
drivers/block/null_blk/null_blk.h +6 -1
@@ -69,7 +69,12 @@ enum {struct nullb_device {struct nullb *nullb; -struct config_item item; +struct config_group group; +#ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION +struct fault_config timeout_config; +struct fault_config requeue_config; +struct fault_config init_hctx_fault_config; +#endif struct radix_tree_root data;/* data stored in the disk */ struct radix_tree_root cache;/* disk cache data */ unsigned long flags;/* device flags */
Signature · 1 line
2.34.1
Quoted 10 lines · Akinobu Mita
This patch set makes
null_blkdriver-specific fault-injection dynamically configurable per device via configfs.Since the
null_blkdriver supports configuration such as device creation via configfs, it is natural to configure fault-injection via configfs as well.Currently, only the debugfs interface is provided for dynamically configuring fault-injection, so this introduces a compatible interface via configfs.
Oh, nice. Can you also update blktests to take advantage of this and not require built-in null_blk for fault injection tests?
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Akinobu Mita
This patch set makes
null_blkdriver-specific fault-injection dynamically configurable per device via configfs.Since the
null_blkdriver supports configuration such as device creation via configfs, it is natural to configure fault-injection via configfs as well.
Quoted 5 lines
Quoted 3 lines
Currently, only the debugfs interface is provided for dynamically configuring fault-injection, so this introduces a compatible interface via configfs.
Oh, nice. Can you also update blktests to take advantage of this and not require built-in
null_blkfor fault injection tests?
+1 on blktests, please CC me when you do.
-ck
Akinobu Mita
maintainerPATCH 1/1 don't require modular null_blk for fault-injection
I'm trying to allow configuration of null_blk fault-injection via configfs.
This blktests change changes null_blk fault-injection settings to be configured via configfs instead of module parameters.
This allows null_blk fault-injection tests to run even if the null_blk is built-in the kernel and not built as a module.
However, to keep the scripts simple, we will skip testing if the null_blk does not yet support configuring fault-injection via configfs.
--- tests/block/014 | 18 ++++++++++++------ tests/block/015 | 18 ++++++++++++------ tests/block/030 | 26 +++++++++++++++----------- 3 files changed, 39 insertions(+), 23 deletions(-)
tests/block/014 +12 -6
@@ -16,20 +16,26 @@ requires() { test() { echo "Running ${TEST_NAME}" - # The format is "<interval>,<probability>,<space>,<times>". Here, we - # fail 50% of I/Os. - if ! _init_null_blk timeout='1,50,0,-1'; then + # Here, we fail 50% of I/Os. + if ! _configure_null_blk faultb0 timeout_inject/probability=50 \ + timeout_inject/times=-1 timeout_inject/verbose=0 power=1; then + if [[ -d /sys/kernel/config/nullb/faultb0/timeout_inject ]]; then + echo "Configuring null_blk failed" + else + SKIP_REASONS+=("requires fault injection via configfs") + fi + rmdir /sys/kernel/config/nullb/faultb0 return 1 fi - for sched in $(_io_schedulers nullb0); do + for sched in $(_io_schedulers faultb0); do echo "Testing $sched" >> "$FULL" - echo "$sched" > /sys/block/nullb0/queue/scheduler + echo "$sched" > /sys/block/faultb0/queue/scheduler # Do a bunch of I/Os which will timeout and then complete. The # only thing we're really testing here is that this doesn't # crash or hang. for ((i = 0; i < 100; i++)); do - dd if=/dev/nullb0 of=/dev/null bs=4K count=4 \ + dd if=/dev/faultb0 of=/dev/null bs=4K count=4 \ iflag=direct status=none > /dev/null 2>&1 & done wait
tests/block/015 +12 -6
@@ -18,16 +18,22 @@ requires() { test() { echo "Running ${TEST_NAME}" - # The format is "<interval>,<probability>,<space>,<times>". Here, we - # requeue 10% of the time. - if ! _init_null_blk requeue='1,10,0,-1'; then + # Here, we requeue 10% of the time. + if ! _configure_null_blk faultb0 requeue_inject/probability=10 \ + requeue_inject/times=-1 requeue_inject/verbose=0 power=1; then + if [[ -d /sys/kernel/config/nullb/faultb0/requeue_inject ]]; then + echo "Configuring null_blk failed" + else + SKIP_REASONS+=("requires fault injection via configfs") + fi + rmdir /sys/kernel/config/nullb/faultb0 return 1 fi - for sched in $(_io_schedulers nullb0); do + for sched in $(_io_schedulers faultb0); do echo "Testing $sched" >> "$FULL" - echo "$sched" > /sys/block/nullb0/queue/scheduler - dd if=/dev/nullb0 of=/dev/null bs=4K count=$((512 * 1024)) \ + echo "$sched" > /sys/block/faultb0/queue/scheduler + dd if=/dev/faultb0 of=/dev/null bs=4K count=$((512 * 1024)) \ iflag=direct status=none done
tests/block/030 +15 -11
@@ -17,19 +17,23 @@ requires() { } test() { - local i sq=/sys/kernel/config/nullb/nullb0/submit_queues + local i sq=/sys/kernel/config/nullb/faultb0/submit_queues : "${TIMEOUT:=30}" - # Legend: init_hctx=<interval>,<probability>,<space>,<times> # Set <space> to $(nproc) + 1 to make loading of null_blk succeed. - if ! _init_null_blk nr_devices=0 \ - "init_hctx=$(nproc),100,$(($(nproc) + 1)),-1"; then - echo "Loading null_blk failed" - return 1 - fi - if ! _configure_null_blk nullb0 completion_nsec=0 blocksize=512 size=16\ - submit_queues="$(nproc)" memory_backed=1 power=1; then - echo "Configuring null_blk failed" + if ! _configure_null_blk faultb0 completion_nsec=0 blocksize=512 size=16\ + submit_queues="$(nproc)" memory_backed=1 \ + init_hctx_fault_inject/interval="$(nproc)" \ + init_hctx_fault_inject/probability=100 \ + init_hctx_fault_inject/space="$(($(nproc) + 1))" \ + init_hctx_fault_inject/times=-1 \ + init_hctx_fault_inject/verbose=0 power=1; then + if [[ -d /sys/kernel/config/nullb/faultb0/init_hctx_fault_inject ]]; then + echo "Configuring null_blk failed" + else + SKIP_REASONS+=("requires fault injection via configfs") + fi + rmdir /sys/kernel/config/nullb/faultb0 return 1 fi # Since older null_blk versions do not allow "submit_queues" to be
@@ -47,7 +51,7 @@ test() { else SKIP_REASONS+=("Skipping test because $sq cannot be modified") fi - rmdir /sys/kernel/config/nullb/nullb0 + rmdir /sys/kernel/config/nullb/faultb0 _exit_null_blk echo Passed }
Signature · 1 line
2.34.1
Re: [PATCH blktests] don't require modular null_blk for fault-injection
Akinobu, thanks for the patch, and sorry for this slow response.
Quoted 6 lines · Akinobu Mita
I'm trying to allow configuration of
null_blkfault-injection via configfs.This blktests change changes
null_blkfault-injection settings to be configured via configfs instead of module parameters.
This allowsnull_blkfault-injection tests to run even if thenull_blkis built-in the kernel and not built as a module.
It's good that the three test case can run with built-in null_blk.
Quoted 3 lines
However, to keep the scripts simple, we will skip testing if the
null_blkdoes not yet support configuring fault-injection via configfs.
Hmm, it means that blktests coverage will be lost on older kernels without the configfs support. Before this change, the test cases were not skipped on older kernel with loadable null_blk. After this patch, the test cases will be skipped.
Can we cover both the new and old ways? When the null_blk set up with configfs fails, we can fallback to the old way with module parameters.
For example, null_blk set up of block/014 can be like this:
# Here, we fail 50% of I/Os.
if ! _configure_null_blk faultb0 timeout_inject/probability=50 \
timeout_inject/times=-1 timeout_inject/verbose=0 power=1 \
> /dev/null 2>&1; then
rmdir /sys/kernel/config/nullb/faultb0
if [[ -d /sys/kernel/config/nullb/faultb0/timeout_inject ]]; then
echo "Configuring null_blk failed"
return 1
elif _module_file_exists null_blk; then
# Fall back to set up with module parameter. The format
# is "<interval>,<probability>,<space>,<times>"
if ! _init_null_blk timeout='1,50,0,-1'; then
echo "Configuring null_blk failed"
return 1;
fi
else
SKIP_REASONS+=("requires fault injection via configfs or modular null_blk")
return 1
fi
fiAkinobu Mita
maintainerRe: [PATCH blktests] don't require modular null_blk for fault-injection
2023年4月12日(水) 12:05 Shin'ichiro Kawasaki <[email protected]>:
Quoted 17 lines
Akinobu, thanks for the patch, and sorry for this slow response.
Quoted 6 lines · Akinobu Mita
I'm trying to allow configuration of
null_blkfault-injection via configfs.This blktests change changes
null_blkfault-injection settings to be configured via configfs instead of module parameters.
This allowsnull_blkfault-injection tests to run even if thenull_blkis built-in the kernel and not built as a module.It's good that the three test case can run with built-in
null_blk.Quoted 3 lines
However, to keep the scripts simple, we will skip testing if the
null_blkdoes not yet support configuring fault-injection via configfs.
Quoted 8 lines
Hmm, it means that blktests coverage will be lost on older kernels without the configfs support. Before this change, the test cases were not skipped on older kernel with loadable
null_blk. After this patch, the test cases will be skipped.Can we cover both the new and old ways? When the
null_blkset up with configfs fails, we can fallback to the old way with module parameters.For example,
null_blkset up of block/014 can be like this:
OK, I'll update the tests and give it a try.
Quoted 8 lines · Akinobu Mita
This patch set makes
null_blkdriver-specific fault-injection dynamically configurable per device via configfs.Since the
null_blkdriver supports configuration such as device creation via configfs, it is natural to configure fault-injection via configfs as well.[...]
Applied, thanks!
[1/2] fault-inject: allow configuration via configfs
commit: 4668c7a2940d134bea50058e138591b97485c5da
[2/2] block: null_blk: make fault-injection dynamically configurable per device
commit: bb4c19e030f45c5416f1eb4daa94fbaf7165e9eaBest regards,
Signature · 1 line
Jens Axboe