Skip to contentSkip to conversation

scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc.patch removed from -mm tree

merged [email protected] 1 participant 1 message Jan 23, 2022

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: scsi/sg: move sg-big-buff sysctl to scsi/sg.c
has been removed from the -mm tree. Its filename was
scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Xiaoming Ni <[email protected]>
Subject: scsi/sg: move sg-big-buff sysctl to scsi/sg.c

kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.

So move the sg-big-buff sysctl from kernel/sysctl.c to drivers/scsi/sg.c and use register_sysctl() to register the sysctl interface.

[[email protected]: commit log update]
Cc Al Viro <[email protected]>
Cc Amir Goldstein <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Antti Palosaari <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Benjamin LaHaise <[email protected]>
Cc Clemens Ladisch <[email protected]>
Cc David Airlie <[email protected]>
Cc Douglas Gilbert <[email protected]>
Cc Eric Biederman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Iurii Zaikin <[email protected]>
Cc James E.J. Bottomley <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Jan Kara <[email protected]>
Cc Joel Becker <[email protected]>
Cc John Ogness <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Joseph Qi <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Kees Cook <[email protected]>
Cc Lukas Middendorf <[email protected]>
Cc Mark Fasheh <[email protected]>
Cc Martin K. Petersen <[email protected]>
Cc Paul Turner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Phillip Potter <[email protected]>
Cc Qing Wang <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Sebastian Reichel <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Stephen Kitt <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Tetsuo Handa <[email protected]>
Cc "Theodore Ts'o" <[email protected]>

---

 drivers/scsi/sg.c |   35 ++++++++++++++++++++++++++++++++++-
 include/scsi/sg.h |    4 ----
 kernel/sysctl.c   |   12 ------------
 3 files changed, 34 insertions(+), 17 deletions(-)
drivers/scsi/sg.c renamed from drivers/scsi/sg.c~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +34 -1
@@ -77,7 +77,7 @@ static int sg_proc_init(void);
 
 #define SG_DEFAULT_TIMEOUT mult_frac(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ)
 
-int sg_big_buff = SG_DEF_RESERVED_SIZE;
+static int sg_big_buff = SG_DEF_RESERVED_SIZE;
 /* N.B. This variable is readable and writeable via
    /proc/scsi/sg/def_reserved_size . Each time sg_open() is called a buffer
    of this size (or less if there is not enough memory) will be reserved
@@ -1634,6 +1634,37 @@ MODULE_PARM_DESC(scatter_elem_sz, "scatt
 MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd");
 MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))");
 
+#ifdef CONFIG_SYSCTL
+#include <linux/sysctl.h>
+
+static struct ctl_table sg_sysctls[] = {
+	{
+		.procname	= "sg-big-buff",
+		.data		= &sg_big_buff,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec,
+	},
+	{}
+};
+
+static struct ctl_table_header *hdr;
+static void register_sg_sysctls(void)
+{
+	if (!hdr)
+		hdr = register_sysctl("kernel", sg_sysctls);
+}
+
+static void unregister_sg_sysctls(void)
+{
+	if (hdr)
+		unregister_sysctl_table(hdr);
+}
+#else
+#define register_sg_sysctls() do { } while (0)
+#define unregister_sg_sysctls() do { } while (0)
+#endif /* CONFIG_SYSCTL */
+
 static int __init
 init_sg(void)
 {
@@ -1666,6 +1697,7 @@ init_sg(void)
 		return 0;
 	}
 	class_destroy(sg_sysfs_class);
+	register_sg_sysctls();
 err_out:
 	unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS);
 	return rc;
@@ -1674,6 +1706,7 @@ err_out:
 static void __exit
 exit_sg(void)
 {
+	unregister_sg_sysctls();
 #ifdef CONFIG_SCSI_PROC_FS
 	remove_proc_subtree("scsi/sg", NULL);
 #endif				/* CONFIG_SCSI_PROC_FS */
include/scsi/sg.h renamed from include/scsi/sg.h~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +0 -4
@@ -29,10 +29,6 @@
  * For utility and test programs see: http://sg.danny.cz/sg/sg3_utils.html
  */
 
-#ifdef __KERNEL__
-extern int sg_big_buff; /* for sysctl */
-#endif
-
 
 typedef struct sg_iovec /* same structure as used by readv() Linux system */
 {                       /* call. It defines one scatter-gather element. */
kernel/sysctl.c renamed from kernel/sysctl.c~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +0 -12
@@ -95,9 +95,6 @@
 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
 #include <linux/lockdep.h>
 #endif
-#ifdef CONFIG_CHR_DEV_SG
-#include <scsi/sg.h>
-#endif
 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
 #include <linux/stackleak.h>
 #endif
@@ -2090,15 +2087,6 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dostring,
 	},
 #endif
-#ifdef CONFIG_CHR_DEV_SG
-	{
-		.procname	= "sg-big-buff",
-		.data		= &sg_big_buff,
-		.maxlen		= sizeof (int),
-		.mode		= 0444,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #ifdef CONFIG_BSD_PROCESS_ACCT
 	{
 		.procname	= "acct",

_

Patches currently in -mm which might be from [email protected] are