Disconnect injection stress-tests the ability for both client and server implementations to behave resiliently in the face of network instability. A file called /sys/kernel/debug/fail_sunrpc/ignore-server-disconnect enables administrators to turn off server-side disconnect injection while allowing other types of sunrpc errors to be injected. So far there are no others. The default setting is that server-side disconnect injection is enabled (ignore=false). Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx> --- net/sunrpc/debugfs.c | 9 +++++++-- net/sunrpc/fail.h | 2 ++ net/sunrpc/svc.c | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index 7a9065b6a058..654e513afff7 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c @@ -306,8 +306,13 @@ struct fail_sunrpc_attr fail_sunrpc = { #if IS_ENABLED(CONFIG_FAULT_INJECTION_DEBUG_FS) static void fail_sunrpc_init(void) { - fault_create_debugfs_attr("fail_sunrpc", NULL, - &fail_sunrpc.attr); + struct dentry *dir; + + dir = fault_create_debugfs_attr("fail_sunrpc", NULL, + &fail_sunrpc.attr); + + debugfs_create_bool("ignore-server-disconnect", S_IFREG | 0600, dir, + &fail_sunrpc.ignore_server_disconnect); } #else static inline void fail_sunrpc_init(void) diff --git a/net/sunrpc/fail.h b/net/sunrpc/fail.h index 96a46eff94e4..302daa1fea8b 100644 --- a/net/sunrpc/fail.h +++ b/net/sunrpc/fail.h @@ -10,6 +10,8 @@ struct fail_sunrpc_attr { struct fault_attr attr; + + bool ignore_server_disconnect; }; extern struct fail_sunrpc_attr fail_sunrpc; diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 35b549c147a2..332628da0372 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -31,6 +31,8 @@ #include <trace/events/sunrpc.h> +#include "fail.h" + #define RPCDBG_FACILITY RPCDBG_SVCDSP static void svc_unregister(const struct svc_serv *serv, struct net *net); @@ -1507,6 +1509,10 @@ svc_process(struct svc_rqst *rqstp) struct svc_serv *serv = rqstp->rq_server; u32 dir; + if (!fail_sunrpc.ignore_server_disconnect && + should_fail(&fail_sunrpc.attr, 1)) + svc_xprt_deferred_close(rqstp->rq_xprt); + /* * Setup response xdr_buf. * Initially it has just one page