ocfs2: Move the hb_ctl_path sysctl into the stack glue.
authorJoel Becker <joel.becker@oracle.com>
Fri, 30 May 2008 22:30:49 +0000 (15:30 -0700)
committerMark Fasheh <mfasheh@suse.com>
Mon, 16 Jun 2008 17:46:50 +0000 (10:46 -0700)
ocfs2 needs to call out to the hb_ctl program at unmount for all cluster
stacks.  The first step is to move the hb_ctl_path sysctl out of the
o2cb code and into the generic stack glue.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
fs/ocfs2/cluster/nodemanager.c
fs/ocfs2/cluster/nodemanager.h
fs/ocfs2/stack_o2cb.c
fs/ocfs2/stackglue.c
fs/ocfs2/stackglue.h

index cf9401e8cd0b221e4187dbd4624c05e2070a3d89..cfdb08b484edb6ab33e5b4e4c89ccca612b18ab2 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/sysctl.h>
 #include <linux/configfs.h>
 
 #include "tcp.h"
  * cluster references throughout where nodes are looked up */
 struct o2nm_cluster *o2nm_single_cluster = NULL;
 
-#define OCFS2_MAX_HB_CTL_PATH 256
-static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
-
-static ctl_table ocfs2_nm_table[] = {
-       {
-               .ctl_name       = 1,
-               .procname       = "hb_ctl_path",
-               .data           = ocfs2_hb_ctl_path,
-               .maxlen         = OCFS2_MAX_HB_CTL_PATH,
-               .mode           = 0644,
-               .proc_handler   = &proc_dostring,
-               .strategy       = &sysctl_string,
-       },
-       { .ctl_name = 0 }
-};
-
-static ctl_table ocfs2_mod_table[] = {
-       {
-               .ctl_name       = FS_OCFS2_NM,
-               .procname       = "nm",
-               .data           = NULL,
-               .maxlen         = 0,
-               .mode           = 0555,
-               .child          = ocfs2_nm_table
-       },
-       { .ctl_name = 0}
-};
-
-static ctl_table ocfs2_kern_table[] = {
-       {
-               .ctl_name       = FS_OCFS2,
-               .procname       = "ocfs2",
-               .data           = NULL,
-               .maxlen         = 0,
-               .mode           = 0555,
-               .child          = ocfs2_mod_table
-       },
-       { .ctl_name = 0}
-};
-
-static ctl_table ocfs2_root_table[] = {
-       {
-               .ctl_name       = CTL_FS,
-               .procname       = "fs",
-               .data           = NULL,
-               .maxlen         = 0,
-               .mode           = 0555,
-               .child          = ocfs2_kern_table
-       },
-       { .ctl_name = 0 }
-};
-
-static struct ctl_table_header *ocfs2_table_header = NULL;
-
-const char *o2nm_get_hb_ctl_path(void)
-{
-       return ocfs2_hb_ctl_path;
-}
-EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path);
 
 struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
 {
@@ -941,9 +881,6 @@ void o2nm_undepend_this_node(void)
 
 static void __exit exit_o2nm(void)
 {
-       if (ocfs2_table_header)
-               unregister_sysctl_table(ocfs2_table_header);
-
        /* XXX sync with hb callbacks and shut down hb? */
        o2net_unregister_hb_callbacks();
        configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
@@ -964,16 +901,9 @@ static int __init init_o2nm(void)
        if (ret)
                goto out;
 
-       ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
-       if (!ocfs2_table_header) {
-               printk(KERN_ERR "nodemanager: unable to register sysctl\n");
-               ret = -ENOMEM; /* or something. */
-               goto out_o2net;
-       }
-
        ret = o2net_register_hb_callbacks();
        if (ret)
-               goto out_sysctl;
+               goto out_o2net;
 
        config_group_init(&o2nm_cluster_group.cs_subsys.su_group);
        mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex);
@@ -990,8 +920,6 @@ static int __init init_o2nm(void)
        configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
 out_callbacks:
        o2net_unregister_hb_callbacks();
-out_sysctl:
-       unregister_sysctl_table(ocfs2_table_header);
 out_o2net:
        o2net_exit();
 out:
index 7c860361b8ddc944a84c7b05ddf760df99b6cdd2..c992ea0da4add8295528b2e8b02c907ab9337df0 100644 (file)
 #include <linux/configfs.h>
 #include <linux/rbtree.h>
 
-#define FS_OCFS2_NM            1
-
-const char *o2nm_get_hb_ctl_path(void);
-
 struct o2nm_node {
        spinlock_t              nd_lock;
        struct config_item      nd_item;
index bbd1667aa7d3996035fdf517dd0dd71c034ec6e5..fb26a7c69c4747075b3bb4ff3c7c76df25e9728c 100644 (file)
@@ -338,7 +338,7 @@ static void o2hb_stop(const char *group)
        int ret;
        char *argv[5], *envp[3];
 
-       argv[0] = (char *)o2nm_get_hb_ctl_path();
+       argv[0] = (char *)ocfs2_get_hb_ctl_path();
        argv[1] = "-K";
        argv[2] = "-u";
        argv[3] = (char *)group;
index 119f60cea9cc27e8b2aca2214e8626e1558c7439..fb9b8e0db2602a73438f843d1628860e75e5ef28 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/fs.h>
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
+#include <linux/sysctl.h>
 
 #include "ocfs2_fs.h"
 
@@ -548,10 +549,92 @@ error:
        return ret;
 }
 
+/*
+ * Sysctl bits
+ *
+ * The sysctl lives at /proc/sys/fs/ocfs2/nm/hb_ctl_path.  The 'nm' doesn't
+ * make as much sense in a multiple cluster stack world, but it's safer
+ * and easier to preserve the name.
+ */
+
+#define FS_OCFS2_NM            1
+
+#define OCFS2_MAX_HB_CTL_PATH 256
+static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
+
+static ctl_table ocfs2_nm_table[] = {
+       {
+               .ctl_name       = 1,
+               .procname       = "hb_ctl_path",
+               .data           = ocfs2_hb_ctl_path,
+               .maxlen         = OCFS2_MAX_HB_CTL_PATH,
+               .mode           = 0644,
+               .proc_handler   = &proc_dostring,
+               .strategy       = &sysctl_string,
+       },
+       { .ctl_name = 0 }
+};
+
+static ctl_table ocfs2_mod_table[] = {
+       {
+               .ctl_name       = FS_OCFS2_NM,
+               .procname       = "nm",
+               .data           = NULL,
+               .maxlen         = 0,
+               .mode           = 0555,
+               .child          = ocfs2_nm_table
+       },
+       { .ctl_name = 0}
+};
+
+static ctl_table ocfs2_kern_table[] = {
+       {
+               .ctl_name       = FS_OCFS2,
+               .procname       = "ocfs2",
+               .data           = NULL,
+               .maxlen         = 0,
+               .mode           = 0555,
+               .child          = ocfs2_mod_table
+       },
+       { .ctl_name = 0}
+};
+
+static ctl_table ocfs2_root_table[] = {
+       {
+               .ctl_name       = CTL_FS,
+               .procname       = "fs",
+               .data           = NULL,
+               .maxlen         = 0,
+               .mode           = 0555,
+               .child          = ocfs2_kern_table
+       },
+       { .ctl_name = 0 }
+};
+
+static struct ctl_table_header *ocfs2_table_header = NULL;
+
+const char *ocfs2_get_hb_ctl_path(void)
+{
+       return ocfs2_hb_ctl_path;
+}
+EXPORT_SYMBOL_GPL(ocfs2_get_hb_ctl_path);
+
+
+/*
+ * Initialization
+ */
+
 static int __init ocfs2_stack_glue_init(void)
 {
        strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
 
+       ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
+       if (!ocfs2_table_header) {
+               printk(KERN_ERR
+                      "ocfs2 stack glue: unable to register sysctl\n");
+               return -ENOMEM; /* or something. */
+       }
+
        return ocfs2_sysfs_init();
 }
 
@@ -559,6 +642,8 @@ static void __exit ocfs2_stack_glue_exit(void)
 {
        lproto = NULL;
        ocfs2_sysfs_exit();
+       if (ocfs2_table_header)
+               unregister_sysctl_table(ocfs2_table_header);
 }
 
 MODULE_AUTHOR("Oracle");
index 005e4f170e0f998a44b2c9dab2524d0bd1fa1d79..c9fb01ab6347d65d8593ed37d3ae25bdac6d4b72 100644 (file)
@@ -258,4 +258,6 @@ void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto)
 /* Used by stack plugins */
 int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
 void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
+const char *ocfs2_get_hb_ctl_path(void);
+
 #endif  /* STACKGLUE_H */