0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef STACKGLUE_H
0012 #define STACKGLUE_H
0013
0014 #include <linux/types.h>
0015 #include <linux/list.h>
0016 #include <linux/dlmconstants.h>
0017
0018 #include "dlm/dlmapi.h"
0019 #include <linux/dlm.h>
0020
0021
0022 struct file;
0023 struct file_lock;
0024
0025
0026
0027
0028
0029
0030 #define DLM_LKF_LOCAL 0x00100000
0031
0032
0033
0034
0035
0036 #define GROUP_NAME_MAX 64
0037
0038
0039 #define CLUSTER_NAME_MAX 16
0040
0041
0042
0043
0044
0045
0046 struct ocfs2_protocol_version {
0047 u8 pv_major;
0048 u8 pv_minor;
0049 };
0050
0051
0052
0053
0054
0055
0056 struct fsdlm_lksb_plus_lvb {
0057 struct dlm_lksb lksb;
0058 char lvb[DLM_LVB_LEN];
0059 };
0060
0061
0062
0063
0064
0065
0066 struct ocfs2_cluster_connection;
0067 struct ocfs2_dlm_lksb {
0068 union {
0069 struct dlm_lockstatus lksb_o2dlm;
0070 struct dlm_lksb lksb_fsdlm;
0071 struct fsdlm_lksb_plus_lvb padding;
0072 };
0073 struct ocfs2_cluster_connection *lksb_conn;
0074 };
0075
0076
0077
0078
0079 struct ocfs2_locking_protocol {
0080 struct ocfs2_protocol_version lp_max_version;
0081 void (*lp_lock_ast)(struct ocfs2_dlm_lksb *lksb);
0082 void (*lp_blocking_ast)(struct ocfs2_dlm_lksb *lksb, int level);
0083 void (*lp_unlock_ast)(struct ocfs2_dlm_lksb *lksb, int error);
0084 };
0085
0086
0087
0088
0089
0090
0091
0092 struct ocfs2_cluster_connection {
0093 char cc_name[GROUP_NAME_MAX + 1];
0094 int cc_namelen;
0095 char cc_cluster_name[CLUSTER_NAME_MAX + 1];
0096 int cc_cluster_name_len;
0097 struct ocfs2_protocol_version cc_version;
0098 struct ocfs2_locking_protocol *cc_proto;
0099 void (*cc_recovery_handler)(int node_num, void *recovery_data);
0100 void *cc_recovery_data;
0101 void *cc_lockspace;
0102 void *cc_private;
0103 };
0104
0105
0106
0107
0108
0109
0110 struct ocfs2_stack_operations {
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 int (*connect)(struct ocfs2_cluster_connection *conn);
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144 int (*disconnect)(struct ocfs2_cluster_connection *conn);
0145
0146
0147
0148
0149
0150 int (*this_node)(struct ocfs2_cluster_connection *conn,
0151 unsigned int *node);
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163 int (*dlm_lock)(struct ocfs2_cluster_connection *conn,
0164 int mode,
0165 struct ocfs2_dlm_lksb *lksb,
0166 u32 flags,
0167 void *name,
0168 unsigned int namelen);
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,
0180 struct ocfs2_dlm_lksb *lksb,
0181 u32 flags);
0182
0183
0184
0185
0186
0187
0188
0189 int (*lock_status)(struct ocfs2_dlm_lksb *lksb);
0190
0191
0192
0193
0194 int (*lvb_valid)(struct ocfs2_dlm_lksb *lksb);
0195
0196
0197
0198
0199 void *(*lock_lvb)(struct ocfs2_dlm_lksb *lksb);
0200
0201
0202
0203
0204
0205
0206 int (*plock)(struct ocfs2_cluster_connection *conn,
0207 u64 ino,
0208 struct file *file,
0209 int cmd,
0210 struct file_lock *fl);
0211
0212
0213
0214
0215
0216 void (*dump_lksb)(struct ocfs2_dlm_lksb *lksb);
0217 };
0218
0219
0220
0221
0222
0223
0224 struct ocfs2_stack_plugin {
0225 char *sp_name;
0226 struct ocfs2_stack_operations *sp_ops;
0227 struct module *sp_owner;
0228
0229
0230 struct list_head sp_list;
0231 unsigned int sp_count;
0232 struct ocfs2_protocol_version sp_max_proto;
0233 };
0234
0235
0236
0237 int ocfs2_cluster_connect(const char *stack_name,
0238 const char *cluster_name,
0239 int cluster_name_len,
0240 const char *group,
0241 int grouplen,
0242 struct ocfs2_locking_protocol *lproto,
0243 void (*recovery_handler)(int node_num,
0244 void *recovery_data),
0245 void *recovery_data,
0246 struct ocfs2_cluster_connection **conn);
0247
0248
0249
0250
0251 int ocfs2_cluster_connect_agnostic(const char *group,
0252 int grouplen,
0253 struct ocfs2_locking_protocol *lproto,
0254 void (*recovery_handler)(int node_num,
0255 void *recovery_data),
0256 void *recovery_data,
0257 struct ocfs2_cluster_connection **conn);
0258 int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn,
0259 int hangup_pending);
0260 void ocfs2_cluster_hangup(const char *group, int grouplen);
0261 int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *conn,
0262 unsigned int *node);
0263
0264 struct ocfs2_lock_res;
0265 int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
0266 int mode,
0267 struct ocfs2_dlm_lksb *lksb,
0268 u32 flags,
0269 void *name,
0270 unsigned int namelen);
0271 int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
0272 struct ocfs2_dlm_lksb *lksb,
0273 u32 flags);
0274
0275 int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb);
0276 int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb);
0277 void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb);
0278 void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb);
0279
0280 int ocfs2_stack_supports_plocks(void);
0281 int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,
0282 struct file *file, int cmd, struct file_lock *fl);
0283
0284 void ocfs2_stack_glue_set_max_proto_version(struct ocfs2_protocol_version *max_proto);
0285
0286
0287
0288 int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
0289 void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
0290
0291 extern struct kset *ocfs2_kset;
0292
0293 #endif