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>

authored by Joel Becker and committed by Mark Fasheh 3878f110 06651906

+89 -78
+1 -73
fs/ocfs2/cluster/nodemanager.c
··· 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" ··· 35 36 * cluster references throughout where nodes are looked up */ 36 37 struct o2nm_cluster *o2nm_single_cluster = NULL; 37 38 38 - #define OCFS2_MAX_HB_CTL_PATH 256 39 - static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; 40 - 41 - static ctl_table ocfs2_nm_table[] = { 42 - { 43 - .ctl_name = 1, 44 - .procname = "hb_ctl_path", 45 - .data = ocfs2_hb_ctl_path, 46 - .maxlen = OCFS2_MAX_HB_CTL_PATH, 47 - .mode = 0644, 48 - .proc_handler = &proc_dostring, 49 - .strategy = &sysctl_string, 50 - }, 51 - { .ctl_name = 0 } 52 - }; 53 - 54 - static ctl_table ocfs2_mod_table[] = { 55 - { 56 - .ctl_name = FS_OCFS2_NM, 57 - .procname = "nm", 58 - .data = NULL, 59 - .maxlen = 0, 60 - .mode = 0555, 61 - .child = ocfs2_nm_table 62 - }, 63 - { .ctl_name = 0} 64 - }; 65 - 66 - static ctl_table ocfs2_kern_table[] = { 67 - { 68 - .ctl_name = FS_OCFS2, 69 - .procname = "ocfs2", 70 - .data = NULL, 71 - .maxlen = 0, 72 - .mode = 0555, 73 - .child = ocfs2_mod_table 74 - }, 75 - { .ctl_name = 0} 76 - }; 77 - 78 - static ctl_table ocfs2_root_table[] = { 79 - { 80 - .ctl_name = CTL_FS, 81 - .procname = "fs", 82 - .data = NULL, 83 - .maxlen = 0, 84 - .mode = 0555, 85 - .child = ocfs2_kern_table 86 - }, 87 - { .ctl_name = 0 } 88 - }; 89 - 90 - static struct ctl_table_header *ocfs2_table_header = NULL; 91 - 92 - const char *o2nm_get_hb_ctl_path(void) 93 - { 94 - return ocfs2_hb_ctl_path; 95 - } 96 - EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path); 97 39 98 40 struct o2nm_node *o2nm_get_node_by_num(u8 node_num) 99 41 { ··· 881 941 882 942 static void __exit exit_o2nm(void) 883 943 { 884 - if (ocfs2_table_header) 885 - unregister_sysctl_table(ocfs2_table_header); 886 - 887 944 /* XXX sync with hb callbacks and shut down hb? */ 888 945 o2net_unregister_hb_callbacks(); 889 946 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); ··· 901 964 if (ret) 902 965 goto out; 903 966 904 - ocfs2_table_header = register_sysctl_table(ocfs2_root_table); 905 - if (!ocfs2_table_header) { 906 - printk(KERN_ERR "nodemanager: unable to register sysctl\n"); 907 - ret = -ENOMEM; /* or something. */ 908 - goto out_o2net; 909 - } 910 - 911 967 ret = o2net_register_hb_callbacks(); 912 968 if (ret) 913 - goto out_sysctl; 969 + goto out_o2net; 914 970 915 971 config_group_init(&o2nm_cluster_group.cs_subsys.su_group); 916 972 mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex); ··· 920 990 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); 921 991 out_callbacks: 922 992 o2net_unregister_hb_callbacks(); 923 - out_sysctl: 924 - unregister_sysctl_table(ocfs2_table_header); 925 993 out_o2net: 926 994 o2net_exit(); 927 995 out:
-4
fs/ocfs2/cluster/nodemanager.h
··· 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;
+1 -1
fs/ocfs2/stack_o2cb.c
··· 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;
+85
fs/ocfs2/stackglue.c
··· 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 ··· 549 548 return ret; 550 549 } 551 550 551 + /* 552 + * Sysctl bits 553 + * 554 + * The sysctl lives at /proc/sys/fs/ocfs2/nm/hb_ctl_path. The 'nm' doesn't 555 + * make as much sense in a multiple cluster stack world, but it's safer 556 + * and easier to preserve the name. 557 + */ 558 + 559 + #define FS_OCFS2_NM 1 560 + 561 + #define OCFS2_MAX_HB_CTL_PATH 256 562 + static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; 563 + 564 + static ctl_table ocfs2_nm_table[] = { 565 + { 566 + .ctl_name = 1, 567 + .procname = "hb_ctl_path", 568 + .data = ocfs2_hb_ctl_path, 569 + .maxlen = OCFS2_MAX_HB_CTL_PATH, 570 + .mode = 0644, 571 + .proc_handler = &proc_dostring, 572 + .strategy = &sysctl_string, 573 + }, 574 + { .ctl_name = 0 } 575 + }; 576 + 577 + static ctl_table ocfs2_mod_table[] = { 578 + { 579 + .ctl_name = FS_OCFS2_NM, 580 + .procname = "nm", 581 + .data = NULL, 582 + .maxlen = 0, 583 + .mode = 0555, 584 + .child = ocfs2_nm_table 585 + }, 586 + { .ctl_name = 0} 587 + }; 588 + 589 + static ctl_table ocfs2_kern_table[] = { 590 + { 591 + .ctl_name = FS_OCFS2, 592 + .procname = "ocfs2", 593 + .data = NULL, 594 + .maxlen = 0, 595 + .mode = 0555, 596 + .child = ocfs2_mod_table 597 + }, 598 + { .ctl_name = 0} 599 + }; 600 + 601 + static ctl_table ocfs2_root_table[] = { 602 + { 603 + .ctl_name = CTL_FS, 604 + .procname = "fs", 605 + .data = NULL, 606 + .maxlen = 0, 607 + .mode = 0555, 608 + .child = ocfs2_kern_table 609 + }, 610 + { .ctl_name = 0 } 611 + }; 612 + 613 + static struct ctl_table_header *ocfs2_table_header = NULL; 614 + 615 + const char *ocfs2_get_hb_ctl_path(void) 616 + { 617 + return ocfs2_hb_ctl_path; 618 + } 619 + EXPORT_SYMBOL_GPL(ocfs2_get_hb_ctl_path); 620 + 621 + 622 + /* 623 + * Initialization 624 + */ 625 + 552 626 static int __init ocfs2_stack_glue_init(void) 553 627 { 554 628 strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); 629 + 630 + ocfs2_table_header = register_sysctl_table(ocfs2_root_table); 631 + if (!ocfs2_table_header) { 632 + printk(KERN_ERR 633 + "ocfs2 stack glue: unable to register sysctl\n"); 634 + return -ENOMEM; /* or something. */ 635 + } 555 636 556 637 return ocfs2_sysfs_init(); 557 638 } ··· 642 559 { 643 560 lproto = NULL; 644 561 ocfs2_sysfs_exit(); 562 + if (ocfs2_table_header) 563 + unregister_sysctl_table(ocfs2_table_header); 645 564 } 646 565 647 566 MODULE_AUTHOR("Oracle");
+2
fs/ocfs2/stackglue.h
··· 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 */