NFS: Initialize v4 sysctls from nfs_init_v4()
authorBryan Schumaker <bjschuma@netapp.com>
Mon, 16 Jul 2012 20:39:14 +0000 (16:39 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 17 Jul 2012 17:33:18 +0000 (13:33 -0400)
And split them out of the generic client into their own file.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/Makefile
fs/nfs/nfs4_fs.h
fs/nfs/nfs4super.c
fs/nfs/nfs4sysctl.c [new file with mode: 0644]
fs/nfs/sysctl.c

index 162a699134caba87478e489079457c578c488e53..4a78e76440f8580644a5331e387744ffd39bf64a 100644 (file)
@@ -17,7 +17,12 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
                           callback.o callback_xdr.o callback_proc.o \
                           nfs4namespace.o
 nfs-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o
-nfs-$(CONFIG_SYSCTL) += sysctl.o
+
+ifeq ($(CONFIG_SYSCTL), y)
+nfs-y += sysctl.o
+nfs-$(CONFIG_NFS_V4) += nfs4sysctl.o
+endif
+
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
index 1a6ed3f9a32a6a1320ea7f6cfae5426ed8129f13..b508fef1a32b3bec20f40a45ec93fa5a56144c18 100644 (file)
@@ -368,6 +368,21 @@ extern const nfs4_stateid zero_stateid;
 int init_nfs_v4(void);
 void exit_nfs_v4(void);
 
+/* nfs4sysctl.c */
+#ifdef CONFIG_SYSCTL
+int nfs4_register_sysctl(void);
+void nfs4_unregister_sysctl(void);
+#else
+static inline int nfs4_register_sysctl(void)
+{
+       return 0;
+}
+
+static inline int nfs4_unregister_sysctl(void)
+{
+}
+#endif
+
 /* nfs4xdr.c */
 extern struct rpc_procinfo nfs4_procedures[];
 
index 366e41459695acbedf4b8ce6b2ee18ed7d413049..70c394e75ca1f846fa49fc751338adfcd84a6f68 100644 (file)
@@ -3,6 +3,8 @@
  */
 #include <linux/init.h>
 #include <linux/nfs_idmap.h>
+#include <linux/nfs_fs.h>
+#include "nfs4_fs.h"
 
 int __init init_nfs_v4(void)
 {
@@ -12,12 +14,19 @@ int __init init_nfs_v4(void)
        if (err)
                goto out;
 
+       err = nfs4_register_sysctl();
+       if (err)
+               goto out1;
+
        return 0;
+out1:
+       nfs_idmap_quit();
 out:
        return err;
 }
 
 void __exit exit_nfs_v4(void)
 {
+       nfs4_unregister_sysctl();
        nfs_idmap_quit();
 }
diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
new file mode 100644 (file)
index 0000000..5729bc8
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * linux/fs/nfs/nfs4sysctl.c
+ *
+ * Sysctl interface to NFS v4 parameters
+ *
+ * Copyright (c) 2006 Trond Myklebust <Trond.Myklebust@netapp.com>
+ */
+#include <linux/sysctl.h>
+#include <linux/nfs_idmap.h>
+#include <linux/nfs_fs.h>
+
+#include "callback.h"
+
+static const int nfs_set_port_min = 0;
+static const int nfs_set_port_max = 65535;
+static struct ctl_table_header *nfs4_callback_sysctl_table;
+
+static ctl_table nfs4_cb_sysctls[] = {
+       {
+               .procname = "nfs_callback_tcpport",
+               .data = &nfs_callback_set_tcpport,
+               .maxlen = sizeof(int),
+               .mode = 0644,
+               .proc_handler = proc_dointvec_minmax,
+               .extra1 = (int *)&nfs_set_port_min,
+               .extra2 = (int *)&nfs_set_port_max,
+       },
+       {
+               .procname = "idmap_cache_timeout",
+               .data = &nfs_idmap_cache_timeout,
+               .maxlen = sizeof(int),
+               .mode = 0644,
+               .proc_handler = proc_dointvec_jiffies,
+       },
+       { }
+};
+
+static ctl_table nfs4_cb_sysctl_dir[] = {
+       {
+               .procname = "nfs",
+               .mode = 0555,
+               .child = nfs4_cb_sysctls,
+       },
+       { }
+};
+
+static ctl_table nfs4_cb_sysctl_root[] = {
+       {
+               .procname = "fs",
+               .mode = 0555,
+               .child = nfs4_cb_sysctl_dir,
+       },
+       { }
+};
+
+int nfs4_register_sysctl(void)
+{
+       nfs4_callback_sysctl_table = register_sysctl_table(nfs4_cb_sysctl_root);
+       if (nfs4_callback_sysctl_table == NULL)
+               return -ENOMEM;
+       return 0;
+}
+
+void nfs4_unregister_sysctl(void)
+{
+       unregister_sysctl_table(nfs4_callback_sysctl_table);
+       nfs4_callback_sysctl_table = NULL;
+}
index ad4d2e787b2041d17eaacc4a1ce8097f0cc13aca..6b3f2535a3ec7ae5c840696956288c41dac84021 100644 (file)
@@ -9,37 +9,11 @@
 #include <linux/fs.h>
 #include <linux/sysctl.h>
 #include <linux/module.h>
-#include <linux/nfs4.h>
-#include <linux/nfs_idmap.h>
 #include <linux/nfs_fs.h>
 
-#include "callback.h"
-
-#ifdef CONFIG_NFS_V4
-static const int nfs_set_port_min = 0;
-static const int nfs_set_port_max = 65535;
-#endif
 static struct ctl_table_header *nfs_callback_sysctl_table;
 
 static ctl_table nfs_cb_sysctls[] = {
-#ifdef CONFIG_NFS_V4
-       {
-               .procname = "nfs_callback_tcpport",
-               .data = &nfs_callback_set_tcpport,
-               .maxlen = sizeof(int),
-               .mode = 0644,
-               .proc_handler = proc_dointvec_minmax,
-               .extra1 = (int *)&nfs_set_port_min,
-               .extra2 = (int *)&nfs_set_port_max,
-       },
-       {
-               .procname = "idmap_cache_timeout",
-               .data = &nfs_idmap_cache_timeout,
-               .maxlen = sizeof(int),
-               .mode = 0644,
-               .proc_handler = proc_dointvec_jiffies,
-       },
-#endif
        {
                .procname       = "nfs_mountpoint_timeout",
                .data           = &nfs_mountpoint_expiry_timeout,