Skip to content

Commit 3878f11

Browse files
Joel BeckerMark Fasheh
authored andcommitted
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>
1 parent 0665190 commit 3878f11

5 files changed

Lines changed: 89 additions & 78 deletions

File tree

‎fs/ocfs2/cluster/nodemanager.c‎

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <linux/kernel.h>
2323
#include <linux/module.h>
24-
#include <linux/sysctl.h>
2524
#include <linux/configfs.h>
2625

2726
#include "tcp.h"
@@ -36,65 +35,6 @@
3635
* cluster references throughout where nodes are looked up */
3736
struct o2nm_cluster *o2nm_single_cluster = NULL;
3837

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-
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);
9838

9939
struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
10040
{
@@ -941,9 +881,6 @@ void o2nm_undepend_this_node(void)
941881

942882
static void __exit exit_o2nm(void)
943883
{
944-
if (ocfs2_table_header)
945-
unregister_sysctl_table(ocfs2_table_header);
946-
947884
/* XXX sync with hb callbacks and shut down hb? */
948885
o2net_unregister_hb_callbacks();
949886
configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
@@ -964,16 +901,9 @@ static int __init init_o2nm(void)
964901
if (ret)
965902
goto out;
966903

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-
974904
ret = o2net_register_hb_callbacks();
975905
if (ret)
976-
goto out_sysctl;
906+
goto out_o2net;
977907

978908
config_group_init(&o2nm_cluster_group.cs_subsys.su_group);
979909
mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex);
@@ -990,8 +920,6 @@ static int __init init_o2nm(void)
990920
configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
991921
out_callbacks:
992922
o2net_unregister_hb_callbacks();
993-
out_sysctl:
994-
unregister_sysctl_table(ocfs2_table_header);
995923
out_o2net:
996924
o2net_exit();
997925
out:

‎fs/ocfs2/cluster/nodemanager.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#include <linux/configfs.h>
3434
#include <linux/rbtree.h>
3535

36-
#define FS_OCFS2_NM 1
37-
38-
const char *o2nm_get_hb_ctl_path(void);
39-
4036
struct o2nm_node {
4137
spinlock_t nd_lock;
4238
struct config_item nd_item;

‎fs/ocfs2/stack_o2cb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void o2hb_stop(const char *group)
338338
int ret;
339339
char *argv[5], *envp[3];
340340

341-
argv[0] = (char *)o2nm_get_hb_ctl_path();
341+
argv[0] = (char *)ocfs2_get_hb_ctl_path();
342342
argv[1] = "-K";
343343
argv[2] = "-u";
344344
argv[3] = (char *)group;

‎fs/ocfs2/stackglue.c‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/fs.h>
2727
#include <linux/kobject.h>
2828
#include <linux/sysfs.h>
29+
#include <linux/sysctl.h>
2930

3031
#include "ocfs2_fs.h"
3132

@@ -548,17 +549,101 @@ static int ocfs2_sysfs_init(void)
548549
return ret;
549550
}
550551

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+
551627
static int __init ocfs2_stack_glue_init(void)
552628
{
553629
strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
554630

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+
555638
return ocfs2_sysfs_init();
556639
}
557640

558641
static void __exit ocfs2_stack_glue_exit(void)
559642
{
560643
lproto = NULL;
561644
ocfs2_sysfs_exit();
645+
if (ocfs2_table_header)
646+
unregister_sysctl_table(ocfs2_table_header);
562647
}
563648

564649
MODULE_AUTHOR("Oracle");

‎fs/ocfs2/stackglue.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,6 @@ void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto)
258258
/* Used by stack plugins */
259259
int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
260260
void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
261+
const char *ocfs2_get_hb_ctl_path(void);
262+
261263
#endif /* STACKGLUE_H */

0 commit comments

Comments
 (0)