dlm_internal.h 18 KB

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