dlmglue.h 6.7 KB

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