dlm_internal.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /******************************************************************************
  2. *******************************************************************************
  3. **
  4. ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  5. ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  6. **
  7. ** This copyrighted material is made available to anyone wishing to use,
  8. ** modify, copy, or redistribute it subject to the terms and conditions
  9. ** of the GNU General Public License v.2.
  10. **
  11. *******************************************************************************
  12. ******************************************************************************/
  13. #ifndef __DLM_INTERNAL_DOT_H__
  14. #define __DLM_INTERNAL_DOT_H__
  15. /*
  16. * This is the main header file to be included in each DLM source file.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/slab.h>
  20. #include <linux/sched.h>
  21. #include <linux/types.h>
  22. #include <linux/ctype.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/vmalloc.h>
  25. #include <linux/list.h>
  26. #include <linux/errno.h>
  27. #include <linux/random.h>
  28. #include <linux/delay.h>
  29. #include <linux/socket.h>
  30. #include <linux/kthread.h>
  31. #include <linux/kobject.h>
  32. #include <linux/kref.h>
  33. #include <linux/kernel.h>
  34. #include <linux/jhash.h>
  35. #include <linux/miscdevice.h>
  36. #include <linux/mutex.h>
  37. #include <linux/idr.h>
  38. #include <linux/ratelimit.h>
  39. #include <asm/uaccess.h>
  40. #include <linux/dlm.h>
  41. #include "config.h"
  42. /* Size of the temp buffer midcomms allocates on the stack.
  43. We try to make this large enough so most messages fit.
  44. FIXME: should sctp make this unnecessary? */
  45. #define DLM_INBUF_LEN 148
  46. struct dlm_ls;
  47. struct dlm_lkb;
  48. struct dlm_rsb;
  49. struct dlm_member;
  50. struct dlm_rsbtable;
  51. struct dlm_dirtable;
  52. struct dlm_direntry;
  53. struct dlm_recover;
  54. struct dlm_header;
  55. struct dlm_message;
  56. struct dlm_rcom;
  57. struct dlm_mhandle;
  58. #define log_print(fmt, args...) \
  59. printk(KERN_ERR "dlm: "fmt"\n" , ##args)
  60. #define log_error(ls, fmt, args...) \
  61. printk(KERN_ERR "dlm: %s: " fmt "\n", (ls)->ls_name , ##args)
  62. #define log_debug(ls, fmt, args...) \
  63. do { \
  64. if (dlm_config.ci_log_debug) \
  65. printk(KERN_DEBUG "dlm: %s: " fmt "\n", \
  66. (ls)->ls_name , ##args); \
  67. } while (0)
  68. #define log_limit(ls, fmt, args...) \
  69. do { \
  70. if (dlm_config.ci_log_debug) \
  71. printk_ratelimited(KERN_DEBUG "dlm: %s: " fmt "\n", \
  72. (ls)->ls_name , ##args); \
  73. } while (0)
  74. #define DLM_ASSERT(x, do) \
  75. { \
  76. if (!(x)) \
  77. { \
  78. printk(KERN_ERR "\nDLM: Assertion failed on line %d of file %s\n" \
  79. "DLM: assertion: \"%s\"\n" \
  80. "DLM: time = %lu\n", \
  81. __LINE__, __FILE__, #x, jiffies); \
  82. {do} \
  83. printk("\n"); \
  84. BUG(); \
  85. panic("DLM: Record message above and reboot.\n"); \
  86. } \
  87. }
  88. struct dlm_direntry {
  89. struct list_head list;
  90. uint32_t master_nodeid;
  91. uint16_t length;
  92. char name[1];
  93. };
  94. struct dlm_dirtable {
  95. struct list_head list;
  96. spinlock_t lock;
  97. };
  98. struct dlm_rsbtable {
  99. struct rb_root keep;
  100. struct rb_root toss;
  101. spinlock_t lock;
  102. };
  103. /*
  104. * Lockspace member (per node in a ls)
  105. */
  106. struct dlm_member {
  107. struct list_head list;
  108. int nodeid;
  109. int weight;
  110. int slot;
  111. int slot_prev;
  112. int comm_seq;
  113. uint32_t generation;
  114. };
  115. /*
  116. * Save and manage recovery state for a lockspace.
  117. */
  118. struct dlm_recover {
  119. struct list_head list;
  120. struct dlm_config_node *nodes;
  121. int nodes_count;
  122. uint64_t seq;
  123. };
  124. /*
  125. * Pass input args to second stage locking function.
  126. */
  127. struct dlm_args {
  128. uint32_t flags;
  129. void (*astfn) (void *astparam);
  130. void *astparam;
  131. void (*bastfn) (void *astparam, int mode);
  132. int mode;
  133. struct dlm_lksb *lksb;
  134. unsigned long timeout;
  135. };
  136. /*
  137. * Lock block
  138. *
  139. * A lock can be one of three types:
  140. *
  141. * local copy lock is mastered locally
  142. * (lkb_nodeid is zero and DLM_LKF_MSTCPY is not set)
  143. * process copy lock is mastered on a remote node
  144. * (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is not set)
  145. * master copy master node's copy of a lock owned by remote node
  146. * (lkb_nodeid is non-zero and DLM_LKF_MSTCPY is set)
  147. *
  148. * lkb_exflags: a copy of the most recent flags arg provided to dlm_lock or
  149. * dlm_unlock. The dlm does not modify these or use any private flags in
  150. * this field; it only contains DLM_LKF_ flags from dlm.h. These flags
  151. * are sent as-is to the remote master when the lock is remote.
  152. *
  153. * lkb_flags: internal dlm flags (DLM_IFL_ prefix) from dlm_internal.h.
  154. * Some internal flags are shared between the master and process nodes;
  155. * these shared flags are kept in the lower two bytes. One of these
  156. * flags set on the master copy will be propagated to the process copy
  157. * and v.v. Other internal flags are private to the master or process
  158. * node (e.g. DLM_IFL_MSTCPY). These are kept in the high two bytes.
  159. *
  160. * lkb_sbflags: status block flags. These flags are copied directly into
  161. * the caller's lksb.sb_flags prior to the dlm_lock/dlm_unlock completion
  162. * ast. All defined in dlm.h with DLM_SBF_ prefix.
  163. *
  164. * lkb_status: the lock status indicates which rsb queue the lock is
  165. * on, grant, convert, or wait. DLM_LKSTS_ WAITING/GRANTED/CONVERT
  166. *
  167. * lkb_wait_type: the dlm message type (DLM_MSG_ prefix) for which a
  168. * reply is needed. Only set when the lkb is on the lockspace waiters
  169. * list awaiting a reply from a remote node.
  170. *
  171. * lkb_nodeid: when the lkb is a local copy, nodeid is 0; when the lkb
  172. * is a master copy, nodeid specifies the remote lock holder, when the
  173. * lkb is a process copy, the nodeid specifies the lock master.
  174. */
  175. /* lkb_status */
  176. #define DLM_LKSTS_WAITING 1
  177. #define DLM_LKSTS_GRANTED 2
  178. #define DLM_LKSTS_CONVERT 3
  179. /* lkb_flags */
  180. #define DLM_IFL_MSTCPY 0x00010000
  181. #define DLM_IFL_RESEND 0x00020000
  182. #define DLM_IFL_DEAD 0x00040000
  183. #define DLM_IFL_OVERLAP_UNLOCK 0x00080000
  184. #define DLM_IFL_OVERLAP_CANCEL 0x00100000
  185. #define DLM_IFL_ENDOFLIFE 0x00200000
  186. #define DLM_IFL_WATCH_TIMEWARN 0x00400000
  187. #define DLM_IFL_TIMEOUT_CANCEL 0x00800000
  188. #define DLM_IFL_DEADLOCK_CANCEL 0x01000000
  189. #define DLM_IFL_STUB_MS 0x02000000 /* magic number for m_flags */
  190. #define DLM_IFL_USER 0x00000001
  191. #define DLM_IFL_ORPHAN 0x00000002
  192. #define DLM_CALLBACKS_SIZE 6
  193. #define DLM_CB_CAST 0x00000001
  194. #define DLM_CB_BAST 0x00000002
  195. #define DLM_CB_SKIP 0x00000004
  196. struct dlm_callback {
  197. uint64_t seq;
  198. uint32_t flags; /* DLM_CBF_ */
  199. int sb_status; /* copy to lksb status */
  200. uint8_t sb_flags; /* copy to lksb flags */
  201. int8_t mode; /* rq mode of bast, gr mode of cast */
  202. };
  203. struct dlm_lkb {
  204. struct dlm_rsb *lkb_resource; /* the rsb */
  205. struct kref lkb_ref;
  206. int lkb_nodeid; /* copied from rsb */
  207. int lkb_ownpid; /* pid of lock owner */
  208. uint32_t lkb_id; /* our lock ID */
  209. uint32_t lkb_remid; /* lock ID on remote partner */
  210. uint32_t lkb_exflags; /* external flags from caller */
  211. uint32_t lkb_sbflags; /* lksb flags */
  212. uint32_t lkb_flags; /* internal flags */
  213. uint32_t lkb_lvbseq; /* lvb sequence number */
  214. int8_t lkb_status; /* granted, waiting, convert */
  215. int8_t lkb_rqmode; /* requested lock mode */
  216. int8_t lkb_grmode; /* granted lock mode */
  217. int8_t lkb_highbast; /* highest mode bast sent for */
  218. int8_t lkb_wait_type; /* type of reply waiting for */
  219. int8_t lkb_wait_count;
  220. int lkb_wait_nodeid; /* for debugging */
  221. struct list_head lkb_statequeue; /* rsb g/c/w list */
  222. struct list_head lkb_rsb_lookup; /* waiting for rsb lookup */
  223. struct list_head lkb_wait_reply; /* waiting for remote reply */
  224. struct list_head lkb_ownqueue; /* list of locks for a process */
  225. struct list_head lkb_time_list;
  226. ktime_t lkb_timestamp;
  227. ktime_t lkb_wait_time;
  228. unsigned long lkb_timeout_cs;
  229. struct mutex lkb_cb_mutex;
  230. struct work_struct lkb_cb_work;
  231. struct list_head lkb_cb_list; /* for ls_cb_delay or proc->asts */
  232. struct dlm_callback lkb_callbacks[DLM_CALLBACKS_SIZE];
  233. struct dlm_callback lkb_last_cast;
  234. struct dlm_callback lkb_last_bast;
  235. ktime_t lkb_last_cast_time; /* for debugging */
  236. ktime_t lkb_last_bast_time; /* for debugging */
  237. char *lkb_lvbptr;
  238. struct dlm_lksb *lkb_lksb; /* caller's status block */
  239. void (*lkb_astfn) (void *astparam);
  240. void (*lkb_bastfn) (void *astparam, int mode);
  241. union {
  242. void *lkb_astparam; /* caller's ast arg */
  243. struct dlm_user_args *lkb_ua;
  244. };
  245. };
  246. struct dlm_rsb {
  247. struct dlm_ls *res_ls; /* the lockspace */
  248. struct kref res_ref;
  249. struct mutex res_mutex;
  250. unsigned long res_flags;
  251. int res_length; /* length of rsb name */
  252. int res_nodeid;
  253. uint32_t res_lvbseq;
  254. uint32_t res_hash;
  255. uint32_t res_bucket; /* rsbtbl */
  256. unsigned long res_toss_time;
  257. uint32_t res_first_lkid;
  258. struct list_head res_lookup; /* lkbs waiting on first */
  259. union {
  260. struct list_head res_hashchain;
  261. struct rb_node res_hashnode; /* rsbtbl */
  262. };
  263. struct list_head res_grantqueue;
  264. struct list_head res_convertqueue;
  265. struct list_head res_waitqueue;
  266. struct list_head res_root_list; /* used for recovery */
  267. struct list_head res_recover_list; /* used for recovery */
  268. int res_recover_locks_count;
  269. char *res_lvbptr;
  270. char res_name[DLM_RESNAME_MAXLEN+1];
  271. };
  272. /* find_rsb() flags */
  273. #define R_MASTER 1 /* only return rsb if it's a master */
  274. #define R_CREATE 2 /* create/add rsb if not found */
  275. /* rsb_flags */
  276. enum rsb_flags {
  277. RSB_MASTER_UNCERTAIN,
  278. RSB_VALNOTVALID,
  279. RSB_VALNOTVALID_PREV,
  280. RSB_NEW_MASTER,
  281. RSB_NEW_MASTER2,
  282. RSB_RECOVER_CONVERT,
  283. RSB_LOCKS_PURGED,
  284. };
  285. static inline void rsb_set_flag(struct dlm_rsb *r, enum rsb_flags flag)
  286. {
  287. __set_bit(flag, &r->res_flags);
  288. }
  289. static inline void rsb_clear_flag(struct dlm_rsb *r, enum rsb_flags flag)
  290. {
  291. __clear_bit(flag, &r->res_flags);
  292. }
  293. static inline int rsb_flag(struct dlm_rsb *r, enum rsb_flags flag)
  294. {
  295. return test_bit(flag, &r->res_flags);
  296. }
  297. /* dlm_header is first element of all structs sent between nodes */
  298. #define DLM_HEADER_MAJOR 0x00030000
  299. #define DLM_HEADER_MINOR 0x00000001
  300. #define DLM_HEADER_SLOTS 0x00000001
  301. #define DLM_MSG 1
  302. #define DLM_RCOM 2
  303. struct dlm_header {
  304. uint32_t h_version;
  305. uint32_t h_lockspace;
  306. uint32_t h_nodeid; /* nodeid of sender */
  307. uint16_t h_length;
  308. uint8_t h_cmd; /* DLM_MSG, DLM_RCOM */
  309. uint8_t h_pad;
  310. };
  311. #define DLM_MSG_REQUEST 1
  312. #define DLM_MSG_CONVERT 2
  313. #define DLM_MSG_UNLOCK 3
  314. #define DLM_MSG_CANCEL 4
  315. #define DLM_MSG_REQUEST_REPLY 5
  316. #define DLM_MSG_CONVERT_REPLY 6
  317. #define DLM_MSG_UNLOCK_REPLY 7
  318. #define DLM_MSG_CANCEL_REPLY 8
  319. #define DLM_MSG_GRANT 9
  320. #define DLM_MSG_BAST 10
  321. #define DLM_MSG_LOOKUP 11
  322. #define DLM_MSG_REMOVE 12
  323. #define DLM_MSG_LOOKUP_REPLY 13
  324. #define DLM_MSG_PURGE 14
  325. struct dlm_message {
  326. struct dlm_header m_header;
  327. uint32_t m_type; /* DLM_MSG_ */
  328. uint32_t m_nodeid;
  329. uint32_t m_pid;
  330. uint32_t m_lkid; /* lkid on sender */
  331. uint32_t m_remid; /* lkid on receiver */
  332. uint32_t m_parent_lkid;
  333. uint32_t m_parent_remid;
  334. uint32_t m_exflags;
  335. uint32_t m_sbflags;
  336. uint32_t m_flags;
  337. uint32_t m_lvbseq;
  338. uint32_t m_hash;
  339. int m_status;
  340. int m_grmode;
  341. int m_rqmode;
  342. int m_bastmode;
  343. int m_asts;
  344. int m_result; /* 0 or -EXXX */
  345. char m_extra[0]; /* name or lvb */
  346. };
  347. #define DLM_RS_NODES 0x00000001
  348. #define DLM_RS_NODES_ALL 0x00000002
  349. #define DLM_RS_DIR 0x00000004
  350. #define DLM_RS_DIR_ALL 0x00000008
  351. #define DLM_RS_LOCKS 0x00000010
  352. #define DLM_RS_LOCKS_ALL 0x00000020
  353. #define DLM_RS_DONE 0x00000040
  354. #define DLM_RS_DONE_ALL 0x00000080
  355. #define DLM_RCOM_STATUS 1
  356. #define DLM_RCOM_NAMES 2
  357. #define DLM_RCOM_LOOKUP 3
  358. #define DLM_RCOM_LOCK 4
  359. #define DLM_RCOM_STATUS_REPLY 5
  360. #define DLM_RCOM_NAMES_REPLY 6
  361. #define DLM_RCOM_LOOKUP_REPLY 7
  362. #define DLM_RCOM_LOCK_REPLY 8
  363. struct dlm_rcom {
  364. struct dlm_header rc_header;
  365. uint32_t rc_type; /* DLM_RCOM_ */
  366. int rc_result; /* multi-purpose */
  367. uint64_t rc_id; /* match reply with request */
  368. uint64_t rc_seq; /* sender's ls_recover_seq */
  369. uint64_t rc_seq_reply; /* remote ls_recover_seq */
  370. char rc_buf[0];
  371. };
  372. union dlm_packet {
  373. struct dlm_header header; /* common to other two */
  374. struct dlm_message message;
  375. struct dlm_rcom rcom;
  376. };
  377. #define DLM_RSF_NEED_SLOTS 0x00000001
  378. /* RCOM_STATUS data */
  379. struct rcom_status {
  380. __le32 rs_flags;
  381. __le32 rs_unused1;
  382. __le64 rs_unused2;
  383. };
  384. /* RCOM_STATUS_REPLY data */
  385. struct rcom_config {
  386. __le32 rf_lvblen;
  387. __le32 rf_lsflags;
  388. /* DLM_HEADER_SLOTS adds: */
  389. __le32 rf_flags;
  390. __le16 rf_our_slot;
  391. __le16 rf_num_slots;
  392. __le32 rf_generation;
  393. __le32 rf_unused1;
  394. __le64 rf_unused2;
  395. };
  396. struct rcom_slot {
  397. __le32 ro_nodeid;
  398. __le16 ro_slot;
  399. __le16 ro_unused1;
  400. __le64 ro_unused2;
  401. };
  402. struct rcom_lock {
  403. __le32 rl_ownpid;
  404. __le32 rl_lkid;
  405. __le32 rl_remid;
  406. __le32 rl_parent_lkid;
  407. __le32 rl_parent_remid;
  408. __le32 rl_exflags;
  409. __le32 rl_flags;
  410. __le32 rl_lvbseq;
  411. __le32 rl_result;
  412. int8_t rl_rqmode;
  413. int8_t rl_grmode;
  414. int8_t rl_status;
  415. int8_t rl_asts;
  416. __le16 rl_wait_type;
  417. __le16 rl_namelen;
  418. char rl_name[DLM_RESNAME_MAXLEN];
  419. char rl_lvb[0];
  420. };
  421. struct dlm_ls {
  422. struct list_head ls_list; /* list of lockspaces */
  423. dlm_lockspace_t *ls_local_handle;
  424. uint32_t ls_global_id; /* global unique lockspace ID */
  425. uint32_t ls_generation;
  426. uint32_t ls_exflags;
  427. int ls_lvblen;
  428. int ls_count; /* refcount of processes in
  429. the dlm using this ls */
  430. int ls_create_count; /* create/release refcount */
  431. unsigned long ls_flags; /* LSFL_ */
  432. unsigned long ls_scan_time;
  433. struct kobject ls_kobj;
  434. struct idr ls_lkbidr;
  435. spinlock_t ls_lkbidr_spin;
  436. struct dlm_rsbtable *ls_rsbtbl;
  437. uint32_t ls_rsbtbl_size;
  438. struct dlm_dirtable *ls_dirtbl;
  439. uint32_t ls_dirtbl_size;
  440. struct mutex ls_waiters_mutex;
  441. struct list_head ls_waiters; /* lkbs needing a reply */
  442. struct mutex ls_orphans_mutex;
  443. struct list_head ls_orphans;
  444. struct mutex ls_timeout_mutex;
  445. struct list_head ls_timeout;
  446. spinlock_t ls_new_rsb_spin;
  447. int ls_new_rsb_count;
  448. struct list_head ls_new_rsb; /* new rsb structs */
  449. struct list_head ls_nodes; /* current nodes in ls */
  450. struct list_head ls_nodes_gone; /* dead node list, recovery */
  451. int ls_num_nodes; /* number of nodes in ls */
  452. int ls_low_nodeid;
  453. int ls_total_weight;
  454. int *ls_node_array;
  455. int ls_slot;
  456. int ls_num_slots;
  457. int ls_slots_size;
  458. struct dlm_slot *ls_slots;
  459. struct dlm_rsb ls_stub_rsb; /* for returning errors */
  460. struct dlm_lkb ls_stub_lkb; /* for returning errors */
  461. struct dlm_message ls_stub_ms; /* for faking a reply */
  462. struct dentry *ls_debug_rsb_dentry; /* debugfs */
  463. struct dentry *ls_debug_waiters_dentry; /* debugfs */
  464. struct dentry *ls_debug_locks_dentry; /* debugfs */
  465. struct dentry *ls_debug_all_dentry; /* debugfs */
  466. wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
  467. int ls_uevent_result;
  468. struct completion ls_members_done;
  469. int ls_members_result;
  470. struct miscdevice ls_device;
  471. struct workqueue_struct *ls_callback_wq;
  472. /* recovery related */
  473. struct mutex ls_cb_mutex;
  474. struct list_head ls_cb_delay; /* save for queue_work later */
  475. struct timer_list ls_timer;
  476. struct task_struct *ls_recoverd_task;
  477. struct mutex ls_recoverd_active;
  478. spinlock_t ls_recover_lock;
  479. unsigned long ls_recover_begin; /* jiffies timestamp */
  480. uint32_t ls_recover_status; /* DLM_RS_ */
  481. uint64_t ls_recover_seq;
  482. struct dlm_recover *ls_recover_args;
  483. struct rw_semaphore ls_in_recovery; /* block local requests */
  484. struct rw_semaphore ls_recv_active; /* block dlm_recv */
  485. struct list_head ls_requestqueue;/* queue remote requests */
  486. struct mutex ls_requestqueue_mutex;
  487. struct dlm_rcom *ls_recover_buf;
  488. int ls_recover_nodeid; /* for debugging */
  489. uint64_t ls_rcom_seq;
  490. spinlock_t ls_rcom_spin;
  491. struct list_head ls_recover_list;
  492. spinlock_t ls_recover_list_lock;
  493. int ls_recover_list_count;
  494. wait_queue_head_t ls_wait_general;
  495. struct mutex ls_clear_proc_locks;
  496. struct list_head ls_root_list; /* root resources */
  497. struct rw_semaphore ls_root_sem; /* protect root_list */
  498. const struct dlm_lockspace_ops *ls_ops;
  499. void *ls_ops_arg;
  500. int ls_namelen;
  501. char ls_name[1];
  502. };
  503. #define LSFL_WORK 0
  504. #define LSFL_RUNNING 1
  505. #define LSFL_RECOVERY_STOP 2
  506. #define LSFL_RCOM_READY 3
  507. #define LSFL_RCOM_WAIT 4
  508. #define LSFL_UEVENT_WAIT 5
  509. #define LSFL_TIMEWARN 6
  510. #define LSFL_CB_DELAY 7
  511. /* much of this is just saving user space pointers associated with the
  512. lock that we pass back to the user lib with an ast */
  513. struct dlm_user_args {
  514. struct dlm_user_proc *proc; /* each process that opens the lockspace
  515. device has private data
  516. (dlm_user_proc) on the struct file,
  517. the process's locks point back to it*/
  518. struct dlm_lksb lksb;
  519. struct dlm_lksb __user *user_lksb;
  520. void __user *castparam;
  521. void __user *castaddr;
  522. void __user *bastparam;
  523. void __user *bastaddr;
  524. uint64_t xid;
  525. };
  526. #define DLM_PROC_FLAGS_CLOSING 1
  527. #define DLM_PROC_FLAGS_COMPAT 2
  528. /* locks list is kept so we can remove all a process's locks when it
  529. exits (or orphan those that are persistent) */
  530. struct dlm_user_proc {
  531. dlm_lockspace_t *lockspace;
  532. unsigned long flags; /* DLM_PROC_FLAGS */
  533. struct list_head asts;
  534. spinlock_t asts_spin;
  535. struct list_head locks;
  536. spinlock_t locks_spin;
  537. struct list_head unlocking;
  538. wait_queue_head_t wait;
  539. };
  540. static inline int dlm_locking_stopped(struct dlm_ls *ls)
  541. {
  542. return !test_bit(LSFL_RUNNING, &ls->ls_flags);
  543. }
  544. static inline int dlm_recovery_stopped(struct dlm_ls *ls)
  545. {
  546. return test_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
  547. }
  548. static inline int dlm_no_directory(struct dlm_ls *ls)
  549. {
  550. return (ls->ls_exflags & DLM_LSFL_NODIR) ? 1 : 0;
  551. }
  552. int dlm_netlink_init(void);
  553. void dlm_netlink_exit(void);
  554. void dlm_timeout_warn(struct dlm_lkb *lkb);
  555. int dlm_plock_init(void);
  556. void dlm_plock_exit(void);
  557. #ifdef CONFIG_DLM_DEBUG
  558. int dlm_register_debugfs(void);
  559. void dlm_unregister_debugfs(void);
  560. int dlm_create_debug_file(struct dlm_ls *ls);
  561. void dlm_delete_debug_file(struct dlm_ls *ls);
  562. #else
  563. static inline int dlm_register_debugfs(void) { return 0; }
  564. static inline void dlm_unregister_debugfs(void) { }
  565. static inline int dlm_create_debug_file(struct dlm_ls *ls) { return 0; }
  566. static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
  567. #endif
  568. #endif /* __DLM_INTERNAL_DOT_H__ */