* [PATCH v3 0/4] SunRPC fault injection
@ 2021-08-20 14:53 Chuck Lever
2021-08-20 14:53 ` [PATCH v3 1/4] SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory Chuck Lever
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Chuck Lever @ 2021-08-20 14:53 UTC (permalink / raw)
To: linux-nfs
The following series (re)implements SunRPC disconnect injection
using the kernel's generic fault injection infrastructure under
debugfs. It's partially a clean-up and partially a fresh
implementation of server-side disconnect injection, while also
enabling the straightforward addition of further types of fault
injection in the future.
Changes since v2:
- CONFIG options still not right, complexity now hidden in Kconfig
Changes since v1:
- Now builds properly with various combinations of CONFIG options
---
Chuck Lever (4):
SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory
SUNRPC: Move client-side disconnect injection
SUNRPC: Server-side disconnect injection
SUNRPC: Add documentation for the fail_sunrpc/ directory
.../fault-injection/fault-injection.rst | 18 +++++
include/linux/sunrpc/xprt.h | 18 -----
lib/Kconfig.debug | 7 ++
net/sunrpc/debugfs.c | 73 +++++--------------
net/sunrpc/fail.h | 25 +++++++
net/sunrpc/svc.c | 8 ++
net/sunrpc/xprt.c | 14 ++++
7 files changed, 92 insertions(+), 71 deletions(-)
create mode 100644 net/sunrpc/fail.h
--
Chuck Lever
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/4] SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory
2021-08-20 14:53 [PATCH v3 0/4] SunRPC fault injection Chuck Lever
@ 2021-08-20 14:53 ` Chuck Lever
2021-08-20 14:54 ` [PATCH v3 2/4] SUNRPC: Move client-side disconnect injection Chuck Lever
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2021-08-20 14:53 UTC (permalink / raw)
To: linux-nfs
This directory will contain a set of administrative controls for
enabling error injection for kernel RPC consumers.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
lib/Kconfig.debug | 7 +++++++
net/sunrpc/debugfs.c | 14 ++++++++++++++
net/sunrpc/fail.h | 21 +++++++++++++++++++++
3 files changed, 42 insertions(+)
create mode 100644 net/sunrpc/fail.h
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 5ddd575159fb..cd78bb0a7dd9 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1971,6 +1971,13 @@ config FAIL_MMC_REQUEST
and to test how the mmc host driver handles retries from
the block device.
+config FAIL_SUNRPC
+ bool "Fault-injection capability for SunRPC"
+ depends on FAULT_INJECTION_DEBUG_FS && SUNRPC_DEBUG
+ help
+ Provide fault-injection capability for SunRPC and
+ its consumers.
+
config FAULT_INJECTION_STACKTRACE_FILTER
bool "stacktrace filter for fault-injection capabilities"
depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index 56029e3af6ff..eaeb51f83abd 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -8,7 +8,9 @@
#include <linux/debugfs.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/clnt.h>
+
#include "netns.h"
+#include "fail.h"
static struct dentry *topdir;
static struct dentry *rpc_clnt_dir;
@@ -297,6 +299,13 @@ static const struct file_operations fault_disconnect_fops = {
.release = fault_release,
};
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+struct fail_sunrpc_attr fail_sunrpc = {
+ .attr = FAULT_ATTR_INITIALIZER,
+};
+EXPORT_SYMBOL_GPL(fail_sunrpc);
+#endif
+
void __exit
sunrpc_debugfs_exit(void)
{
@@ -321,4 +330,9 @@ sunrpc_debugfs_init(void)
debugfs_create_file("disconnect", S_IFREG | 0400, rpc_fault_dir, NULL,
&fault_disconnect_fops);
+
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+ fault_create_debugfs_attr("fail_sunrpc", NULL,
+ &fail_sunrpc.attr);
+#endif
}
diff --git a/net/sunrpc/fail.h b/net/sunrpc/fail.h
new file mode 100644
index 000000000000..1d402b0d3453
--- /dev/null
+++ b/net/sunrpc/fail.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021, Oracle. All rights reserved.
+ */
+
+#ifndef _NET_SUNRPC_FAIL_H_
+#define _NET_SUNRPC_FAIL_H_
+
+#include <linux/fault-inject.h>
+
+#if IS_ENABLED(CONFIG_FAULT_INJECTION)
+
+struct fail_sunrpc_attr {
+ struct fault_attr attr;
+};
+
+extern struct fail_sunrpc_attr fail_sunrpc;
+
+#endif /* CONFIG_FAULT_INJECTION */
+
+#endif /* _NET_SUNRPC_FAIL_H_ */
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/4] SUNRPC: Move client-side disconnect injection
2021-08-20 14:53 [PATCH v3 0/4] SunRPC fault injection Chuck Lever
2021-08-20 14:53 ` [PATCH v3 1/4] SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory Chuck Lever
@ 2021-08-20 14:54 ` Chuck Lever
2021-08-20 14:54 ` [PATCH v3 3/4] SUNRPC: Server-side " Chuck Lever
2021-08-20 14:54 ` [PATCH v3 4/4] SUNRPC: Add documentation for the fail_sunrpc/ directory Chuck Lever
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2021-08-20 14:54 UTC (permalink / raw)
To: linux-nfs
Disconnect injection stress-tests the ability for both client and
server implementations to behave resiliently in the face of network
instability.
Convert the existing client-side disconnect injection infrastructure
to use the kernel's generic error injection facility. The generic
facility has a richer set of injection criteria.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
include/linux/sunrpc/xprt.h | 18 ----------
net/sunrpc/debugfs.c | 78 ++++++++-----------------------------------
net/sunrpc/fail.h | 2 +
net/sunrpc/xprt.c | 14 ++++++++
4 files changed, 30 insertions(+), 82 deletions(-)
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index c8c39f22d3b1..b15c1f07162d 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -288,7 +288,6 @@ struct rpc_xprt {
const char *address_strings[RPC_DISPLAY_MAX];
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
struct dentry *debugfs; /* debugfs directory */
- atomic_t inject_disconnect;
#endif
struct rcu_head rcu;
const struct xprt_class *xprt_class;
@@ -502,21 +501,4 @@ static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt)
return test_and_set_bit(XPRT_BINDING, &xprt->state);
}
-#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
-extern unsigned int rpc_inject_disconnect;
-static inline void xprt_inject_disconnect(struct rpc_xprt *xprt)
-{
- if (!rpc_inject_disconnect)
- return;
- if (atomic_dec_return(&xprt->inject_disconnect))
- return;
- atomic_set(&xprt->inject_disconnect, rpc_inject_disconnect);
- xprt->ops->inject_disconnect(xprt);
-}
-#else
-static inline void xprt_inject_disconnect(struct rpc_xprt *xprt)
-{
-}
-#endif
-
#endif /* _LINUX_SUNRPC_XPRT_H */
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index eaeb51f83abd..04e453ad3508 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -16,8 +16,6 @@ static struct dentry *topdir;
static struct dentry *rpc_clnt_dir;
static struct dentry *rpc_xprt_dir;
-unsigned int rpc_inject_disconnect;
-
static int
tasks_show(struct seq_file *f, void *v)
{
@@ -237,8 +235,6 @@ rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
/* make tasks file */
debugfs_create_file("info", S_IFREG | 0400, xprt->debugfs, xprt,
&xprt_info_fops);
-
- atomic_set(&xprt->inject_disconnect, rpc_inject_disconnect);
}
void
@@ -248,62 +244,26 @@ rpc_xprt_debugfs_unregister(struct rpc_xprt *xprt)
xprt->debugfs = NULL;
}
-static int
-fault_open(struct inode *inode, struct file *filp)
-{
- filp->private_data = kmalloc(128, GFP_KERNEL);
- if (!filp->private_data)
- return -ENOMEM;
- return 0;
-}
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+struct fail_sunrpc_attr fail_sunrpc = {
+ .attr = FAULT_ATTR_INITIALIZER,
+};
+EXPORT_SYMBOL_GPL(fail_sunrpc);
-static int
-fault_release(struct inode *inode, struct file *filp)
+static void fail_sunrpc_init(void)
{
- kfree(filp->private_data);
- return 0;
-}
+ struct dentry *dir;
-static ssize_t
-fault_disconnect_read(struct file *filp, char __user *user_buf,
- size_t len, loff_t *offset)
-{
- char *buffer = (char *)filp->private_data;
- size_t size;
+ dir = fault_create_debugfs_attr("fail_sunrpc", NULL,
+ &fail_sunrpc.attr);
- size = sprintf(buffer, "%u\n", rpc_inject_disconnect);
- return simple_read_from_buffer(user_buf, len, offset, buffer, size);
+ debugfs_create_bool("ignore-client-disconnect", S_IFREG | 0600, dir,
+ &fail_sunrpc.ignore_client_disconnect);
}
-
-static ssize_t
-fault_disconnect_write(struct file *filp, const char __user *user_buf,
- size_t len, loff_t *offset)
+#else
+static void fail_sunrpc_init(void)
{
- char buffer[16];
-
- if (len >= sizeof(buffer))
- len = sizeof(buffer) - 1;
- if (copy_from_user(buffer, user_buf, len))
- return -EFAULT;
- buffer[len] = '\0';
- if (kstrtouint(buffer, 10, &rpc_inject_disconnect))
- return -EINVAL;
- return len;
}
-
-static const struct file_operations fault_disconnect_fops = {
- .owner = THIS_MODULE,
- .open = fault_open,
- .read = fault_disconnect_read,
- .write = fault_disconnect_write,
- .release = fault_release,
-};
-
-#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
-struct fail_sunrpc_attr fail_sunrpc = {
- .attr = FAULT_ATTR_INITIALIZER,
-};
-EXPORT_SYMBOL_GPL(fail_sunrpc);
#endif
void __exit
@@ -318,21 +278,11 @@ sunrpc_debugfs_exit(void)
void __init
sunrpc_debugfs_init(void)
{
- struct dentry *rpc_fault_dir;
-
topdir = debugfs_create_dir("sunrpc", NULL);
rpc_clnt_dir = debugfs_create_dir("rpc_clnt", topdir);
rpc_xprt_dir = debugfs_create_dir("rpc_xprt", topdir);
- rpc_fault_dir = debugfs_create_dir("inject_fault", topdir);
-
- debugfs_create_file("disconnect", S_IFREG | 0400, rpc_fault_dir, NULL,
- &fault_disconnect_fops);
-
-#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
- fault_create_debugfs_attr("fail_sunrpc", NULL,
- &fail_sunrpc.attr);
-#endif
+ fail_sunrpc_init();
}
diff --git a/net/sunrpc/fail.h b/net/sunrpc/fail.h
index 1d402b0d3453..62c1b9fd59e2 100644
--- a/net/sunrpc/fail.h
+++ b/net/sunrpc/fail.h
@@ -12,6 +12,8 @@
struct fail_sunrpc_attr {
struct fault_attr attr;
+
+ bool ignore_client_disconnect;
};
extern struct fail_sunrpc_attr fail_sunrpc;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index fb6db09725c7..05abe344a269 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -56,6 +56,7 @@
#include "sunrpc.h"
#include "sysfs.h"
+#include "fail.h"
/*
* Local variables
@@ -855,6 +856,19 @@ xprt_init_autodisconnect(struct timer_list *t)
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
}
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+static void xprt_inject_disconnect(struct rpc_xprt *xprt)
+{
+ if (!fail_sunrpc.ignore_client_disconnect &&
+ should_fail(&fail_sunrpc.attr, 1))
+ xprt->ops->inject_disconnect(xprt);
+}
+#else
+static inline void xprt_inject_disconnect(struct rpc_xprt *xprt)
+{
+}
+#endif
+
bool xprt_lock_connect(struct rpc_xprt *xprt,
struct rpc_task *task,
void *cookie)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/4] SUNRPC: Server-side disconnect injection
2021-08-20 14:53 [PATCH v3 0/4] SunRPC fault injection Chuck Lever
2021-08-20 14:53 ` [PATCH v3 1/4] SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory Chuck Lever
2021-08-20 14:54 ` [PATCH v3 2/4] SUNRPC: Move client-side disconnect injection Chuck Lever
@ 2021-08-20 14:54 ` Chuck Lever
2021-08-20 14:54 ` [PATCH v3 4/4] SUNRPC: Add documentation for the fail_sunrpc/ directory Chuck Lever
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2021-08-20 14:54 UTC (permalink / raw)
To: linux-nfs
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. The
default setting is that server-side disconnect injection is enabled
(ignore=false).
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
net/sunrpc/debugfs.c | 3 +++
net/sunrpc/fail.h | 2 ++
net/sunrpc/svc.c | 8 ++++++++
3 files changed, 13 insertions(+)
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index 04e453ad3508..827bf3a28178 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -259,6 +259,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-server-disconnect", S_IFREG | 0600, dir,
+ &fail_sunrpc.ignore_server_disconnect);
}
#else
static void fail_sunrpc_init(void)
diff --git a/net/sunrpc/fail.h b/net/sunrpc/fail.h
index 62c1b9fd59e2..69dc30cc44b8 100644
--- a/net/sunrpc/fail.h
+++ b/net/sunrpc/fail.h
@@ -14,6 +14,8 @@ struct fail_sunrpc_attr {
struct fault_attr attr;
bool ignore_client_disconnect;
+
+ bool ignore_server_disconnect;
};
extern struct fail_sunrpc_attr fail_sunrpc;
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 5aa263326b6a..bfcbaf7b3822 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);
@@ -1524,6 +1526,12 @@ svc_process(struct svc_rqst *rqstp)
struct svc_serv *serv = rqstp->rq_server;
u32 dir;
+#if IS_ENABLED(CONFIG_FAIL_SUNRPC)
+ if (!fail_sunrpc.ignore_server_disconnect &&
+ should_fail(&fail_sunrpc.attr, 1))
+ svc_xprt_deferred_close(rqstp->rq_xprt);
+#endif
+
/*
* Setup response xdr_buf.
* Initially it has just one page
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 4/4] SUNRPC: Add documentation for the fail_sunrpc/ directory
2021-08-20 14:53 [PATCH v3 0/4] SunRPC fault injection Chuck Lever
` (2 preceding siblings ...)
2021-08-20 14:54 ` [PATCH v3 3/4] SUNRPC: Server-side " Chuck Lever
@ 2021-08-20 14:54 ` Chuck Lever
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2021-08-20 14:54 UTC (permalink / raw)
To: linux-nfs
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
Documentation/fault-injection/fault-injection.rst | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/Documentation/fault-injection/fault-injection.rst b/Documentation/fault-injection/fault-injection.rst
index f47d05ed0d94..4a25c5eb6f07 100644
--- a/Documentation/fault-injection/fault-injection.rst
+++ b/Documentation/fault-injection/fault-injection.rst
@@ -24,6 +24,10 @@ Available fault injection capabilities
injects futex deadlock and uaddr fault errors.
+- fail_sunrpc
+
+ injects kernel RPC client and server failures.
+
- fail_make_request
injects disk IO errors on devices permitted by setting
@@ -151,6 +155,20 @@ configuration of fault-injection capabilities.
default is 'N', setting it to 'Y' will disable failure injections
when dealing with private (address space) futexes.
+- /sys/kernel/debug/fail_sunrpc/ignore-client-disconnect:
+
+ Format: { 'Y' | 'N' }
+
+ default is 'N', setting it to 'Y' will disable disconnect
+ injection on the RPC client.
+
+- /sys/kernel/debug/fail_sunrpc/ignore-server-disconnect:
+
+ Format: { 'Y' | 'N' }
+
+ default is 'N', setting it to 'Y' will disable disconnect
+ injection on the RPC server.
+
- /sys/kernel/debug/fail_function/inject:
Format: { 'function-name' | '!function-name' | '' }
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-20 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 14:53 [PATCH v3 0/4] SunRPC fault injection Chuck Lever
2021-08-20 14:53 ` [PATCH v3 1/4] SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory Chuck Lever
2021-08-20 14:54 ` [PATCH v3 2/4] SUNRPC: Move client-side disconnect injection Chuck Lever
2021-08-20 14:54 ` [PATCH v3 3/4] SUNRPC: Server-side " Chuck Lever
2021-08-20 14:54 ` [PATCH v3 4/4] SUNRPC: Add documentation for the fail_sunrpc/ directory Chuck Lever
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.