1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
6 * Code which interfaces ocfs2 with fs/dlm and a userspace stack.
8 * Copyright (C) 2007 Oracle. All rights reserved.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
20 #include <linux/module.h>
22 #include <linux/miscdevice.h>
23 #include <linux/mutex.h>
24 #include <linux/reboot.h>
25 #include <asm/uaccess.h>
27 #include "ocfs2.h" /* For struct ocfs2_lock_res */
28 #include "stackglue.h"
32 * The control protocol starts with a handshake. Until the handshake
33 * is complete, the control device will fail all write(2)s.
35 * The handshake is simple. First, the client reads until EOF. Each line
36 * of output is a supported protocol tag. All protocol tags are a single
37 * character followed by a two hex digit version number. Currently the
38 * only things supported is T01, for "Text-base version 0x01". Next, the
39 * client writes the version they would like to use, including the newline.
40 * Thus, the protocol tag is 'T01\n'. If the version tag written is
41 * unknown, -EINVAL is returned. Once the negotiation is complete, the
42 * client can start sending messages.
44 * The T01 protocol has three messages. First is the "SETN" message.
45 * It has the following syntax:
47 * SETN<space><8-char-hex-nodenum><newline>
49 * This is 14 characters.
51 * The "SETN" message must be the first message following the protocol.
52 * It tells ocfs2_control the local node number.
54 * Next comes the "SETV" message. It has the following syntax:
56 * SETV<space><2-char-hex-major><space><2-char-hex-minor><newline>
58 * This is 11 characters.
60 * The "SETV" message sets the filesystem locking protocol version as
61 * negotiated by the client. The client negotiates based on the maximum
62 * version advertised in /sys/fs/ocfs2/max_locking_protocol. The major
63 * number from the "SETV" message must match
64 * ocfs2_user_plugin.sp_proto->lp_max_version.pv_major, and the minor number
65 * must be less than or equal to ...->lp_max_version.pv_minor.
67 * Once this information has been set, mounts will be allowed. From this
68 * point on, the "DOWN" message can be sent for node down notification.
69 * It has the following syntax:
71 * DOWN<space><32-char-cap-hex-uuid><space><8-char-hex-nodenum><newline>
75 * DOWN 632A924FDD844190BDA93C0DF6B94899 00000001\n
77 * This is 47 characters.
81 * Whether or not the client has done the handshake.
82 * For now, we have just one protocol version.
84 #define OCFS2_CONTROL_PROTO "T01\n"
85 #define OCFS2_CONTROL_PROTO_LEN 4
87 /* Handshake states */
88 #define OCFS2_CONTROL_HANDSHAKE_INVALID (0)
89 #define OCFS2_CONTROL_HANDSHAKE_READ (1)
90 #define OCFS2_CONTROL_HANDSHAKE_PROTOCOL (2)
91 #define OCFS2_CONTROL_HANDSHAKE_VALID (3)
94 #define OCFS2_CONTROL_MESSAGE_OP_LEN 4
95 #define OCFS2_CONTROL_MESSAGE_SETNODE_OP "SETN"
96 #define OCFS2_CONTROL_MESSAGE_SETNODE_TOTAL_LEN 14
97 #define OCFS2_CONTROL_MESSAGE_SETVERSION_OP "SETV"
98 #define OCFS2_CONTROL_MESSAGE_SETVERSION_TOTAL_LEN 11
99 #define OCFS2_CONTROL_MESSAGE_DOWN_OP "DOWN"
100 #define OCFS2_CONTROL_MESSAGE_DOWN_TOTAL_LEN 47
101 #define OCFS2_TEXT_UUID_LEN 32
102 #define OCFS2_CONTROL_MESSAGE_VERNUM_LEN 2
103 #define OCFS2_CONTROL_MESSAGE_NODENUM_LEN 8
106 * ocfs2_live_connection is refcounted because the filesystem and
107 * miscdevice sides can detach in different order. Let's just be safe.
109 struct ocfs2_live_connection
{
110 struct list_head oc_list
;
111 struct ocfs2_cluster_connection
*oc_conn
;
114 struct ocfs2_control_private
{
115 struct list_head op_list
;
118 struct ocfs2_protocol_version op_proto
;
121 /* SETN<space><8-char-hex-nodenum><newline> */
122 struct ocfs2_control_message_setn
{
123 char tag
[OCFS2_CONTROL_MESSAGE_OP_LEN
];
125 char nodestr
[OCFS2_CONTROL_MESSAGE_NODENUM_LEN
];
129 /* SETV<space><2-char-hex-major><space><2-char-hex-minor><newline> */
130 struct ocfs2_control_message_setv
{
131 char tag
[OCFS2_CONTROL_MESSAGE_OP_LEN
];
133 char major
[OCFS2_CONTROL_MESSAGE_VERNUM_LEN
];
135 char minor
[OCFS2_CONTROL_MESSAGE_VERNUM_LEN
];
139 /* DOWN<space><32-char-cap-hex-uuid><space><8-char-hex-nodenum><newline> */
140 struct ocfs2_control_message_down
{
141 char tag
[OCFS2_CONTROL_MESSAGE_OP_LEN
];
143 char uuid
[OCFS2_TEXT_UUID_LEN
];
145 char nodestr
[OCFS2_CONTROL_MESSAGE_NODENUM_LEN
];
149 union ocfs2_control_message
{
150 char tag
[OCFS2_CONTROL_MESSAGE_OP_LEN
];
151 struct ocfs2_control_message_setn u_setn
;
152 struct ocfs2_control_message_setv u_setv
;
153 struct ocfs2_control_message_down u_down
;
156 static struct ocfs2_stack_plugin ocfs2_user_plugin
;
158 static atomic_t ocfs2_control_opened
;
159 static int ocfs2_control_this_node
= -1;
160 static struct ocfs2_protocol_version running_proto
;
162 static LIST_HEAD(ocfs2_live_connection_list
);
163 static LIST_HEAD(ocfs2_control_private_list
);
164 static DEFINE_MUTEX(ocfs2_control_lock
);
166 static inline void ocfs2_control_set_handshake_state(struct file
*file
,
169 struct ocfs2_control_private
*p
= file
->private_data
;
173 static inline int ocfs2_control_get_handshake_state(struct file
*file
)
175 struct ocfs2_control_private
*p
= file
->private_data
;
179 static struct ocfs2_live_connection
*ocfs2_connection_find(const char *name
)
181 size_t len
= strlen(name
);
182 struct ocfs2_live_connection
*c
;
184 BUG_ON(!mutex_is_locked(&ocfs2_control_lock
));
186 list_for_each_entry(c
, &ocfs2_live_connection_list
, oc_list
) {
187 if ((c
->oc_conn
->cc_namelen
== len
) &&
188 !strncmp(c
->oc_conn
->cc_name
, name
, len
))
196 * ocfs2_live_connection structures are created underneath the ocfs2
197 * mount path. Since the VFS prevents multiple calls to
198 * fill_super(), we can't get dupes here.
200 static int ocfs2_live_connection_new(struct ocfs2_cluster_connection
*conn
,
201 struct ocfs2_live_connection
**c_ret
)
204 struct ocfs2_live_connection
*c
;
206 c
= kzalloc(sizeof(struct ocfs2_live_connection
), GFP_KERNEL
);
210 mutex_lock(&ocfs2_control_lock
);
213 if (atomic_read(&ocfs2_control_opened
))
214 list_add(&c
->oc_list
, &ocfs2_live_connection_list
);
217 "ocfs2: Userspace control daemon is not present\n");
221 mutex_unlock(&ocfs2_control_lock
);
232 * This function disconnects the cluster connection from ocfs2_control.
233 * Afterwards, userspace can't affect the cluster connection.
235 static void ocfs2_live_connection_drop(struct ocfs2_live_connection
*c
)
237 mutex_lock(&ocfs2_control_lock
);
238 list_del_init(&c
->oc_list
);
240 mutex_unlock(&ocfs2_control_lock
);
245 static int ocfs2_control_cfu(void *target
, size_t target_len
,
246 const char __user
*buf
, size_t count
)
248 /* The T01 expects write(2) calls to have exactly one command */
249 if ((count
!= target_len
) ||
250 (count
> sizeof(union ocfs2_control_message
)))
253 if (copy_from_user(target
, buf
, target_len
))
259 static ssize_t
ocfs2_control_validate_protocol(struct file
*file
,
260 const char __user
*buf
,
264 char kbuf
[OCFS2_CONTROL_PROTO_LEN
];
266 ret
= ocfs2_control_cfu(kbuf
, OCFS2_CONTROL_PROTO_LEN
,
271 if (strncmp(kbuf
, OCFS2_CONTROL_PROTO
, OCFS2_CONTROL_PROTO_LEN
))
274 ocfs2_control_set_handshake_state(file
,
275 OCFS2_CONTROL_HANDSHAKE_PROTOCOL
);
280 static void ocfs2_control_send_down(const char *uuid
,
283 struct ocfs2_live_connection
*c
;
285 mutex_lock(&ocfs2_control_lock
);
287 c
= ocfs2_connection_find(uuid
);
289 BUG_ON(c
->oc_conn
== NULL
);
290 c
->oc_conn
->cc_recovery_handler(nodenum
,
291 c
->oc_conn
->cc_recovery_data
);
294 mutex_unlock(&ocfs2_control_lock
);
298 * Called whenever configuration elements are sent to /dev/ocfs2_control.
299 * If all configuration elements are present, try to set the global
300 * values. If there is a problem, return an error. Skip any missing
301 * elements, and only bump ocfs2_control_opened when we have all elements
302 * and are successful.
304 static int ocfs2_control_install_private(struct file
*file
)
308 struct ocfs2_control_private
*p
= file
->private_data
;
310 BUG_ON(p
->op_state
!= OCFS2_CONTROL_HANDSHAKE_PROTOCOL
);
312 mutex_lock(&ocfs2_control_lock
);
314 if (p
->op_this_node
< 0) {
316 } else if ((ocfs2_control_this_node
>= 0) &&
317 (ocfs2_control_this_node
!= p
->op_this_node
)) {
322 if (!p
->op_proto
.pv_major
) {
324 } else if (!list_empty(&ocfs2_live_connection_list
) &&
325 ((running_proto
.pv_major
!= p
->op_proto
.pv_major
) ||
326 (running_proto
.pv_minor
!= p
->op_proto
.pv_minor
))) {
332 ocfs2_control_this_node
= p
->op_this_node
;
333 running_proto
.pv_major
= p
->op_proto
.pv_major
;
334 running_proto
.pv_minor
= p
->op_proto
.pv_minor
;
338 mutex_unlock(&ocfs2_control_lock
);
341 /* We set the global values successfully */
342 atomic_inc(&ocfs2_control_opened
);
343 ocfs2_control_set_handshake_state(file
,
344 OCFS2_CONTROL_HANDSHAKE_VALID
);
350 static int ocfs2_control_get_this_node(void)
354 mutex_lock(&ocfs2_control_lock
);
355 if (ocfs2_control_this_node
< 0)
358 rc
= ocfs2_control_this_node
;
359 mutex_unlock(&ocfs2_control_lock
);
364 static int ocfs2_control_do_setnode_msg(struct file
*file
,
365 struct ocfs2_control_message_setn
*msg
)
369 struct ocfs2_control_private
*p
= file
->private_data
;
371 if (ocfs2_control_get_handshake_state(file
) !=
372 OCFS2_CONTROL_HANDSHAKE_PROTOCOL
)
375 if (strncmp(msg
->tag
, OCFS2_CONTROL_MESSAGE_SETNODE_OP
,
376 OCFS2_CONTROL_MESSAGE_OP_LEN
))
379 if ((msg
->space
!= ' ') || (msg
->newline
!= '\n'))
381 msg
->space
= msg
->newline
= '\0';
383 nodenum
= simple_strtol(msg
->nodestr
, &ptr
, 16);
387 if ((nodenum
== LONG_MIN
) || (nodenum
== LONG_MAX
) ||
388 (nodenum
> INT_MAX
) || (nodenum
< 0))
390 p
->op_this_node
= nodenum
;
392 return ocfs2_control_install_private(file
);
395 static int ocfs2_control_do_setversion_msg(struct file
*file
,
396 struct ocfs2_control_message_setv
*msg
)
400 struct ocfs2_control_private
*p
= file
->private_data
;
401 struct ocfs2_protocol_version
*max
=
402 &ocfs2_user_plugin
.sp_proto
->lp_max_version
;
404 if (ocfs2_control_get_handshake_state(file
) !=
405 OCFS2_CONTROL_HANDSHAKE_PROTOCOL
)
408 if (strncmp(msg
->tag
, OCFS2_CONTROL_MESSAGE_SETVERSION_OP
,
409 OCFS2_CONTROL_MESSAGE_OP_LEN
))
412 if ((msg
->space1
!= ' ') || (msg
->space2
!= ' ') ||
413 (msg
->newline
!= '\n'))
415 msg
->space1
= msg
->space2
= msg
->newline
= '\0';
417 major
= simple_strtol(msg
->major
, &ptr
, 16);
420 minor
= simple_strtol(msg
->minor
, &ptr
, 16);
425 * The major must be between 1 and 255, inclusive. The minor
426 * must be between 0 and 255, inclusive. The version passed in
427 * must be within the maximum version supported by the filesystem.
429 if ((major
== LONG_MIN
) || (major
== LONG_MAX
) ||
430 (major
> (u8
)-1) || (major
< 1))
432 if ((minor
== LONG_MIN
) || (minor
== LONG_MAX
) ||
433 (minor
> (u8
)-1) || (minor
< 0))
435 if ((major
!= max
->pv_major
) ||
436 (minor
> max
->pv_minor
))
439 p
->op_proto
.pv_major
= major
;
440 p
->op_proto
.pv_minor
= minor
;
442 return ocfs2_control_install_private(file
);
445 static int ocfs2_control_do_down_msg(struct file
*file
,
446 struct ocfs2_control_message_down
*msg
)
451 if (ocfs2_control_get_handshake_state(file
) !=
452 OCFS2_CONTROL_HANDSHAKE_VALID
)
455 if (strncmp(msg
->tag
, OCFS2_CONTROL_MESSAGE_DOWN_OP
,
456 OCFS2_CONTROL_MESSAGE_OP_LEN
))
459 if ((msg
->space1
!= ' ') || (msg
->space2
!= ' ') ||
460 (msg
->newline
!= '\n'))
462 msg
->space1
= msg
->space2
= msg
->newline
= '\0';
464 nodenum
= simple_strtol(msg
->nodestr
, &p
, 16);
468 if ((nodenum
== LONG_MIN
) || (nodenum
== LONG_MAX
) ||
469 (nodenum
> INT_MAX
) || (nodenum
< 0))
472 ocfs2_control_send_down(msg
->uuid
, nodenum
);
477 static ssize_t
ocfs2_control_message(struct file
*file
,
478 const char __user
*buf
,
482 union ocfs2_control_message msg
;
484 /* Try to catch padding issues */
485 WARN_ON(offsetof(struct ocfs2_control_message_down
, uuid
) !=
486 (sizeof(msg
.u_down
.tag
) + sizeof(msg
.u_down
.space1
)));
488 memset(&msg
, 0, sizeof(union ocfs2_control_message
));
489 ret
= ocfs2_control_cfu(&msg
, count
, buf
, count
);
493 if ((count
== OCFS2_CONTROL_MESSAGE_SETNODE_TOTAL_LEN
) &&
494 !strncmp(msg
.tag
, OCFS2_CONTROL_MESSAGE_SETNODE_OP
,
495 OCFS2_CONTROL_MESSAGE_OP_LEN
))
496 ret
= ocfs2_control_do_setnode_msg(file
, &msg
.u_setn
);
497 else if ((count
== OCFS2_CONTROL_MESSAGE_SETVERSION_TOTAL_LEN
) &&
498 !strncmp(msg
.tag
, OCFS2_CONTROL_MESSAGE_SETVERSION_OP
,
499 OCFS2_CONTROL_MESSAGE_OP_LEN
))
500 ret
= ocfs2_control_do_setversion_msg(file
, &msg
.u_setv
);
501 else if ((count
== OCFS2_CONTROL_MESSAGE_DOWN_TOTAL_LEN
) &&
502 !strncmp(msg
.tag
, OCFS2_CONTROL_MESSAGE_DOWN_OP
,
503 OCFS2_CONTROL_MESSAGE_OP_LEN
))
504 ret
= ocfs2_control_do_down_msg(file
, &msg
.u_down
);
509 return ret
? ret
: count
;
512 static ssize_t
ocfs2_control_write(struct file
*file
,
513 const char __user
*buf
,
519 switch (ocfs2_control_get_handshake_state(file
)) {
520 case OCFS2_CONTROL_HANDSHAKE_INVALID
:
524 case OCFS2_CONTROL_HANDSHAKE_READ
:
525 ret
= ocfs2_control_validate_protocol(file
, buf
,
529 case OCFS2_CONTROL_HANDSHAKE_PROTOCOL
:
530 case OCFS2_CONTROL_HANDSHAKE_VALID
:
531 ret
= ocfs2_control_message(file
, buf
, count
);
544 * This is a naive version. If we ever have a new protocol, we'll expand
545 * it. Probably using seq_file.
547 static ssize_t
ocfs2_control_read(struct file
*file
,
552 char *proto_string
= OCFS2_CONTROL_PROTO
;
555 if (*ppos
>= OCFS2_CONTROL_PROTO_LEN
)
558 to_write
= OCFS2_CONTROL_PROTO_LEN
- *ppos
;
559 if (to_write
> count
)
561 if (copy_to_user(buf
, proto_string
+ *ppos
, to_write
))
566 /* Have we read the whole protocol list? */
567 if (*ppos
>= OCFS2_CONTROL_PROTO_LEN
)
568 ocfs2_control_set_handshake_state(file
,
569 OCFS2_CONTROL_HANDSHAKE_READ
);
574 static int ocfs2_control_release(struct inode
*inode
, struct file
*file
)
576 struct ocfs2_control_private
*p
= file
->private_data
;
578 mutex_lock(&ocfs2_control_lock
);
580 if (ocfs2_control_get_handshake_state(file
) !=
581 OCFS2_CONTROL_HANDSHAKE_VALID
)
584 if (atomic_dec_and_test(&ocfs2_control_opened
)) {
585 if (!list_empty(&ocfs2_live_connection_list
)) {
586 /* XXX: Do bad things! */
588 "ocfs2: Unexpected release of ocfs2_control!\n"
589 " Loss of cluster connection requires "
590 "an emergency restart!\n");
594 * Last valid close clears the node number and resets
595 * the locking protocol version
597 ocfs2_control_this_node
= -1;
598 running_proto
.pv_major
= 0;
599 running_proto
.pv_major
= 0;
603 list_del_init(&p
->op_list
);
604 file
->private_data
= NULL
;
606 mutex_unlock(&ocfs2_control_lock
);
613 static int ocfs2_control_open(struct inode
*inode
, struct file
*file
)
615 struct ocfs2_control_private
*p
;
617 p
= kzalloc(sizeof(struct ocfs2_control_private
), GFP_KERNEL
);
620 p
->op_this_node
= -1;
622 mutex_lock(&ocfs2_control_lock
);
623 file
->private_data
= p
;
624 list_add(&p
->op_list
, &ocfs2_control_private_list
);
625 mutex_unlock(&ocfs2_control_lock
);
630 static const struct file_operations ocfs2_control_fops
= {
631 .open
= ocfs2_control_open
,
632 .release
= ocfs2_control_release
,
633 .read
= ocfs2_control_read
,
634 .write
= ocfs2_control_write
,
635 .owner
= THIS_MODULE
,
638 static struct miscdevice ocfs2_control_device
= {
639 .minor
= MISC_DYNAMIC_MINOR
,
640 .name
= "ocfs2_control",
641 .fops
= &ocfs2_control_fops
,
644 static int ocfs2_control_init(void)
648 atomic_set(&ocfs2_control_opened
, 0);
650 rc
= misc_register(&ocfs2_control_device
);
653 "ocfs2: Unable to register ocfs2_control device "
660 static void ocfs2_control_exit(void)
664 rc
= misc_deregister(&ocfs2_control_device
);
667 "ocfs2: Unable to deregister ocfs2_control device "
672 static struct dlm_lksb
*fsdlm_astarg_to_lksb(void *astarg
)
674 struct ocfs2_lock_res
*res
= astarg
;
675 return &res
->l_lksb
.lksb_fsdlm
;
678 static void fsdlm_lock_ast_wrapper(void *astarg
)
680 struct dlm_lksb
*lksb
= fsdlm_astarg_to_lksb(astarg
);
681 int status
= lksb
->sb_status
;
683 BUG_ON(ocfs2_user_plugin
.sp_proto
== NULL
);
686 * For now we're punting on the issue of other non-standard errors
687 * where we can't tell if the unlock_ast or lock_ast should be called.
688 * The main "other error" that's possible is EINVAL which means the
689 * function was called with invalid args, which shouldn't be possible
690 * since the caller here is under our control. Other non-standard
691 * errors probably fall into the same category, or otherwise are fatal
692 * which means we can't carry on anyway.
695 if (status
== -DLM_EUNLOCK
|| status
== -DLM_ECANCEL
)
696 ocfs2_user_plugin
.sp_proto
->lp_unlock_ast(astarg
, 0);
698 ocfs2_user_plugin
.sp_proto
->lp_lock_ast(astarg
);
701 static void fsdlm_blocking_ast_wrapper(void *astarg
, int level
)
703 BUG_ON(ocfs2_user_plugin
.sp_proto
== NULL
);
705 ocfs2_user_plugin
.sp_proto
->lp_blocking_ast(astarg
, level
);
708 static int user_dlm_lock(struct ocfs2_cluster_connection
*conn
,
710 union ocfs2_dlm_lksb
*lksb
,
713 unsigned int namelen
,
718 if (!lksb
->lksb_fsdlm
.sb_lvbptr
)
719 lksb
->lksb_fsdlm
.sb_lvbptr
= (char *)lksb
+
720 sizeof(struct dlm_lksb
);
722 ret
= dlm_lock(conn
->cc_lockspace
, mode
, &lksb
->lksb_fsdlm
,
723 flags
|DLM_LKF_NODLCKWT
, name
, namelen
, 0,
724 fsdlm_lock_ast_wrapper
, astarg
,
725 fsdlm_blocking_ast_wrapper
);
729 static int user_dlm_unlock(struct ocfs2_cluster_connection
*conn
,
730 union ocfs2_dlm_lksb
*lksb
,
736 ret
= dlm_unlock(conn
->cc_lockspace
, lksb
->lksb_fsdlm
.sb_lkid
,
737 flags
, &lksb
->lksb_fsdlm
, astarg
);
741 static int user_dlm_lock_status(union ocfs2_dlm_lksb
*lksb
)
743 return lksb
->lksb_fsdlm
.sb_status
;
746 static void *user_dlm_lvb(union ocfs2_dlm_lksb
*lksb
)
748 return (void *)(lksb
->lksb_fsdlm
.sb_lvbptr
);
751 static void user_dlm_dump_lksb(union ocfs2_dlm_lksb
*lksb
)
756 * Compare a requested locking protocol version against the current one.
758 * If the major numbers are different, they are incompatible.
759 * If the current minor is greater than the request, they are incompatible.
760 * If the current minor is less than or equal to the request, they are
761 * compatible, and the requester should run at the current minor version.
763 static int fs_protocol_compare(struct ocfs2_protocol_version
*existing
,
764 struct ocfs2_protocol_version
*request
)
766 if (existing
->pv_major
!= request
->pv_major
)
769 if (existing
->pv_minor
> request
->pv_minor
)
772 if (existing
->pv_minor
< request
->pv_minor
)
773 request
->pv_minor
= existing
->pv_minor
;
778 static int user_cluster_connect(struct ocfs2_cluster_connection
*conn
)
780 dlm_lockspace_t
*fsdlm
;
781 struct ocfs2_live_connection
*control
;
784 BUG_ON(conn
== NULL
);
786 rc
= ocfs2_live_connection_new(conn
, &control
);
791 * running_proto must have been set before we allowed any mounts
794 if (fs_protocol_compare(&running_proto
, &conn
->cc_version
)) {
796 "Unable to mount with fs locking protocol version "
797 "%u.%u because the userspace control daemon has "
798 "negotiated %u.%u\n",
799 conn
->cc_version
.pv_major
, conn
->cc_version
.pv_minor
,
800 running_proto
.pv_major
, running_proto
.pv_minor
);
802 ocfs2_live_connection_drop(control
);
806 rc
= dlm_new_lockspace(conn
->cc_name
, strlen(conn
->cc_name
),
807 &fsdlm
, DLM_LSFL_FS
, DLM_LVB_LEN
);
809 ocfs2_live_connection_drop(control
);
813 conn
->cc_private
= control
;
814 conn
->cc_lockspace
= fsdlm
;
819 static int user_cluster_disconnect(struct ocfs2_cluster_connection
*conn
)
821 dlm_release_lockspace(conn
->cc_lockspace
, 2);
822 conn
->cc_lockspace
= NULL
;
823 ocfs2_live_connection_drop(conn
->cc_private
);
824 conn
->cc_private
= NULL
;
828 static int user_cluster_this_node(unsigned int *this_node
)
832 rc
= ocfs2_control_get_this_node();
840 static struct ocfs2_stack_operations ocfs2_user_plugin_ops
= {
841 .connect
= user_cluster_connect
,
842 .disconnect
= user_cluster_disconnect
,
843 .this_node
= user_cluster_this_node
,
844 .dlm_lock
= user_dlm_lock
,
845 .dlm_unlock
= user_dlm_unlock
,
846 .lock_status
= user_dlm_lock_status
,
847 .lock_lvb
= user_dlm_lvb
,
848 .dump_lksb
= user_dlm_dump_lksb
,
851 static struct ocfs2_stack_plugin ocfs2_user_plugin
= {
853 .sp_ops
= &ocfs2_user_plugin_ops
,
854 .sp_owner
= THIS_MODULE
,
858 static int __init
ocfs2_user_plugin_init(void)
862 rc
= ocfs2_control_init();
864 rc
= ocfs2_stack_glue_register(&ocfs2_user_plugin
);
866 ocfs2_control_exit();
872 static void __exit
ocfs2_user_plugin_exit(void)
874 ocfs2_stack_glue_unregister(&ocfs2_user_plugin
);
875 ocfs2_control_exit();
878 MODULE_AUTHOR("Oracle");
879 MODULE_DESCRIPTION("ocfs2 driver for userspace cluster stacks");
880 MODULE_LICENSE("GPL");
881 module_init(ocfs2_user_plugin_init
);
882 module_exit(ocfs2_user_plugin_exit
);