aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/stackglue.h
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-02-01 18:02:36 -0500
committerMark Fasheh <mfasheh@suse.com>2008-04-18 11:56:05 -0400
commite3dad42bf993a0f24eb6e46152356c9b119c15e8 (patch)
treedf0419dc5e4387db7e6a6e0118bb5b9d01d8c0b2 /fs/ocfs2/stackglue.h
parent553aa7e408eac402c00b67ddfa7aec13fe1f3a33 (diff)
ocfs2: Create ocfs2_stack_operations and split out the o2cb stack.
Define the ocfs2_stack_operations structure. Build o2cb_stack_ops from all of the o2cb-specific stack functions. Change the generic stack glue functions to call the stack_ops instead of the o2cb functions directly. The o2cb functions are moved to stack_o2cb.c. The headers are cleaned up to where only needed headers are included. In this code, stackglue.c and stack_o2cb.c refer to some shared extern variables. When they become modules, that will change. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/stackglue.h')
-rw-r--r--fs/ocfs2/stackglue.h123
1 files changed, 121 insertions, 2 deletions
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index decb147106fd..083632215dc5 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -25,6 +25,8 @@
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/dlmconstants.h> 26#include <linux/dlmconstants.h>
27 27
28#include "dlm/dlmapi.h"
29
28/* 30/*
29 * dlmconstants.h does not have a LOCAL flag. We hope to remove it 31 * dlmconstants.h does not have a LOCAL flag. We hope to remove it
30 * some day, but right now we need it. Let's fake it. This value is larger 32 * some day, but right now we need it. Let's fake it. This value is larger
@@ -39,13 +41,18 @@
39#define GROUP_NAME_MAX 64 41#define GROUP_NAME_MAX 64
40 42
41 43
42#include "dlm/dlmapi.h" 44/*
43 45 * ocfs2_protocol_version changes when ocfs2 does something different in
46 * its inter-node behavior. See dlmglue.c for more information.
47 */
44struct ocfs2_protocol_version { 48struct ocfs2_protocol_version {
45 u8 pv_major; 49 u8 pv_major;
46 u8 pv_minor; 50 u8 pv_minor;
47}; 51};
48 52
53/*
54 * The ocfs2_locking_protocol defines the handlers called on ocfs2's behalf.
55 */
49struct ocfs2_locking_protocol { 56struct ocfs2_locking_protocol {
50 struct ocfs2_protocol_version lp_max_version; 57 struct ocfs2_protocol_version lp_max_version;
51 void (*lp_lock_ast)(void *astarg); 58 void (*lp_lock_ast)(void *astarg);
@@ -53,10 +60,20 @@ struct ocfs2_locking_protocol {
53 void (*lp_unlock_ast)(void *astarg, int error); 60 void (*lp_unlock_ast)(void *astarg, int error);
54}; 61};
55 62
63/*
64 * A union of all lock status structures. We define it here so that the
65 * size of the union is known. Lock status structures are embedded in
66 * ocfs2 inodes.
67 */
56union ocfs2_dlm_lksb { 68union ocfs2_dlm_lksb {
57 struct dlm_lockstatus lksb_o2dlm; 69 struct dlm_lockstatus lksb_o2dlm;
58}; 70};
59 71
72/*
73 * A cluster connection. Mostly opaque to ocfs2, the connection holds
74 * state for the underlying stack. ocfs2 does use cc_version to determine
75 * locking compatibility.
76 */
60struct ocfs2_cluster_connection { 77struct ocfs2_cluster_connection {
61 char cc_name[GROUP_NAME_MAX]; 78 char cc_name[GROUP_NAME_MAX];
62 int cc_namelen; 79 int cc_namelen;
@@ -67,6 +84,106 @@ struct ocfs2_cluster_connection {
67 void *cc_private; 84 void *cc_private;
68}; 85};
69 86
87/*
88 * Each cluster stack implements the stack operations structure. Not used
89 * in the ocfs2 code, the stackglue code translates generic cluster calls
90 * into stack operations.
91 */
92struct ocfs2_stack_operations {
93 /*
94 * The fs code calls ocfs2_cluster_connect() to attach a new
95 * filesystem to the cluster stack. The ->connect() op is passed
96 * an ocfs2_cluster_connection with the name and recovery field
97 * filled in.
98 *
99 * The stack must set up any notification mechanisms and create
100 * the filesystem lockspace in the DLM. The lockspace should be
101 * stored on cc_lockspace. Any other information can be stored on
102 * cc_private.
103 *
104 * ->connect() must not return until it is guaranteed that
105 *
106 * - Node down notifications for the filesystem will be recieved
107 * and passed to conn->cc_recovery_handler().
108 * - Locking requests for the filesystem will be processed.
109 */
110 int (*connect)(struct ocfs2_cluster_connection *conn);
111
112 /*
113 * The fs code calls ocfs2_cluster_disconnect() when a filesystem
114 * no longer needs cluster services. All DLM locks have been
115 * dropped, and recovery notification is being ignored by the
116 * fs code. The stack must disengage from the DLM and discontinue
117 * recovery notification.
118 *
119 * Once ->disconnect() has returned, the connection structure will
120 * be freed. Thus, a stack must not return from ->disconnect()
121 * until it will no longer reference the conn pointer.
122 */
123 int (*disconnect)(struct ocfs2_cluster_connection *conn);
124
125 /*
126 * ocfs2_cluster_hangup() exists for compatibility with older
127 * ocfs2 tools. Only the classic stack really needs it. As such
128 * ->hangup() is not required of all stacks. See the comment by
129 * ocfs2_cluster_hangup() for more details.
130 */
131 void (*hangup)(const char *group, int grouplen);
132
133 /*
134 * ->this_node() returns the cluster's unique identifier for the
135 * local node.
136 */
137 int (*this_node)(unsigned int *node);
138
139 /*
140 * Call the underlying dlm lock function. The ->dlm_lock()
141 * callback should convert the flags and mode as appropriate.
142 *
143 * ast and bast functions are not part of the call because the
144 * stack will likely want to wrap ast and bast calls before passing
145 * them to stack->sp_proto.
146 */
147 int (*dlm_lock)(struct ocfs2_cluster_connection *conn,
148 int mode,
149 union ocfs2_dlm_lksb *lksb,
150 u32 flags,
151 void *name,
152 unsigned int namelen,
153 void *astarg);
154
155 /*
156 * Call the underlying dlm unlock function. The ->dlm_unlock()
157 * function should convert the flags as appropriate.
158 *
159 * The unlock ast is not passed, as the stack will want to wrap
160 * it before calling stack->sp_proto->lp_unlock_ast().
161 */
162 int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,
163 union ocfs2_dlm_lksb *lksb,
164 u32 flags,
165 void *astarg);
166
167 /*
168 * Return the status of the current lock status block. The fs
169 * code should never dereference the union. The ->lock_status()
170 * callback pulls out the stack-specific lksb, converts the status
171 * to a proper errno, and returns it.
172 */
173 int (*lock_status)(union ocfs2_dlm_lksb *lksb);
174
175 /*
176 * Pull the lvb pointer off of the stack-specific lksb.
177 */
178 void *(*lock_lvb)(union ocfs2_dlm_lksb *lksb);
179
180 /*
181 * This is an optoinal debugging hook. If provided, the
182 * stack can dump debugging information about this lock.
183 */
184 void (*dump_lksb)(union ocfs2_dlm_lksb *lksb);
185};
186
70int ocfs2_cluster_connect(const char *group, 187int ocfs2_cluster_connect(const char *group,
71 int grouplen, 188 int grouplen,
72 void (*recovery_handler)(int node_num, 189 void (*recovery_handler)(int node_num,
@@ -95,4 +212,6 @@ void ocfs2_dlm_dump_lksb(union ocfs2_dlm_lksb *lksb);
95 212
96void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto); 213void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto);
97 214
215extern struct ocfs2_locking_protocol *stack_glue_lproto;
216extern struct ocfs2_stack_operations o2cb_stack_ops;
98#endif /* STACKGLUE_H */ 217#endif /* STACKGLUE_H */