Signal injection can help exercise signal handling paths in the
SUNRPC scheduler and in transport implementations.
Signed-off-by: Chuck Lever <[email protected]>
---
Documentation/fault-injection/fault-injection.rst | 7 +++++++
net/sunrpc/debugfs.c | 3 +++
net/sunrpc/fail.h | 1 +
net/sunrpc/sched.c | 10 ++++++++++
4 files changed, 21 insertions(+)
diff --git a/Documentation/fault-injection/fault-injection.rst b/Documentation/fault-injection/fault-injection.rst
index 17779a2772e5..ff5c4db2198f 100644
--- a/Documentation/fault-injection/fault-injection.rst
+++ b/Documentation/fault-injection/fault-injection.rst
@@ -162,6 +162,13 @@ configuration of fault-injection capabilities.
default is 'N', setting it to 'Y' will disable disconnect
injection on the RPC client.
+- /sys/kernel/debug/fail_sunrpc/ignore-client-signals:
+
+ Format: { 'Y' | 'N' }
+
+ default is 'N', setting it to 'Y' will disable signal
+ injection on the RPC client.
+
- /sys/kernel/debug/fail_sunrpc/ignore-server-disconnect:
Format: { 'Y' | 'N' }
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index a176d5a0b0ee..8df634e63f30 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -260,6 +260,9 @@ static void fail_sunrpc_init(void)
debugfs_create_bool("ignore-client-disconnect", S_IFREG | 0600, dir,
&fail_sunrpc.ignore_client_disconnect);
+ debugfs_create_bool("ignore-client-signals", S_IFREG | 0600, dir,
+ &fail_sunrpc.ignore_client_signals);
+
debugfs_create_bool("ignore-server-disconnect", S_IFREG | 0600, dir,
&fail_sunrpc.ignore_server_disconnect);
diff --git a/net/sunrpc/fail.h b/net/sunrpc/fail.h
index 4b4b500df428..359ed0b2f600 100644
--- a/net/sunrpc/fail.h
+++ b/net/sunrpc/fail.h
@@ -14,6 +14,7 @@ struct fail_sunrpc_attr {
struct fault_attr attr;
bool ignore_client_disconnect;
+ bool ignore_client_signals;
bool ignore_server_disconnect;
bool ignore_cache_wait;
};
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 7f70c1e608b7..1b1de8906a91 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -26,6 +26,7 @@
#include <linux/sunrpc/metrics.h>
#include "sunrpc.h"
+#include "fail.h"
#define CREATE_TRACE_POINTS
#include <trace/events/sunrpc.h>
@@ -959,6 +960,12 @@ static void __rpc_execute(struct rpc_task *task)
if (task_is_async)
goto out;
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+ if (!fail_sunrpc.ignore_client_signals &&
+ should_fail(&fail_sunrpc.attr, 1))
+ goto signalled;
+#endif
+
/* sync task: sleep here */
trace_rpc_task_sync_sleep(task, task->tk_action);
status = out_of_line_wait_on_bit(&task->tk_runstate,
@@ -971,6 +978,9 @@ static void __rpc_execute(struct rpc_task *task)
* clean up after sleeping on some queue, we don't
* break the loop here, but go around once more.
*/
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+signalled:
+#endif
trace_rpc_task_signalled(task, task->tk_action);
set_bit(RPC_TASK_SIGNALLED, &task->tk_runstate);
task->tk_rpc_status = -ERESTARTSYS;