aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/stackglue.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2010-01-29 20:19:06 -0500
committerJoel Becker <joel.becker@oracle.com>2010-02-26 18:41:17 -0500
commit553b5eb91abd5f8e679d23ae547b92c589726814 (patch)
tree99b3e550a11b0d62d45bbc78d73d448acadd138a /fs/ocfs2/stackglue.c
parente603cfb074e150736814ef093a411df32c02ba9f (diff)
ocfs2: Pass the locking protocol into ocfs2_cluster_connect().
Inside the stackglue, the locking protocol structure is hanging off of the ocfs2_cluster_connection. This takes it one further; the locking protocol is passed into ocfs2_cluster_connect(). Now different cluster connections can have different locking protocols with distinct asts. Note that all locking protocols have to keep their maximum protocol version in lock-step. With the protocol structure set in ocfs2_cluster_connect(), there is no need for the stackglue to have a static pointer to a specific protocol structure. We can change initialization to only pass in the maximum protocol version. Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/stackglue.c')
-rw-r--r--fs/ocfs2/stackglue.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index fc184c762700..31db2e87cfd4 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -36,7 +36,7 @@
36#define OCFS2_STACK_PLUGIN_USER "user" 36#define OCFS2_STACK_PLUGIN_USER "user"
37#define OCFS2_MAX_HB_CTL_PATH 256 37#define OCFS2_MAX_HB_CTL_PATH 256
38 38
39static struct ocfs2_locking_protocol *lproto; 39static struct ocfs2_protocol_version locking_max_version;
40static DEFINE_SPINLOCK(ocfs2_stack_lock); 40static DEFINE_SPINLOCK(ocfs2_stack_lock);
41static LIST_HEAD(ocfs2_stack_list); 41static LIST_HEAD(ocfs2_stack_list);
42static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1]; 42static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1];
@@ -176,7 +176,7 @@ int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin)
176 spin_lock(&ocfs2_stack_lock); 176 spin_lock(&ocfs2_stack_lock);
177 if (!ocfs2_stack_lookup(plugin->sp_name)) { 177 if (!ocfs2_stack_lookup(plugin->sp_name)) {
178 plugin->sp_count = 0; 178 plugin->sp_count = 0;
179 plugin->sp_max_proto = lproto->lp_max_version; 179 plugin->sp_max_proto = locking_max_version;
180 list_add(&plugin->sp_list, &ocfs2_stack_list); 180 list_add(&plugin->sp_list, &ocfs2_stack_list);
181 printk(KERN_INFO "ocfs2: Registered cluster interface %s\n", 181 printk(KERN_INFO "ocfs2: Registered cluster interface %s\n",
182 plugin->sp_name); 182 plugin->sp_name);
@@ -213,23 +213,23 @@ void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin)
213} 213}
214EXPORT_SYMBOL_GPL(ocfs2_stack_glue_unregister); 214EXPORT_SYMBOL_GPL(ocfs2_stack_glue_unregister);
215 215
216void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto) 216void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_proto)
217{ 217{
218 struct ocfs2_stack_plugin *p; 218 struct ocfs2_stack_plugin *p;
219 219
220 BUG_ON(proto == NULL);
221
222 spin_lock(&ocfs2_stack_lock); 220 spin_lock(&ocfs2_stack_lock);
223 BUG_ON(active_stack != NULL); 221 if (memcmp(max_proto, &locking_max_version,
222 sizeof(struct ocfs2_protocol_version))) {
223 BUG_ON(locking_max_version.pv_major != 0);
224 224
225 lproto = proto; 225 locking_max_version = *max_proto;
226 list_for_each_entry(p, &ocfs2_stack_list, sp_list) { 226 list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
227 p->sp_max_proto = lproto->lp_max_version; 227 p->sp_max_proto = locking_max_version;
228 }
228 } 229 }
229
230 spin_unlock(&ocfs2_stack_lock); 230 spin_unlock(&ocfs2_stack_lock);
231} 231}
232EXPORT_SYMBOL_GPL(ocfs2_stack_glue_set_locking_protocol); 232EXPORT_SYMBOL_GPL(ocfs2_stack_glue_set_max_proto_version);
233 233
234 234
235/* 235/*
@@ -245,8 +245,6 @@ int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
245 void *name, 245 void *name,
246 unsigned int namelen) 246 unsigned int namelen)
247{ 247{
248 BUG_ON(lproto == NULL);
249
250 if (!lksb->lksb_conn) 248 if (!lksb->lksb_conn)
251 lksb->lksb_conn = conn; 249 lksb->lksb_conn = conn;
252 else 250 else
@@ -260,7 +258,6 @@ int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
260 struct ocfs2_dlm_lksb *lksb, 258 struct ocfs2_dlm_lksb *lksb,
261 u32 flags) 259 u32 flags)
262{ 260{
263 BUG_ON(lproto == NULL);
264 BUG_ON(lksb->lksb_conn == NULL); 261 BUG_ON(lksb->lksb_conn == NULL);
265 262
266 return active_stack->sp_ops->dlm_unlock(conn, lksb, flags); 263 return active_stack->sp_ops->dlm_unlock(conn, lksb, flags);
@@ -314,6 +311,7 @@ EXPORT_SYMBOL_GPL(ocfs2_plock);
314int ocfs2_cluster_connect(const char *stack_name, 311int ocfs2_cluster_connect(const char *stack_name,
315 const char *group, 312 const char *group,
316 int grouplen, 313 int grouplen,
314 struct ocfs2_locking_protocol *lproto,
317 void (*recovery_handler)(int node_num, 315 void (*recovery_handler)(int node_num,
318 void *recovery_data), 316 void *recovery_data),
319 void *recovery_data, 317 void *recovery_data,
@@ -331,6 +329,12 @@ int ocfs2_cluster_connect(const char *stack_name,
331 goto out; 329 goto out;
332 } 330 }
333 331
332 if (memcmp(&lproto->lp_max_version, &locking_max_version,
333 sizeof(struct ocfs2_protocol_version))) {
334 rc = -EINVAL;
335 goto out;
336 }
337
334 new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection), 338 new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection),
335 GFP_KERNEL); 339 GFP_KERNEL);
336 if (!new_conn) { 340 if (!new_conn) {
@@ -456,10 +460,10 @@ static ssize_t ocfs2_max_locking_protocol_show(struct kobject *kobj,
456 ssize_t ret = 0; 460 ssize_t ret = 0;
457 461
458 spin_lock(&ocfs2_stack_lock); 462 spin_lock(&ocfs2_stack_lock);
459 if (lproto) 463 if (locking_max_version.pv_major)
460 ret = snprintf(buf, PAGE_SIZE, "%u.%u\n", 464 ret = snprintf(buf, PAGE_SIZE, "%u.%u\n",
461 lproto->lp_max_version.pv_major, 465 locking_max_version.pv_major,
462 lproto->lp_max_version.pv_minor); 466 locking_max_version.pv_minor);
463 spin_unlock(&ocfs2_stack_lock); 467 spin_unlock(&ocfs2_stack_lock);
464 468
465 return ret; 469 return ret;
@@ -688,7 +692,10 @@ static int __init ocfs2_stack_glue_init(void)
688 692
689static void __exit ocfs2_stack_glue_exit(void) 693static void __exit ocfs2_stack_glue_exit(void)
690{ 694{
691 lproto = NULL; 695 memset(&locking_max_version, 0,
696 sizeof(struct ocfs2_protocol_version));
697 locking_max_version.pv_major = 0;
698 locking_max_version.pv_minor = 0;
692 ocfs2_sysfs_exit(); 699 ocfs2_sysfs_exit();
693 if (ocfs2_table_header) 700 if (ocfs2_table_header)
694 unregister_sysctl_table(ocfs2_table_header); 701 unregister_sysctl_table(ocfs2_table_header);