dlmglue.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * dlmglue.h
  4. *
  5. * description here
  6. *
  7. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  8. */
  9. #ifndef DLMGLUE_H
  10. #define DLMGLUE_H
  11. #include "dcache.h"
  12. #define OCFS2_LVB_VERSION 5
  13. struct ocfs2_meta_lvb {
  14. __u8 lvb_version;
  15. __u8 lvb_reserved0;
  16. __be16 lvb_idynfeatures;
  17. __be32 lvb_iclusters;
  18. __be32 lvb_iuid;
  19. __be32 lvb_igid;
  20. __be64 lvb_iatime_packed;
  21. __be64 lvb_ictime_packed;
  22. __be64 lvb_imtime_packed;
  23. __be64 lvb_isize;
  24. __be16 lvb_imode;
  25. __be16 lvb_inlink;
  26. __be32 lvb_iattr;
  27. __be32 lvb_igeneration;
  28. __be32 lvb_reserved2;
  29. };
  30. #define OCFS2_QINFO_LVB_VERSION 1
  31. struct ocfs2_qinfo_lvb {
  32. __u8 lvb_version;
  33. __u8 lvb_reserved[3];
  34. __be32 lvb_bgrace;
  35. __be32 lvb_igrace;
  36. __be32 lvb_syncms;
  37. __be32 lvb_blocks;
  38. __be32 lvb_free_blk;
  39. __be32 lvb_free_entry;
  40. };
  41. #define OCFS2_ORPHAN_LVB_VERSION 1
  42. struct ocfs2_orphan_scan_lvb {
  43. __u8 lvb_version;
  44. __u8 lvb_reserved[3];
  45. __be32 lvb_os_seqno;
  46. };
  47. #define OCFS2_TRIMFS_LVB_VERSION 1
  48. struct ocfs2_trim_fs_lvb {
  49. __u8 lvb_version;
  50. __u8 lvb_success;
  51. __u8 lvb_reserved[2];
  52. __be32 lvb_nodenum;
  53. __be64 lvb_start;
  54. __be64 lvb_len;
  55. __be64 lvb_minlen;
  56. __be64 lvb_trimlen;
  57. };
  58. struct ocfs2_trim_fs_info {
  59. u8 tf_valid; /* lvb is valid, or not */
  60. u8 tf_success; /* trim is successful, or not */
  61. u32 tf_nodenum; /* osb node number */
  62. u64 tf_start; /* trim start offset in clusters */
  63. u64 tf_len; /* trim end offset in clusters */
  64. u64 tf_minlen; /* trim minimum contiguous free clusters */
  65. u64 tf_trimlen; /* trimmed length in bytes */
  66. };
  67. struct ocfs2_lock_holder {
  68. struct list_head oh_list;
  69. struct pid *oh_owner_pid;
  70. int oh_ex;
  71. };
  72. /* ocfs2_inode_lock_full() 'arg_flags' flags */
  73. /* don't wait on recovery. */
  74. #define OCFS2_META_LOCK_RECOVERY (0x01)
  75. /* Instruct the dlm not to queue ourselves on the other node. */
  76. #define OCFS2_META_LOCK_NOQUEUE (0x02)
  77. /* don't block waiting for the downconvert thread, instead return -EAGAIN */
  78. #define OCFS2_LOCK_NONBLOCK (0x04)
  79. /* just get back disk inode bh if we've got cluster lock. */
  80. #define OCFS2_META_LOCK_GETBH (0x08)
  81. /* Locking subclasses of inode cluster lock */
  82. enum {
  83. OI_LS_NORMAL = 0,
  84. OI_LS_PARENT,
  85. OI_LS_RENAME1,
  86. OI_LS_RENAME2,
  87. OI_LS_REFLINK_TARGET,
  88. };
  89. int ocfs2_dlm_init(struct ocfs2_super *osb);
  90. void ocfs2_dlm_shutdown(struct ocfs2_super *osb, int hangup_pending);
  91. void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res);
  92. void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res,
  93. enum ocfs2_lock_type type,
  94. unsigned int generation,
  95. struct inode *inode);
  96. void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,
  97. u64 parent, struct inode *inode);
  98. struct ocfs2_file_private;
  99. void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres,
  100. struct ocfs2_file_private *fp);
  101. struct ocfs2_mem_dqinfo;
  102. void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres,
  103. struct ocfs2_mem_dqinfo *info);
  104. void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres,
  105. struct ocfs2_super *osb, u64 ref_blkno,
  106. unsigned int generation);
  107. void ocfs2_lock_res_free(struct ocfs2_lock_res *res);
  108. int ocfs2_create_new_inode_locks(struct inode *inode);
  109. int ocfs2_drop_inode_locks(struct inode *inode);
  110. int ocfs2_rw_lock(struct inode *inode, int write);
  111. int ocfs2_try_rw_lock(struct inode *inode, int write);
  112. void ocfs2_rw_unlock(struct inode *inode, int write);
  113. int ocfs2_open_lock(struct inode *inode);
  114. int ocfs2_try_open_lock(struct inode *inode, int write);
  115. void ocfs2_open_unlock(struct inode *inode);
  116. int ocfs2_inode_lock_atime(struct inode *inode,
  117. struct vfsmount *vfsmnt,
  118. int *level, int wait);
  119. int ocfs2_inode_lock_full_nested(struct inode *inode,
  120. struct buffer_head **ret_bh,
  121. int ex,
  122. int arg_flags,
  123. int subclass);
  124. int ocfs2_inode_lock_with_folio(struct inode *inode,
  125. struct buffer_head **ret_bh, int ex, struct folio *folio);
  126. /* Variants without special locking class or flags */
  127. #define ocfs2_inode_lock_full(i, r, e, f)\
  128. ocfs2_inode_lock_full_nested(i, r, e, f, OI_LS_NORMAL)
  129. #define ocfs2_inode_lock_nested(i, b, e, s)\
  130. ocfs2_inode_lock_full_nested(i, b, e, 0, s)
  131. /* 99% of the time we don't want to supply any additional flags --
  132. * those are for very specific cases only. */
  133. #define ocfs2_inode_lock(i, b, e) ocfs2_inode_lock_full_nested(i, b, e, 0, OI_LS_NORMAL)
  134. #define ocfs2_try_inode_lock(i, b, e)\
  135. ocfs2_inode_lock_full_nested(i, b, e, OCFS2_META_LOCK_NOQUEUE,\
  136. OI_LS_NORMAL)
  137. void ocfs2_inode_unlock(struct inode *inode,
  138. int ex);
  139. int ocfs2_super_lock(struct ocfs2_super *osb,
  140. int ex);
  141. void ocfs2_super_unlock(struct ocfs2_super *osb,
  142. int ex);
  143. int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno);
  144. void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);
  145. int ocfs2_rename_lock(struct ocfs2_super *osb);
  146. void ocfs2_rename_unlock(struct ocfs2_super *osb);
  147. int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex);
  148. void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex);
  149. void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb);
  150. void ocfs2_trim_fs_lock_res_uninit(struct ocfs2_super *osb);
  151. int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
  152. struct ocfs2_trim_fs_info *info, int trylock);
  153. void ocfs2_trim_fs_unlock(struct ocfs2_super *osb,
  154. struct ocfs2_trim_fs_info *info);
  155. int ocfs2_dentry_lock(struct dentry *dentry, int ex);
  156. void ocfs2_dentry_unlock(struct dentry *dentry, int ex);
  157. int ocfs2_file_lock(struct file *file, int ex, int trylock);
  158. void ocfs2_file_unlock(struct file *file);
  159. int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex);
  160. void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex);
  161. struct ocfs2_refcount_tree;
  162. int ocfs2_refcount_lock(struct ocfs2_refcount_tree *ref_tree, int ex);
  163. void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex);
  164. void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
  165. struct ocfs2_lock_res *lockres);
  166. void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
  167. struct ocfs2_lock_res *lockres);
  168. /* for the downconvert thread */
  169. void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb);
  170. struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void);
  171. void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug);
  172. /* To set the locking protocol on module initialization */
  173. void ocfs2_set_locking_protocol(void);
  174. /* The _tracker pair is used to avoid cluster recursive locking */
  175. int ocfs2_inode_lock_tracker(struct inode *inode,
  176. struct buffer_head **ret_bh,
  177. int ex,
  178. struct ocfs2_lock_holder *oh);
  179. void ocfs2_inode_unlock_tracker(struct inode *inode,
  180. int ex,
  181. struct ocfs2_lock_holder *oh,
  182. int had_lock);
  183. #endif /* DLMGLUE_H */