SUNRPC: Add a /sys/kernel/debug/fail_sunrpc/ directory
authorChuck Lever <chuck.lever@oracle.com>
Tue, 3 Aug 2021 19:45:18 +0000 (15:45 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 20 Aug 2021 17:50:32 +0000 (13:50 -0400)
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
net/sunrpc/debugfs.c
net/sunrpc/fail.h [new file with mode: 0644]

index 5ddd575159fb82f2f9d0bc95b7b162f2b47d8f5f..cd78bb0a7dd9ba298b542df03362eddbf3a28337 100644 (file)
@@ -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
index 56029e3af6ff0b29271129d2c5d409027ab4d5d2..eaeb51f83abd9e92d9619f9fafe686b750062eba 100644 (file)
@@ -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 (file)
index 0000000..1d402b0
--- /dev/null
@@ -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_ */