aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-07-14 17:29:34 -0400
committerJonathan Corbet <corbet@lwn.net>2008-07-14 17:29:34 -0400
commit2fceef397f9880b212a74c418290ce69e7ac00eb (patch)
treed9cc09ab992825ef7fede4a688103503e3caf655 /fs/ocfs2
parentfeae1ef116ed381625d3731c5ae4f4ebcb3fa302 (diff)
parentbce7f793daec3e65ec5c5705d2457b81fe7b5725 (diff)
Merge commit 'v2.6.26' into bkl-removal
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/alloc.c4
-rw-r--r--fs/ocfs2/cluster/nodemanager.c74
-rw-r--r--fs/ocfs2/cluster/nodemanager.h4
-rw-r--r--fs/ocfs2/cluster/tcp.c28
-rw-r--r--fs/ocfs2/cluster/tcp.h12
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h32
-rw-r--r--fs/ocfs2/dlm/dlmdebug.h12
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c2
-rw-r--r--fs/ocfs2/dlmglue.c14
-rw-r--r--fs/ocfs2/stack_o2cb.c41
-rw-r--r--fs/ocfs2/stack_user.c37
-rw-r--r--fs/ocfs2/stackglue.c119
-rw-r--r--fs/ocfs2/stackglue.h19
13 files changed, 204 insertions, 194 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 41f84c92094f..10bfb466e068 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -2788,7 +2788,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
2788 BUG_ON(index >= le16_to_cpu(el->l_next_free_rec)); 2788 BUG_ON(index >= le16_to_cpu(el->l_next_free_rec));
2789 left_rec = &el->l_recs[index]; 2789 left_rec = &el->l_recs[index];
2790 2790
2791 if (index == le16_to_cpu(el->l_next_free_rec - 1) && 2791 if (index == le16_to_cpu(el->l_next_free_rec) - 1 &&
2792 le16_to_cpu(el->l_next_free_rec) == le16_to_cpu(el->l_count)) { 2792 le16_to_cpu(el->l_next_free_rec) == le16_to_cpu(el->l_count)) {
2793 /* we meet with a cross extent block merge. */ 2793 /* we meet with a cross extent block merge. */
2794 ret = ocfs2_get_right_path(inode, left_path, &right_path); 2794 ret = ocfs2_get_right_path(inode, left_path, &right_path);
@@ -2802,7 +2802,7 @@ static int ocfs2_merge_rec_right(struct inode *inode,
2802 BUG_ON(next_free <= 0); 2802 BUG_ON(next_free <= 0);
2803 right_rec = &right_el->l_recs[0]; 2803 right_rec = &right_el->l_recs[0];
2804 if (ocfs2_is_empty_extent(right_rec)) { 2804 if (ocfs2_is_empty_extent(right_rec)) {
2805 BUG_ON(le16_to_cpu(next_free) <= 1); 2805 BUG_ON(next_free <= 1);
2806 right_rec = &right_el->l_recs[1]; 2806 right_rec = &right_el->l_recs[1];
2807 } 2807 }
2808 2808
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index cf9401e8cd0b..cfdb08b484ed 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/sysctl.h>
25#include <linux/configfs.h> 24#include <linux/configfs.h>
26 25
27#include "tcp.h" 26#include "tcp.h"
@@ -36,65 +35,6 @@
36 * cluster references throughout where nodes are looked up */ 35 * cluster references throughout where nodes are looked up */
37struct o2nm_cluster *o2nm_single_cluster = NULL; 36struct o2nm_cluster *o2nm_single_cluster = NULL;
38 37
39#define OCFS2_MAX_HB_CTL_PATH 256
40static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
41
42static 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
55static 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
67static 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
79static 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
91static struct ctl_table_header *ocfs2_table_header = NULL;
92
93const char *o2nm_get_hb_ctl_path(void)
94{
95 return ocfs2_hb_ctl_path;
96}
97EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path);
98 38
99struct o2nm_node *o2nm_get_node_by_num(u8 node_num) 39struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
100{ 40{
@@ -941,9 +881,6 @@ void o2nm_undepend_this_node(void)
941 881
942static void __exit exit_o2nm(void) 882static void __exit exit_o2nm(void)
943{ 883{
944 if (ocfs2_table_header)
945 unregister_sysctl_table(ocfs2_table_header);
946
947 /* XXX sync with hb callbacks and shut down hb? */ 884 /* XXX sync with hb callbacks and shut down hb? */
948 o2net_unregister_hb_callbacks(); 885 o2net_unregister_hb_callbacks();
949 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); 886 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
@@ -964,16 +901,9 @@ static int __init init_o2nm(void)
964 if (ret) 901 if (ret)
965 goto out; 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 ret = o2net_register_hb_callbacks(); 904 ret = o2net_register_hb_callbacks();
975 if (ret) 905 if (ret)
976 goto out_sysctl; 906 goto out_o2net;
977 907
978 config_group_init(&o2nm_cluster_group.cs_subsys.su_group); 908 config_group_init(&o2nm_cluster_group.cs_subsys.su_group);
979 mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex); 909 mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex);
@@ -990,8 +920,6 @@ static int __init init_o2nm(void)
990 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); 920 configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys);
991out_callbacks: 921out_callbacks:
992 o2net_unregister_hb_callbacks(); 922 o2net_unregister_hb_callbacks();
993out_sysctl:
994 unregister_sysctl_table(ocfs2_table_header);
995out_o2net: 923out_o2net:
996 o2net_exit(); 924 o2net_exit();
997out: 925out:
diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h
index 7c860361b8dd..c992ea0da4ad 100644
--- a/fs/ocfs2/cluster/nodemanager.h
+++ b/fs/ocfs2/cluster/nodemanager.h
@@ -33,10 +33,6 @@
33#include <linux/configfs.h> 33#include <linux/configfs.h>
34#include <linux/rbtree.h> 34#include <linux/rbtree.h>
35 35
36#define FS_OCFS2_NM 1
37
38const char *o2nm_get_hb_ctl_path(void);
39
40struct o2nm_node { 36struct o2nm_node {
41 spinlock_t nd_lock; 37 spinlock_t nd_lock;
42 struct config_item nd_item; 38 struct config_item nd_item;
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 1e44ad14881a..a27d61581bd6 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -142,53 +142,43 @@ static void o2net_idle_timer(unsigned long data);
142static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 142static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
143static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc); 143static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc);
144 144
145static void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
146 u32 msgkey, struct task_struct *task, u8 node)
147{
148#ifdef CONFIG_DEBUG_FS 145#ifdef CONFIG_DEBUG_FS
146void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
147 u32 msgkey, struct task_struct *task, u8 node)
148{
149 INIT_LIST_HEAD(&nst->st_net_debug_item); 149 INIT_LIST_HEAD(&nst->st_net_debug_item);
150 nst->st_task = task; 150 nst->st_task = task;
151 nst->st_msg_type = msgtype; 151 nst->st_msg_type = msgtype;
152 nst->st_msg_key = msgkey; 152 nst->st_msg_key = msgkey;
153 nst->st_node = node; 153 nst->st_node = node;
154#endif
155} 154}
156 155
157static void o2net_set_nst_sock_time(struct o2net_send_tracking *nst) 156void o2net_set_nst_sock_time(struct o2net_send_tracking *nst)
158{ 157{
159#ifdef CONFIG_DEBUG_FS
160 do_gettimeofday(&nst->st_sock_time); 158 do_gettimeofday(&nst->st_sock_time);
161#endif
162} 159}
163 160
164static void o2net_set_nst_send_time(struct o2net_send_tracking *nst) 161void o2net_set_nst_send_time(struct o2net_send_tracking *nst)
165{ 162{
166#ifdef CONFIG_DEBUG_FS
167 do_gettimeofday(&nst->st_send_time); 163 do_gettimeofday(&nst->st_send_time);
168#endif
169} 164}
170 165
171static void o2net_set_nst_status_time(struct o2net_send_tracking *nst) 166void o2net_set_nst_status_time(struct o2net_send_tracking *nst)
172{ 167{
173#ifdef CONFIG_DEBUG_FS
174 do_gettimeofday(&nst->st_status_time); 168 do_gettimeofday(&nst->st_status_time);
175#endif
176} 169}
177 170
178static void o2net_set_nst_sock_container(struct o2net_send_tracking *nst, 171void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
179 struct o2net_sock_container *sc) 172 struct o2net_sock_container *sc)
180{ 173{
181#ifdef CONFIG_DEBUG_FS
182 nst->st_sc = sc; 174 nst->st_sc = sc;
183#endif
184} 175}
185 176
186static void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id) 177void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id)
187{ 178{
188#ifdef CONFIG_DEBUG_FS
189 nst->st_id = msg_id; 179 nst->st_id = msg_id;
190#endif
191} 180}
181#endif /* CONFIG_DEBUG_FS */
192 182
193static inline int o2net_reconnect_delay(void) 183static inline int o2net_reconnect_delay(void)
194{ 184{
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h
index a705d5d19036..fd6179eb26d4 100644
--- a/fs/ocfs2/cluster/tcp.h
+++ b/fs/ocfs2/cluster/tcp.h
@@ -128,23 +128,23 @@ void o2net_debug_del_nst(struct o2net_send_tracking *nst);
128void o2net_debug_add_sc(struct o2net_sock_container *sc); 128void o2net_debug_add_sc(struct o2net_sock_container *sc);
129void o2net_debug_del_sc(struct o2net_sock_container *sc); 129void o2net_debug_del_sc(struct o2net_sock_container *sc);
130#else 130#else
131static int o2net_debugfs_init(void) 131static inline int o2net_debugfs_init(void)
132{ 132{
133 return 0; 133 return 0;
134} 134}
135static void o2net_debugfs_exit(void) 135static inline void o2net_debugfs_exit(void)
136{ 136{
137} 137}
138static void o2net_debug_add_nst(struct o2net_send_tracking *nst) 138static inline void o2net_debug_add_nst(struct o2net_send_tracking *nst)
139{ 139{
140} 140}
141static void o2net_debug_del_nst(struct o2net_send_tracking *nst) 141static inline void o2net_debug_del_nst(struct o2net_send_tracking *nst)
142{ 142{
143} 143}
144static void o2net_debug_add_sc(struct o2net_sock_container *sc) 144static inline void o2net_debug_add_sc(struct o2net_sock_container *sc)
145{ 145{
146} 146}
147static void o2net_debug_del_sc(struct o2net_sock_container *sc) 147static inline void o2net_debug_del_sc(struct o2net_sock_container *sc)
148{ 148{
149} 149}
150#endif /* CONFIG_DEBUG_FS */ 150#endif /* CONFIG_DEBUG_FS */
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 8d58cfe410b1..18307ff81b77 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -224,10 +224,42 @@ struct o2net_send_tracking {
224 struct timeval st_send_time; 224 struct timeval st_send_time;
225 struct timeval st_status_time; 225 struct timeval st_status_time;
226}; 226};
227
228void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
229 u32 msgkey, struct task_struct *task, u8 node);
230void o2net_set_nst_sock_time(struct o2net_send_tracking *nst);
231void o2net_set_nst_send_time(struct o2net_send_tracking *nst);
232void o2net_set_nst_status_time(struct o2net_send_tracking *nst);
233void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
234 struct o2net_sock_container *sc);
235void o2net_set_nst_msg_id(struct o2net_send_tracking *nst, u32 msg_id);
236
227#else 237#else
228struct o2net_send_tracking { 238struct o2net_send_tracking {
229 u32 dummy; 239 u32 dummy;
230}; 240};
241
242static inline void o2net_init_nst(struct o2net_send_tracking *nst, u32 msgtype,
243 u32 msgkey, struct task_struct *task, u8 node)
244{
245}
246static inline void o2net_set_nst_sock_time(struct o2net_send_tracking *nst)
247{
248}
249static inline void o2net_set_nst_send_time(struct o2net_send_tracking *nst)
250{
251}
252static inline void o2net_set_nst_status_time(struct o2net_send_tracking *nst)
253{
254}
255static inline void o2net_set_nst_sock_container(struct o2net_send_tracking *nst,
256 struct o2net_sock_container *sc)
257{
258}
259static inline void o2net_set_nst_msg_id(struct o2net_send_tracking *nst,
260 u32 msg_id)
261{
262}
231#endif /* CONFIG_DEBUG_FS */ 263#endif /* CONFIG_DEBUG_FS */
232 264
233#endif /* O2CLUSTER_TCP_INTERNAL_H */ 265#endif /* O2CLUSTER_TCP_INTERNAL_H */
diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h
index d34a62a3a625..8c686d22f9c7 100644
--- a/fs/ocfs2/dlm/dlmdebug.h
+++ b/fs/ocfs2/dlm/dlmdebug.h
@@ -60,25 +60,25 @@ void dlm_destroy_debugfs_root(void);
60 60
61#else 61#else
62 62
63static int dlm_debug_init(struct dlm_ctxt *dlm) 63static inline int dlm_debug_init(struct dlm_ctxt *dlm)
64{ 64{
65 return 0; 65 return 0;
66} 66}
67static void dlm_debug_shutdown(struct dlm_ctxt *dlm) 67static inline void dlm_debug_shutdown(struct dlm_ctxt *dlm)
68{ 68{
69} 69}
70static int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) 70static inline int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm)
71{ 71{
72 return 0; 72 return 0;
73} 73}
74static void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm) 74static inline void dlm_destroy_debugfs_subroot(struct dlm_ctxt *dlm)
75{ 75{
76} 76}
77static int dlm_create_debugfs_root(void) 77static inline int dlm_create_debugfs_root(void)
78{ 78{
79 return 0; 79 return 0;
80} 80}
81static void dlm_destroy_debugfs_root(void) 81static inline void dlm_destroy_debugfs_root(void)
82{ 82{
83} 83}
84 84
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index efc015c6128a..44f87caf3683 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -606,7 +606,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm,
606 606
607 res->last_used = 0; 607 res->last_used = 0;
608 608
609 spin_lock(&dlm->spinlock);
609 list_add_tail(&res->tracking, &dlm->tracking_list); 610 list_add_tail(&res->tracking, &dlm->tracking_list);
611 spin_unlock(&dlm->spinlock);
610 612
611 memset(res->lvb, 0, DLM_LVB_LEN); 613 memset(res->lvb, 0, DLM_LVB_LEN);
612 memset(res->refmap, 0, sizeof(res->refmap)); 614 memset(res->refmap, 0, sizeof(res->refmap));
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 394d25a131a5..80e20d9f2780 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -1554,8 +1554,8 @@ out:
1554 */ 1554 */
1555int ocfs2_file_lock(struct file *file, int ex, int trylock) 1555int ocfs2_file_lock(struct file *file, int ex, int trylock)
1556{ 1556{
1557 int ret, level = ex ? LKM_EXMODE : LKM_PRMODE; 1557 int ret, level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
1558 unsigned int lkm_flags = trylock ? LKM_NOQUEUE : 0; 1558 unsigned int lkm_flags = trylock ? DLM_LKF_NOQUEUE : 0;
1559 unsigned long flags; 1559 unsigned long flags;
1560 struct ocfs2_file_private *fp = file->private_data; 1560 struct ocfs2_file_private *fp = file->private_data;
1561 struct ocfs2_lock_res *lockres = &fp->fp_flock; 1561 struct ocfs2_lock_res *lockres = &fp->fp_flock;
@@ -1582,7 +1582,7 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
1582 * Get the lock at NLMODE to start - that way we 1582 * Get the lock at NLMODE to start - that way we
1583 * can cancel the upconvert request if need be. 1583 * can cancel the upconvert request if need be.
1584 */ 1584 */
1585 ret = ocfs2_lock_create(osb, lockres, LKM_NLMODE, 0); 1585 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0);
1586 if (ret < 0) { 1586 if (ret < 0) {
1587 mlog_errno(ret); 1587 mlog_errno(ret);
1588 goto out; 1588 goto out;
@@ -1597,7 +1597,7 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
1597 } 1597 }
1598 1598
1599 lockres->l_action = OCFS2_AST_CONVERT; 1599 lockres->l_action = OCFS2_AST_CONVERT;
1600 lkm_flags |= LKM_CONVERT; 1600 lkm_flags |= DLM_LKF_CONVERT;
1601 lockres->l_requested = level; 1601 lockres->l_requested = level;
1602 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); 1602 lockres_or_flags(lockres, OCFS2_LOCK_BUSY);
1603 1603
@@ -1664,7 +1664,7 @@ void ocfs2_file_unlock(struct file *file)
1664 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) 1664 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED))
1665 return; 1665 return;
1666 1666
1667 if (lockres->l_level == LKM_NLMODE) 1667 if (lockres->l_level == DLM_LOCK_NL)
1668 return; 1668 return;
1669 1669
1670 mlog(0, "Unlock: \"%s\" flags: 0x%lx, level: %d, act: %d\n", 1670 mlog(0, "Unlock: \"%s\" flags: 0x%lx, level: %d, act: %d\n",
@@ -1678,11 +1678,11 @@ void ocfs2_file_unlock(struct file *file)
1678 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); 1678 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED);
1679 lockres->l_blocking = DLM_LOCK_EX; 1679 lockres->l_blocking = DLM_LOCK_EX;
1680 1680
1681 gen = ocfs2_prepare_downconvert(lockres, LKM_NLMODE); 1681 gen = ocfs2_prepare_downconvert(lockres, DLM_LOCK_NL);
1682 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); 1682 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0);
1683 spin_unlock_irqrestore(&lockres->l_lock, flags); 1683 spin_unlock_irqrestore(&lockres->l_lock, flags);
1684 1684
1685 ret = ocfs2_downconvert_lock(osb, lockres, LKM_NLMODE, 0, gen); 1685 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen);
1686 if (ret) { 1686 if (ret) {
1687 mlog_errno(ret); 1687 mlog_errno(ret);
1688 return; 1688 return;
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index bbd1667aa7d3..fcd120f1493a 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -317,8 +317,7 @@ out:
317 return rc; 317 return rc;
318} 318}
319 319
320static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn, 320static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn)
321 int hangup_pending)
322{ 321{
323 struct dlm_ctxt *dlm = conn->cc_lockspace; 322 struct dlm_ctxt *dlm = conn->cc_lockspace;
324 struct o2dlm_private *priv = conn->cc_private; 323 struct o2dlm_private *priv = conn->cc_private;
@@ -333,43 +332,6 @@ static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn,
333 return 0; 332 return 0;
334} 333}
335 334
336static void o2hb_stop(const char *group)
337{
338 int ret;
339 char *argv[5], *envp[3];
340
341 argv[0] = (char *)o2nm_get_hb_ctl_path();
342 argv[1] = "-K";
343 argv[2] = "-u";
344 argv[3] = (char *)group;
345 argv[4] = NULL;
346
347 mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]);
348
349 /* minimal command environment taken from cpu_run_sbin_hotplug */
350 envp[0] = "HOME=/";
351 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
352 envp[2] = NULL;
353
354 ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
355 if (ret < 0)
356 mlog_errno(ret);
357}
358
359/*
360 * Hangup is a hack for tools compatibility. Older ocfs2-tools software
361 * expects the filesystem to call "ocfs2_hb_ctl" during unmount. This
362 * happens regardless of whether the DLM got started, so we can't do it
363 * in ocfs2_cluster_disconnect(). We bring the o2hb_stop() function into
364 * the glue and provide a "hangup" API for super.c to call.
365 *
366 * Other stacks will eventually provide a NULL ->hangup() pointer.
367 */
368static void o2cb_cluster_hangup(const char *group, int grouplen)
369{
370 o2hb_stop(group);
371}
372
373static int o2cb_cluster_this_node(unsigned int *node) 335static int o2cb_cluster_this_node(unsigned int *node)
374{ 336{
375 int node_num; 337 int node_num;
@@ -388,7 +350,6 @@ static int o2cb_cluster_this_node(unsigned int *node)
388static struct ocfs2_stack_operations o2cb_stack_ops = { 350static struct ocfs2_stack_operations o2cb_stack_ops = {
389 .connect = o2cb_cluster_connect, 351 .connect = o2cb_cluster_connect,
390 .disconnect = o2cb_cluster_disconnect, 352 .disconnect = o2cb_cluster_disconnect,
391 .hangup = o2cb_cluster_hangup,
392 .this_node = o2cb_cluster_this_node, 353 .this_node = o2cb_cluster_this_node,
393 .dlm_lock = o2cb_dlm_lock, 354 .dlm_lock = o2cb_dlm_lock,
394 .dlm_unlock = o2cb_dlm_unlock, 355 .dlm_unlock = o2cb_dlm_unlock,
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index cd120011104d..bd7e0f3acfc7 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -62,7 +62,7 @@
62 * negotiated by the client. The client negotiates based on the maximum 62 * negotiated by the client. The client negotiates based on the maximum
63 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major 63 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major
64 * number from the "SETV" message must match 64 * number from the "SETV" message must match
65 * user_stack.sp_proto->lp_max_version.pv_major, and the minor number 65 * ocfs2_user_plugin.sp_proto->lp_max_version.pv_major, and the minor number
66 * must be less than or equal to ...->lp_max_version.pv_minor. 66 * must be less than or equal to ...->lp_max_version.pv_minor.
67 * 67 *
68 * Once this information has been set, mounts will be allowed. From this 68 * Once this information has been set, mounts will be allowed. From this
@@ -154,7 +154,7 @@ union ocfs2_control_message {
154 struct ocfs2_control_message_down u_down; 154 struct ocfs2_control_message_down u_down;
155}; 155};
156 156
157static struct ocfs2_stack_plugin user_stack; 157static struct ocfs2_stack_plugin ocfs2_user_plugin;
158 158
159static atomic_t ocfs2_control_opened; 159static atomic_t ocfs2_control_opened;
160static int ocfs2_control_this_node = -1; 160static int ocfs2_control_this_node = -1;
@@ -400,7 +400,7 @@ static int ocfs2_control_do_setversion_msg(struct file *file,
400 char *ptr = NULL; 400 char *ptr = NULL;
401 struct ocfs2_control_private *p = file->private_data; 401 struct ocfs2_control_private *p = file->private_data;
402 struct ocfs2_protocol_version *max = 402 struct ocfs2_protocol_version *max =
403 &user_stack.sp_proto->lp_max_version; 403 &ocfs2_user_plugin.sp_proto->lp_max_version;
404 404
405 if (ocfs2_control_get_handshake_state(file) != 405 if (ocfs2_control_get_handshake_state(file) !=
406 OCFS2_CONTROL_HANDSHAKE_PROTOCOL) 406 OCFS2_CONTROL_HANDSHAKE_PROTOCOL)
@@ -683,7 +683,7 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
683 struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg); 683 struct dlm_lksb *lksb = fsdlm_astarg_to_lksb(astarg);
684 int status = lksb->sb_status; 684 int status = lksb->sb_status;
685 685
686 BUG_ON(user_stack.sp_proto == NULL); 686 BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
687 687
688 /* 688 /*
689 * For now we're punting on the issue of other non-standard errors 689 * For now we're punting on the issue of other non-standard errors
@@ -696,16 +696,16 @@ static void fsdlm_lock_ast_wrapper(void *astarg)
696 */ 696 */
697 697
698 if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL) 698 if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL)
699 user_stack.sp_proto->lp_unlock_ast(astarg, 0); 699 ocfs2_user_plugin.sp_proto->lp_unlock_ast(astarg, 0);
700 else 700 else
701 user_stack.sp_proto->lp_lock_ast(astarg); 701 ocfs2_user_plugin.sp_proto->lp_lock_ast(astarg);
702} 702}
703 703
704static void fsdlm_blocking_ast_wrapper(void *astarg, int level) 704static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
705{ 705{
706 BUG_ON(user_stack.sp_proto == NULL); 706 BUG_ON(ocfs2_user_plugin.sp_proto == NULL);
707 707
708 user_stack.sp_proto->lp_blocking_ast(astarg, level); 708 ocfs2_user_plugin.sp_proto->lp_blocking_ast(astarg, level);
709} 709}
710 710
711static int user_dlm_lock(struct ocfs2_cluster_connection *conn, 711static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
@@ -819,8 +819,7 @@ out:
819 return rc; 819 return rc;
820} 820}
821 821
822static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn, 822static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
823 int hangup_pending)
824{ 823{
825 dlm_release_lockspace(conn->cc_lockspace, 2); 824 dlm_release_lockspace(conn->cc_lockspace, 2);
826 conn->cc_lockspace = NULL; 825 conn->cc_lockspace = NULL;
@@ -841,7 +840,7 @@ static int user_cluster_this_node(unsigned int *this_node)
841 return 0; 840 return 0;
842} 841}
843 842
844static struct ocfs2_stack_operations user_stack_ops = { 843static struct ocfs2_stack_operations ocfs2_user_plugin_ops = {
845 .connect = user_cluster_connect, 844 .connect = user_cluster_connect,
846 .disconnect = user_cluster_disconnect, 845 .disconnect = user_cluster_disconnect,
847 .this_node = user_cluster_this_node, 846 .this_node = user_cluster_this_node,
@@ -852,20 +851,20 @@ static struct ocfs2_stack_operations user_stack_ops = {
852 .dump_lksb = user_dlm_dump_lksb, 851 .dump_lksb = user_dlm_dump_lksb,
853}; 852};
854 853
855static struct ocfs2_stack_plugin user_stack = { 854static struct ocfs2_stack_plugin ocfs2_user_plugin = {
856 .sp_name = "user", 855 .sp_name = "user",
857 .sp_ops = &user_stack_ops, 856 .sp_ops = &ocfs2_user_plugin_ops,
858 .sp_owner = THIS_MODULE, 857 .sp_owner = THIS_MODULE,
859}; 858};
860 859
861 860
862static int __init user_stack_init(void) 861static int __init ocfs2_user_plugin_init(void)
863{ 862{
864 int rc; 863 int rc;
865 864
866 rc = ocfs2_control_init(); 865 rc = ocfs2_control_init();
867 if (!rc) { 866 if (!rc) {
868 rc = ocfs2_stack_glue_register(&user_stack); 867 rc = ocfs2_stack_glue_register(&ocfs2_user_plugin);
869 if (rc) 868 if (rc)
870 ocfs2_control_exit(); 869 ocfs2_control_exit();
871 } 870 }
@@ -873,14 +872,14 @@ static int __init user_stack_init(void)
873 return rc; 872 return rc;
874} 873}
875 874
876static void __exit user_stack_exit(void) 875static void __exit ocfs2_user_plugin_exit(void)
877{ 876{
878 ocfs2_stack_glue_unregister(&user_stack); 877 ocfs2_stack_glue_unregister(&ocfs2_user_plugin);
879 ocfs2_control_exit(); 878 ocfs2_control_exit();
880} 879}
881 880
882MODULE_AUTHOR("Oracle"); 881MODULE_AUTHOR("Oracle");
883MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks"); 882MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks");
884MODULE_LICENSE("GPL"); 883MODULE_LICENSE("GPL");
885module_init(user_stack_init); 884module_init(ocfs2_user_plugin_init);
886module_exit(user_stack_exit); 885module_exit(ocfs2_user_plugin_exit);
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 119f60cea9cc..10e149ae5e3a 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -26,6 +26,7 @@
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/kobject.h> 27#include <linux/kobject.h>
28#include <linux/sysfs.h> 28#include <linux/sysfs.h>
29#include <linux/sysctl.h>
29 30
30#include "ocfs2_fs.h" 31#include "ocfs2_fs.h"
31 32
@@ -33,11 +34,13 @@
33 34
34#define OCFS2_STACK_PLUGIN_O2CB "o2cb" 35#define OCFS2_STACK_PLUGIN_O2CB "o2cb"
35#define OCFS2_STACK_PLUGIN_USER "user" 36#define OCFS2_STACK_PLUGIN_USER "user"
37#define OCFS2_MAX_HB_CTL_PATH 256
36 38
37static struct ocfs2_locking_protocol *lproto; 39static struct ocfs2_locking_protocol *lproto;
38static DEFINE_SPINLOCK(ocfs2_stack_lock); 40static DEFINE_SPINLOCK(ocfs2_stack_lock);
39static LIST_HEAD(ocfs2_stack_list); 41static LIST_HEAD(ocfs2_stack_list);
40static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1]; 42static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1];
43static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl";
41 44
42/* 45/*
43 * The stack currently in use. If not null, active_stack->sp_count > 0, 46 * The stack currently in use. If not null, active_stack->sp_count > 0,
@@ -349,7 +352,7 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn,
349 352
350 BUG_ON(conn == NULL); 353 BUG_ON(conn == NULL);
351 354
352 ret = active_stack->sp_ops->disconnect(conn, hangup_pending); 355 ret = active_stack->sp_ops->disconnect(conn);
353 356
354 /* XXX Should we free it anyway? */ 357 /* XXX Should we free it anyway? */
355 if (!ret) { 358 if (!ret) {
@@ -362,13 +365,48 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn,
362} 365}
363EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect); 366EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect);
364 367
368/*
369 * Leave the group for this filesystem. This is executed by a userspace
370 * program (stored in ocfs2_hb_ctl_path).
371 */
372static void ocfs2_leave_group(const char *group)
373{
374 int ret;
375 char *argv[5], *envp[3];
376
377 argv[0] = ocfs2_hb_ctl_path;
378 argv[1] = "-K";
379 argv[2] = "-u";
380 argv[3] = (char *)group;
381 argv[4] = NULL;
382
383 /* minimal command environment taken from cpu_run_sbin_hotplug */
384 envp[0] = "HOME=/";
385 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
386 envp[2] = NULL;
387
388 ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
389 if (ret < 0) {
390 printk(KERN_ERR
391 "ocfs2: Error %d running user helper "
392 "\"%s %s %s %s\"\n",
393 ret, argv[0], argv[1], argv[2], argv[3]);
394 }
395}
396
397/*
398 * Hangup is a required post-umount. ocfs2-tools software expects the
399 * filesystem to call "ocfs2_hb_ctl" during unmount. This happens
400 * regardless of whether the DLM got started, so we can't do it
401 * in ocfs2_cluster_disconnect(). The ocfs2_leave_group() function does
402 * the actual work.
403 */
365void ocfs2_cluster_hangup(const char *group, int grouplen) 404void ocfs2_cluster_hangup(const char *group, int grouplen)
366{ 405{
367 BUG_ON(group == NULL); 406 BUG_ON(group == NULL);
368 BUG_ON(group[grouplen] != '\0'); 407 BUG_ON(group[grouplen] != '\0');
369 408
370 if (active_stack->sp_ops->hangup) 409 ocfs2_leave_group(group);
371 active_stack->sp_ops->hangup(group, grouplen);
372 410
373 /* cluster_disconnect() was called with hangup_pending==1 */ 411 /* cluster_disconnect() was called with hangup_pending==1 */
374 ocfs2_stack_driver_put(); 412 ocfs2_stack_driver_put();
@@ -548,10 +586,83 @@ error:
548 return ret; 586 return ret;
549} 587}
550 588
589/*
590 * Sysctl bits
591 *
592 * The sysctl lives at /proc/sys/fs/ocfs2/nm/hb_ctl_path. The 'nm' doesn't
593 * make as much sense in a multiple cluster stack world, but it's safer
594 * and easier to preserve the name.
595 */
596
597#define FS_OCFS2_NM 1
598
599static ctl_table ocfs2_nm_table[] = {
600 {
601 .ctl_name = 1,
602 .procname = "hb_ctl_path",
603 .data = ocfs2_hb_ctl_path,
604 .maxlen = OCFS2_MAX_HB_CTL_PATH,
605 .mode = 0644,
606 .proc_handler = &proc_dostring,
607 .strategy = &sysctl_string,
608 },
609 { .ctl_name = 0 }
610};
611
612static ctl_table ocfs2_mod_table[] = {
613 {
614 .ctl_name = FS_OCFS2_NM,
615 .procname = "nm",
616 .data = NULL,
617 .maxlen = 0,
618 .mode = 0555,
619 .child = ocfs2_nm_table
620 },
621 { .ctl_name = 0}
622};
623
624static ctl_table ocfs2_kern_table[] = {
625 {
626 .ctl_name = FS_OCFS2,
627 .procname = "ocfs2",
628 .data = NULL,
629 .maxlen = 0,
630 .mode = 0555,
631 .child = ocfs2_mod_table
632 },
633 { .ctl_name = 0}
634};
635
636static ctl_table ocfs2_root_table[] = {
637 {
638 .ctl_name = CTL_FS,
639 .procname = "fs",
640 .data = NULL,
641 .maxlen = 0,
642 .mode = 0555,
643 .child = ocfs2_kern_table
644 },
645 { .ctl_name = 0 }
646};
647
648static struct ctl_table_header *ocfs2_table_header = NULL;
649
650
651/*
652 * Initialization
653 */
654
551static int __init ocfs2_stack_glue_init(void) 655static int __init ocfs2_stack_glue_init(void)
552{ 656{
553 strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); 657 strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB);
554 658
659 ocfs2_table_header = register_sysctl_table(ocfs2_root_table);
660 if (!ocfs2_table_header) {
661 printk(KERN_ERR
662 "ocfs2 stack glue: unable to register sysctl\n");
663 return -ENOMEM; /* or something. */
664 }
665
555 return ocfs2_sysfs_init(); 666 return ocfs2_sysfs_init();
556} 667}
557 668
@@ -559,6 +670,8 @@ static void __exit ocfs2_stack_glue_exit(void)
559{ 670{
560 lproto = NULL; 671 lproto = NULL;
561 ocfs2_sysfs_exit(); 672 ocfs2_sysfs_exit();
673 if (ocfs2_table_header)
674 unregister_sysctl_table(ocfs2_table_header);
562} 675}
563 676
564MODULE_AUTHOR("Oracle"); 677MODULE_AUTHOR("Oracle");
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index 005e4f170e0f..db56281dd1be 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -134,22 +134,10 @@ struct ocfs2_stack_operations {
134 * be freed. Thus, a stack must not return from ->disconnect() 134 * be freed. Thus, a stack must not return from ->disconnect()
135 * until it will no longer reference the conn pointer. 135 * until it will no longer reference the conn pointer.
136 * 136 *
137 * If hangup_pending is zero, ocfs2_cluster_disconnect() will also 137 * Once this call returns, the stack glue will be dropping this
138 * be dropping the reference on the module. 138 * connection's reference on the module.
139 */ 139 */
140 int (*disconnect)(struct ocfs2_cluster_connection *conn, 140 int (*disconnect)(struct ocfs2_cluster_connection *conn);
141 int hangup_pending);
142
143 /*
144 * ocfs2_cluster_hangup() exists for compatibility with older
145 * ocfs2 tools. Only the classic stack really needs it. As such
146 * ->hangup() is not required of all stacks. See the comment by
147 * ocfs2_cluster_hangup() for more details.
148 *
149 * Note that ocfs2_cluster_hangup() can only be called if
150 * hangup_pending was passed to ocfs2_cluster_disconnect().
151 */
152 void (*hangup)(const char *group, int grouplen);
153 141
154 /* 142 /*
155 * ->this_node() returns the cluster's unique identifier for the 143 * ->this_node() returns the cluster's unique identifier for the
@@ -258,4 +246,5 @@ void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto)
258/* Used by stack plugins */ 246/* Used by stack plugins */
259int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); 247int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
260void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin); 248void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
249
261#endif /* STACKGLUE_H */ 250#endif /* STACKGLUE_H */