lock_dlm.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License version 2.
  8. */
  9. #ifndef LOCK_DLM_DOT_H
  10. #define LOCK_DLM_DOT_H
  11. #include <linux/module.h>
  12. #include <linux/slab.h>
  13. #include <linux/spinlock.h>
  14. #include <linux/types.h>
  15. #include <linux/string.h>
  16. #include <linux/list.h>
  17. #include <linux/socket.h>
  18. #include <linux/delay.h>
  19. #include <linux/kthread.h>
  20. #include <linux/kobject.h>
  21. #include <linux/fcntl.h>
  22. #include <linux/wait.h>
  23. #include <net/sock.h>
  24. #include <linux/dlm.h>
  25. #include <linux/dlm_plock.h>
  26. #include <linux/lm_interface.h>
  27. /*
  28. * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a
  29. * prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module
  30. * as "lock_dlm".
  31. */
  32. #define GDLM_STRNAME_BYTES 24
  33. #define GDLM_LVB_SIZE 32
  34. #define GDLM_DROP_COUNT 0
  35. #define GDLM_DROP_PERIOD 60
  36. #define GDLM_NAME_LEN 128
  37. /* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number).
  38. We sprintf these numbers into a 24 byte string of hex values to make them
  39. human-readable (to make debugging simpler.) */
  40. struct gdlm_strname {
  41. unsigned char name[GDLM_STRNAME_BYTES];
  42. unsigned short namelen;
  43. };
  44. enum {
  45. DFL_BLOCK_LOCKS = 0,
  46. DFL_SPECTATOR = 1,
  47. DFL_WITHDRAW = 2,
  48. };
  49. struct gdlm_ls {
  50. u32 id;
  51. int jid;
  52. int first;
  53. int first_done;
  54. unsigned long flags;
  55. struct kobject kobj;
  56. char clustername[GDLM_NAME_LEN];
  57. char fsname[GDLM_NAME_LEN];
  58. int fsflags;
  59. dlm_lockspace_t *dlm_lockspace;
  60. lm_callback_t fscb;
  61. struct gfs2_sbd *sdp;
  62. int recover_jid;
  63. int recover_jid_done;
  64. int recover_jid_status;
  65. spinlock_t async_lock;
  66. struct list_head delayed;
  67. struct list_head submit;
  68. u32 all_locks_count;
  69. wait_queue_head_t wait_control;
  70. struct task_struct *thread;
  71. wait_queue_head_t thread_wait;
  72. };
  73. enum {
  74. LFL_NOBLOCK = 0,
  75. LFL_NOCACHE = 1,
  76. LFL_DLM_UNLOCK = 2,
  77. LFL_DLM_CANCEL = 3,
  78. LFL_SYNC_LVB = 4,
  79. LFL_FORCE_PROMOTE = 5,
  80. LFL_REREQUEST = 6,
  81. LFL_ACTIVE = 7,
  82. LFL_INLOCK = 8,
  83. LFL_CANCEL = 9,
  84. LFL_NOBAST = 10,
  85. LFL_HEADQUE = 11,
  86. LFL_UNLOCK_DELETE = 12,
  87. LFL_AST_WAIT = 13,
  88. };
  89. struct gdlm_lock {
  90. struct gdlm_ls *ls;
  91. struct lm_lockname lockname;
  92. struct gdlm_strname strname;
  93. char *lvb;
  94. struct dlm_lksb lksb;
  95. s16 cur;
  96. s16 req;
  97. s16 prev_req;
  98. u32 lkf; /* dlm flags DLM_LKF_ */
  99. unsigned long flags; /* lock_dlm flags LFL_ */
  100. struct list_head delay_list; /* delayed */
  101. struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
  102. };
  103. #define gdlm_assert(assertion, fmt, args...) \
  104. do { \
  105. if (unlikely(!(assertion))) { \
  106. printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \
  107. "lock_dlm: " fmt "\n", \
  108. #assertion, ##args); \
  109. BUG(); \
  110. } \
  111. } while (0)
  112. #define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg)
  113. #define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg)
  114. #define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg)
  115. #ifdef LOCK_DLM_LOG_DEBUG
  116. #define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg)
  117. #else
  118. #define log_debug(fmt, arg...)
  119. #endif
  120. /* sysfs.c */
  121. int gdlm_sysfs_init(void);
  122. void gdlm_sysfs_exit(void);
  123. int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *);
  124. void gdlm_kobject_release(struct gdlm_ls *);
  125. /* thread.c */
  126. int gdlm_init_threads(struct gdlm_ls *);
  127. void gdlm_release_threads(struct gdlm_ls *);
  128. /* lock.c */
  129. void gdlm_submit_delayed(struct gdlm_ls *);
  130. unsigned int gdlm_do_lock(struct gdlm_lock *);
  131. int gdlm_get_lock(void *, struct lm_lockname *, void **);
  132. void gdlm_put_lock(void *);
  133. unsigned int gdlm_lock(void *, unsigned int, unsigned int, unsigned int);
  134. unsigned int gdlm_unlock(void *, unsigned int);
  135. void gdlm_cancel(void *);
  136. int gdlm_hold_lvb(void *, char **);
  137. void gdlm_unhold_lvb(void *, char *);
  138. /* mount.c */
  139. extern const struct lm_lockops gdlm_ops;
  140. #endif