Commit 3878f110f71a0971ff7acc15dd6db711b6ef37c6

Authored by Joel Becker
Committed by Mark Fasheh
1 parent 066519068a

ocfs2: Move the hb_ctl_path sysctl into the stack glue.

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>

Showing 5 changed files with 89 additions and 78 deletions Side-by-side Diff

fs/ocfs2/cluster/nodemanager.c
... ... @@ -21,7 +21,6 @@
21 21  
22 22 #include <linux/kernel.h>
23 23 #include <linux/module.h>
24   -#include <linux/sysctl.h>
25 24 #include <linux/configfs.h>
26 25  
27 26 #include "tcp.h"
28 27  
... ... @@ -36,66 +35,7 @@
36 35 * cluster references throughout where nodes are looked up */
37 36 struct o2nm_cluster *o2nm_single_cluster = NULL;
38 37  
39   -#define OCFS2_MAX_HB_CTL_PATH 256
40   -static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
41 38  
42   -static ctl_table ocfs2_nm_table[] = {
43   - {
44   - .ctl_name = 1,
45   - .procname = "hb_ctl_path",
46   - .data = ocfs2_hb_ctl_path,
47   - .maxlen = OCFS2_MAX_HB_CTL_PATH,
48   - .mode = 0644,
49   - .proc_handler = &proc_dostring,
50   - .strategy = &sysctl_string,
51   - },
52   - { .ctl_name = 0 }
53   -};
54   -
55   -static ctl_table ocfs2_mod_table[] = {
56   - {
57   - .ctl_name = FS_OCFS2_NM,
58   - .procname = "nm",
59   - .data = NULL,
60   - .maxlen = 0,
61   - .mode = 0555,
62   - .child = ocfs2_nm_table
63   - },
64   - { .ctl_name = 0}
65   -};
66   -
67   -static ctl_table ocfs2_kern_table[] = {
68   - {
69   - .ctl_name = FS_OCFS2,
70   - .procname = "ocfs2",
71   - .data = NULL,
72   - .maxlen = 0,
73   - .mode = 0555,
74   - .child = ocfs2_mod_table
75   - },
76   - { .ctl_name = 0}
77   -};
78   -
79   -static ctl_table ocfs2_root_table[] = {
80   - {
81   - .ctl_name = CTL_FS,
82   - .procname = "fs",
83   - .data = NULL,
84   - .maxlen = 0,
85   - .mode = 0555,
86   - .child = ocfs2_kern_table
87   - },
88   - { .ctl_name = 0 }
89   -};
90   -
91   -static struct ctl_table_header *ocfs2_table_header = NULL;
92   -
93   -const char *o2nm_get_hb_ctl_path(void)
94   -{
95   - return ocfs2_hb_ctl_path;
96   -}
97   -EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path);
98   -
99 39 struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
100 40 {
101 41 struct o2nm_node *node = NULL;
... ... @@ -941,9 +881,6 @@
941 881  
942 882 static void __exit exit_o2nm(void)
943 883 {
944   - if (ocfs2_table_header)
945   - unregister_sysctl_table(ocfs2_table_header);
946   -
947 884 /* XXX sync with hb callbacks and shut down hb? */
948 885 o2net_unregister_hb_callbacks();
949 886 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
950 887  
... ... @@ -964,16 +901,9 @@
964 901 if (ret)
965 902 goto out;
966 903  
967   - ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
968   - if (!ocfs2_table_header) {
969   - printk(KERN_ERR "nodemanager: unable to register sysctl\n");
970   - ret = -ENOMEM; /* or something. */
971   - goto out_o2net;
972   - }
973   -
974 904 ret = o2net_register_hb_callbacks();
975 905 if (ret)
976   - goto out_sysctl;
  906 + goto out_o2net;
977 907  
978 908 config_group_init(&o2nm_cluster_group.cs_subsys.su_group);
979 909 mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex);
... ... @@ -990,8 +920,6 @@
990 920 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
991 921 out_callbacks:
992 922 o2net_unregister_hb_callbacks();
993   -out_sysctl:
994   - unregister_sysctl_table(ocfs2_table_header);
995 923 out_o2net:
996 924 o2net_exit();
997 925 out:
fs/ocfs2/cluster/nodemanager.h
... ... @@ -33,10 +33,6 @@
33 33 #include <linux/configfs.h>
34 34 #include <linux/rbtree.h>
35 35  
36   -#define FS_OCFS2_NM 1
37   -
38   -const char *o2nm_get_hb_ctl_path(void);
39   -
40 36 struct o2nm_node {
41 37 spinlock_t nd_lock;
42 38 struct config_item nd_item;
fs/ocfs2/stack_o2cb.c
... ... @@ -338,7 +338,7 @@
338 338 int ret;
339 339 char *argv[5], *envp[3];
340 340  
341   - argv[0] = (char *)o2nm_get_hb_ctl_path();
  341 + argv[0] = (char *)ocfs2_get_hb_ctl_path();
342 342 argv[1] = "-K";
343 343 argv[2] = "-u";
344 344 argv[3] = (char *)group;
fs/ocfs2/stackglue.c
... ... @@ -26,6 +26,7 @@
26 26 #include <linux/fs.h>
27 27 #include <linux/kobject.h>
28 28 #include <linux/sysfs.h>
  29 +#include <linux/sysctl.h>
29 30  
30 31 #include "ocfs2_fs.h"
31 32  
32 33  
... ... @@ -548,10 +549,92 @@
548 549 return ret;
549 550 }
550 551  
  552 +/*
  553 + * Sysctl bits
  554 + *
  555 + * The sysctl lives at /proc/sys/fs/ocfs2/nm/hb_ctl_path. The 'nm' doesn't
  556 + * make as much sense in a multiple cluster stack world, but it's safer
  557 + * and easier to preserve the name.
  558 + */
  559 +
  560 +#define FS_OCFS2_NM 1
  561 +
  562 +#define OCFS2_MAX_HB_CTL_PATH 256
  563 +static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
  564 +
  565 +static ctl_table ocfs2_nm_table[] = {
  566 + {
  567 + .ctl_name = 1,
  568 + .procname = "hb_ctl_path",
  569 + .data = ocfs2_hb_ctl_path,
  570 + .maxlen = OCFS2_MAX_HB_CTL_PATH,
  571 + .mode = 0644,
  572 + .proc_handler = &proc_dostring,
  573 + .strategy = &sysctl_string,
  574 + },
  575 + { .ctl_name = 0 }
  576 +};
  577 +
  578 +static ctl_table ocfs2_mod_table[] = {
  579 + {
  580 + .ctl_name = FS_OCFS2_NM,
  581 + .procname = "nm",
  582 + .data = NULL,
  583 + .maxlen = 0,
  584 + .mode = 0555,
  585 + .child = ocfs2_nm_table
  586 + },
  587 + { .ctl_name = 0}
  588 +};
  589 +
  590 +static ctl_table ocfs2_kern_table[] = {
  591 + {
  592 + .ctl_name = FS_OCFS2,
  593 + .procname = "ocfs2",
  594 + .data = NULL,
  595 + .maxlen = 0,
  596 + .mode = 0555,
  597 + .child = ocfs2_mod_table
  598 + },
  599 + { .ctl_name = 0}
  600 +};
  601 +
  602 +static ctl_table ocfs2_root_table[] = {
  603 + {
  604 + .ctl_name = CTL_FS,
  605 + .procname = "fs",
  606 + .data = NULL,
  607 + .maxlen = 0,
  608 + .mode = 0555,
  609 + .child = ocfs2_kern_table
  610 + },
  611 + { .ctl_name = 0 }
  612 +};
  613 +
  614 +static struct ctl_table_header *ocfs2_table_header = NULL;
  615 +
  616 +const char *ocfs2_get_hb_ctl_path(void)
  617 +{
  618 + return ocfs2_hb_ctl_path;
  619 +}
  620 +EXPORT_SYMBOL_GPL(ocfs2_get_hb_ctl_path);
  621 +
  622 +
  623 +/*
  624 + * Initialization
  625 + */
  626 +
551 627 static int __init ocfs2_stack_glue_init(void)
552 628 {
553 629 strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
554 630  
  631 + ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
  632 + if (!ocfs2_table_header) {
  633 + printk(KERN_ERR
  634 + "ocfs2 stack glue: unable to register sysctl\n");
  635 + return -ENOMEM; /* or something. */
  636 + }
  637 +
555 638 return ocfs2_sysfs_init();
556 639 }
557 640  
... ... @@ -559,6 +642,8 @@
559 642 {
560 643 lproto = NULL;
561 644 ocfs2_sysfs_exit();
  645 + if (ocfs2_table_header)
  646 + unregister_sysctl_table(ocfs2_table_header);
562 647 }
563 648  
564 649 MODULE_AUTHOR("Oracle");
fs/ocfs2/stackglue.h
... ... @@ -258,5 +258,7 @@
258 258 /* Used by stack plugins */
259 259 int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
260 260 void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
  261 +const char *ocfs2_get_hb_ctl_path(void);
  262 +
261 263 #endif /* STACKGLUE_H */