0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef DLMAPI_H
0011 #define DLMAPI_H
0012
0013 struct dlm_lock;
0014 struct dlm_ctxt;
0015
0016
0017 enum dlm_status {
0018 DLM_NORMAL = 0,
0019 DLM_GRANTED,
0020 DLM_DENIED,
0021 DLM_DENIED_NOLOCKS,
0022 DLM_WORKING,
0023 DLM_BLOCKED,
0024 DLM_BLOCKED_ORPHAN,
0025 DLM_DENIED_GRACE_PERIOD,
0026 DLM_SYSERR,
0027 DLM_NOSUPPORT,
0028 DLM_CANCELGRANT,
0029 DLM_IVLOCKID,
0030 DLM_SYNC,
0031 DLM_BADTYPE,
0032 DLM_BADRESOURCE,
0033 DLM_MAXHANDLES,
0034 DLM_NOCLINFO,
0035 DLM_NOLOCKMGR,
0036 DLM_NOPURGED,
0037 DLM_BADARGS,
0038 DLM_VOID,
0039 DLM_NOTQUEUED,
0040 DLM_IVBUFLEN,
0041 DLM_CVTUNGRANT,
0042 DLM_BADPARAM,
0043 DLM_VALNOTVALID,
0044 DLM_REJECTED,
0045 DLM_ABORT,
0046 DLM_CANCEL,
0047 DLM_IVRESHANDLE,
0048 DLM_DEADLOCK,
0049 DLM_DENIED_NOASTS,
0050 DLM_FORWARD,
0051 DLM_TIMEOUT,
0052 DLM_IVGROUPID,
0053 DLM_VERS_CONFLICT,
0054 DLM_BAD_DEVICE_PATH,
0055 DLM_NO_DEVICE_PERMISSION,
0056 DLM_NO_CONTROL_DEVICE,
0057
0058 DLM_RECOVERING,
0059
0060 DLM_MIGRATING,
0061
0062 DLM_MAXSTATS,
0063 };
0064
0065
0066 const char *dlm_errmsg(enum dlm_status err);
0067
0068 const char *dlm_errname(enum dlm_status err);
0069
0070
0071
0072
0073
0074 #define dlm_error(st) do { \
0075 if ((st) != DLM_RECOVERING && \
0076 (st) != DLM_MIGRATING && \
0077 (st) != DLM_FORWARD) \
0078 mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st))); \
0079 } while (0)
0080
0081 #define DLM_LKSB_UNUSED1 0x01
0082 #define DLM_LKSB_PUT_LVB 0x02
0083 #define DLM_LKSB_GET_LVB 0x04
0084 #define DLM_LKSB_UNUSED2 0x08
0085 #define DLM_LKSB_UNUSED3 0x10
0086 #define DLM_LKSB_UNUSED4 0x20
0087 #define DLM_LKSB_UNUSED5 0x40
0088 #define DLM_LKSB_UNUSED6 0x80
0089
0090 #define DLM_LVB_LEN 64
0091
0092
0093
0094 struct dlm_lockstatus {
0095 enum dlm_status status;
0096 u32 flags;
0097 struct dlm_lock *lockid;
0098 char lvb[DLM_LVB_LEN];
0099 };
0100
0101
0102 #define LKM_IVMODE (-1)
0103 #define LKM_NLMODE 0
0104 #define LKM_CRMODE 1
0105 #define LKM_CWMODE 2
0106 #define LKM_PRMODE 3
0107 #define LKM_PWMODE 4
0108 #define LKM_EXMODE 5
0109 #define LKM_MAXMODE 5
0110 #define LKM_MODEMASK 0xff
0111
0112
0113
0114
0115
0116 #define LKM_ORPHAN 0x00000010
0117 #define LKM_PARENTABLE 0x00000020
0118 #define LKM_BLOCK 0x00000040
0119 #define LKM_LOCAL 0x00000080
0120 #define LKM_VALBLK 0x00000100
0121 #define LKM_NOQUEUE 0x00000200
0122 #define LKM_CONVERT 0x00000400
0123 #define LKM_NODLCKWT 0x00000800
0124 #define LKM_UNLOCK 0x00001000
0125 #define LKM_CANCEL 0x00002000
0126 #define LKM_DEQALL 0x00004000
0127 #define LKM_INVVALBLK 0x00008000
0128 #define LKM_SYNCSTS 0x00010000
0129 #define LKM_TIMEOUT 0x00020000
0130 #define LKM_SNGLDLCK 0x00040000
0131 #define LKM_FINDLOCAL 0x00080000
0132 #define LKM_PROC_OWNED 0x00100000
0133 #define LKM_XID 0x00200000
0134 #define LKM_XID_CONFLICT 0x00400000
0135 #define LKM_FORCE 0x00800000
0136 #define LKM_REVVALBLK 0x01000000
0137
0138
0139 #define LKM_UNUSED1 0x00000001
0140 #define LKM_UNUSED2 0x00000002
0141 #define LKM_UNUSED3 0x00000004
0142 #define LKM_UNUSED4 0x00000008
0143 #define LKM_UNUSED5 0x02000000
0144 #define LKM_UNUSED6 0x04000000
0145 #define LKM_UNUSED7 0x08000000
0146
0147
0148
0149 #define LKM_MIGRATION 0x10000000
0150
0151 #define LKM_PUT_LVB 0x20000000
0152
0153 #define LKM_GET_LVB 0x40000000
0154
0155 #define LKM_RECOVERY 0x80000000
0156
0157
0158
0159 typedef void (dlm_astlockfunc_t)(void *);
0160 typedef void (dlm_bastlockfunc_t)(void *, int);
0161 typedef void (dlm_astunlockfunc_t)(void *, enum dlm_status);
0162
0163 enum dlm_status dlmlock(struct dlm_ctxt *dlm,
0164 int mode,
0165 struct dlm_lockstatus *lksb,
0166 int flags,
0167 const char *name,
0168 int namelen,
0169 dlm_astlockfunc_t *ast,
0170 void *data,
0171 dlm_bastlockfunc_t *bast);
0172
0173 enum dlm_status dlmunlock(struct dlm_ctxt *dlm,
0174 struct dlm_lockstatus *lksb,
0175 int flags,
0176 dlm_astunlockfunc_t *unlockast,
0177 void *data);
0178
0179 struct dlm_protocol_version {
0180 u8 pv_major;
0181 u8 pv_minor;
0182 };
0183 struct dlm_ctxt * dlm_register_domain(const char *domain, u32 key,
0184 struct dlm_protocol_version *fs_proto);
0185
0186 void dlm_unregister_domain(struct dlm_ctxt *dlm);
0187
0188 void dlm_print_one_lock(struct dlm_lock *lockid);
0189
0190 typedef void (dlm_eviction_func)(int, void *);
0191 struct dlm_eviction_cb {
0192 struct list_head ec_item;
0193 dlm_eviction_func *ec_func;
0194 void *ec_data;
0195 };
0196 void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb,
0197 dlm_eviction_func *f,
0198 void *data);
0199 void dlm_register_eviction_cb(struct dlm_ctxt *dlm,
0200 struct dlm_eviction_cb *cb);
0201 void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb);
0202
0203 #endif