jfs_txnmgr.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) International Business Machines Corp., 2000-2004
  4. */
  5. #ifndef _H_JFS_TXNMGR
  6. #define _H_JFS_TXNMGR
  7. #include "jfs_logmgr.h"
  8. /*
  9. * Hide implementation of TxBlock and TxLock
  10. */
  11. #define tid_to_tblock(tid) (&TxBlock[tid])
  12. #define lid_to_tlock(lid) (&TxLock[lid])
  13. /*
  14. * transaction block
  15. */
  16. struct tblock {
  17. /*
  18. * tblock and jbuf_t common area: struct logsyncblk
  19. *
  20. * the following 5 fields are the same as struct logsyncblk
  21. * which is common to tblock and jbuf to form logsynclist
  22. */
  23. u16 xflag; /* tx commit type */
  24. u16 flag; /* tx commit state */
  25. lid_t dummy; /* Must keep structures common */
  26. s32 lsn; /* recovery lsn */
  27. struct list_head synclist; /* logsynclist link */
  28. /* lock management */
  29. struct super_block *sb; /* super block */
  30. lid_t next; /* index of first tlock of tid */
  31. lid_t last; /* index of last tlock of tid */
  32. wait_queue_head_t waitor; /* tids waiting on this tid */
  33. /* log management */
  34. u32 logtid; /* log transaction id */
  35. /* commit management */
  36. struct list_head cqueue; /* commit queue list */
  37. s32 clsn; /* commit lsn */
  38. struct lbuf *bp;
  39. s32 pn; /* commit record log page number */
  40. s32 eor; /* commit record eor */
  41. wait_queue_head_t gcwait; /* group commit event list:
  42. * ready transactions wait on this
  43. * event for group commit completion.
  44. */
  45. union {
  46. struct inode *ip; /* inode being deleted */
  47. pxd_t ixpxd; /* pxd of inode extent for created inode */
  48. } u;
  49. u32 ino; /* inode number being created */
  50. };
  51. extern struct tblock *TxBlock; /* transaction block table */
  52. /* commit flags: tblk->xflag */
  53. #define COMMIT_SYNC 0x0001 /* synchronous commit */
  54. #define COMMIT_FORCE 0x0002 /* force pageout at end of commit */
  55. #define COMMIT_FLUSH 0x0004 /* init flush at end of commit */
  56. #define COMMIT_MAP 0x00f0
  57. #define COMMIT_PMAP 0x0010 /* update pmap */
  58. #define COMMIT_WMAP 0x0020 /* update wmap */
  59. #define COMMIT_PWMAP 0x0040 /* update pwmap */
  60. #define COMMIT_FREE 0x0f00
  61. #define COMMIT_DELETE 0x0100 /* inode delete */
  62. #define COMMIT_TRUNCATE 0x0200 /* file truncation */
  63. #define COMMIT_CREATE 0x0400 /* inode create */
  64. #define COMMIT_LAZY 0x0800 /* lazy commit */
  65. #define COMMIT_PAGE 0x1000 /* Identifies element as metapage */
  66. #define COMMIT_INODE 0x2000 /* Identifies element as inode */
  67. /* group commit flags tblk->flag: see jfs_logmgr.h */
  68. /*
  69. * transaction lock
  70. */
  71. struct tlock {
  72. lid_t next; /* 2: index next lockword on tid locklist
  73. * next lockword on freelist
  74. */
  75. tid_t tid; /* 2: transaction id holding lock */
  76. u16 flag; /* 2: lock control */
  77. u16 type; /* 2: log type */
  78. struct metapage *mp; /* 4/8: object page buffer locked */
  79. struct inode *ip; /* 4/8: object */
  80. /* (16) */
  81. s16 lock[24]; /* 48: overlay area */
  82. }; /* (64) */
  83. extern struct tlock *TxLock; /* transaction lock table */
  84. /*
  85. * tlock flag
  86. */
  87. /* txLock state */
  88. #define tlckPAGELOCK 0x8000
  89. #define tlckINODELOCK 0x4000
  90. #define tlckLINELOCK 0x2000
  91. #define tlckINLINELOCK 0x1000
  92. /* lmLog state */
  93. #define tlckLOG 0x0800
  94. /* updateMap state */
  95. #define tlckUPDATEMAP 0x0080
  96. #define tlckDIRECTORY 0x0040
  97. /* freeLock state */
  98. #define tlckFREELOCK 0x0008
  99. #define tlckWRITEPAGE 0x0004
  100. #define tlckFREEPAGE 0x0002
  101. /*
  102. * tlock type
  103. */
  104. #define tlckTYPE 0xfe00
  105. #define tlckINODE 0x8000
  106. #define tlckXTREE 0x4000
  107. #define tlckDTREE 0x2000
  108. #define tlckMAP 0x1000
  109. #define tlckEA 0x0800
  110. #define tlckACL 0x0400
  111. #define tlckDATA 0x0200
  112. #define tlckBTROOT 0x0100
  113. #define tlckOPERATION 0x00ff
  114. #define tlckGROW 0x0001 /* file grow */
  115. #define tlckREMOVE 0x0002 /* file delete */
  116. #define tlckTRUNCATE 0x0004 /* file truncate */
  117. #define tlckRELOCATE 0x0008 /* file/directory relocate */
  118. #define tlckENTRY 0x0001 /* directory insert/delete */
  119. #define tlckEXTEND 0x0002 /* directory extend in-line */
  120. #define tlckSPLIT 0x0010 /* splited page */
  121. #define tlckNEW 0x0020 /* new page from split */
  122. #define tlckFREE 0x0040 /* free page */
  123. #define tlckRELINK 0x0080 /* update sibling pointer */
  124. /*
  125. * linelock for lmLog()
  126. *
  127. * note: linelock and its variations are overlaid
  128. * at tlock.lock: watch for alignment;
  129. */
  130. struct lv {
  131. u8 offset; /* 1: */
  132. u8 length; /* 1: */
  133. }; /* (2) */
  134. #define TLOCKSHORT 20
  135. #define TLOCKLONG 28
  136. struct linelock {
  137. lid_t next; /* 2: next linelock */
  138. s8 maxcnt; /* 1: */
  139. s8 index; /* 1: */
  140. u16 flag; /* 2: */
  141. u8 type; /* 1: */
  142. u8 l2linesize; /* 1: log2 of linesize */
  143. /* (8) */
  144. struct lv lv[20]; /* 40: */
  145. }; /* (48) */
  146. #define dt_lock linelock
  147. struct xtlock {
  148. lid_t next; /* 2: */
  149. s8 maxcnt; /* 1: */
  150. s8 index; /* 1: */
  151. u16 flag; /* 2: */
  152. u8 type; /* 1: */
  153. u8 l2linesize; /* 1: log2 of linesize */
  154. /* (8) */
  155. struct lv header; /* 2: */
  156. struct lv lwm; /* 2: low water mark */
  157. struct lv hwm; /* 2: high water mark */
  158. struct lv twm; /* 2: */
  159. /* (16) */
  160. s32 pxdlock[8]; /* 32: */
  161. }; /* (48) */
  162. /*
  163. * maplock for txUpdateMap()
  164. *
  165. * note: maplock and its variations are overlaid
  166. * at tlock.lock/linelock: watch for alignment;
  167. * N.B. next field may be set by linelock, and should not
  168. * be modified by maplock;
  169. * N.B. index of the first pxdlock specifies index of next
  170. * free maplock (i.e., number of maplock) in the tlock;
  171. */
  172. struct maplock {
  173. lid_t next; /* 2: */
  174. u8 maxcnt; /* 2: */
  175. u8 index; /* 2: next free maplock index */
  176. u16 flag; /* 2: */
  177. u8 type; /* 1: */
  178. u8 count; /* 1: number of pxd/xad */
  179. /* (8) */
  180. pxd_t pxd; /* 8: */
  181. }; /* (16): */
  182. /* maplock flag */
  183. #define mlckALLOC 0x00f0
  184. #define mlckALLOCXADLIST 0x0080
  185. #define mlckALLOCPXDLIST 0x0040
  186. #define mlckALLOCXAD 0x0020
  187. #define mlckALLOCPXD 0x0010
  188. #define mlckFREE 0x000f
  189. #define mlckFREEXADLIST 0x0008
  190. #define mlckFREEPXDLIST 0x0004
  191. #define mlckFREEXAD 0x0002
  192. #define mlckFREEPXD 0x0001
  193. #define pxd_lock maplock
  194. struct xdlistlock {
  195. lid_t next; /* 2: */
  196. u8 maxcnt; /* 2: */
  197. u8 index; /* 2: */
  198. u16 flag; /* 2: */
  199. u8 type; /* 1: */
  200. u8 count; /* 1: number of pxd/xad */
  201. /* (8) */
  202. /*
  203. * We need xdlist to be 64 bits (8 bytes), regardless of
  204. * whether void * is 32 or 64 bits
  205. */
  206. union {
  207. void *_xdlist; /* pxd/xad list */
  208. s64 pad; /* 8: Force 64-bit xdlist size */
  209. } union64;
  210. }; /* (16): */
  211. #define xdlist union64._xdlist
  212. /*
  213. * commit
  214. *
  215. * parameter to the commit manager routines
  216. */
  217. struct commit {
  218. tid_t tid; /* tid = index of tblock */
  219. int flag; /* flags */
  220. struct jfs_log *log; /* log */
  221. struct super_block *sb; /* superblock */
  222. int nip; /* number of entries in iplist */
  223. struct inode **iplist; /* list of pointers to inodes */
  224. /* log record descriptor on 64-bit boundary */
  225. struct lrd lrd; /* : log record descriptor */
  226. };
  227. /*
  228. * external declarations
  229. */
  230. extern int jfs_tlocks_low;
  231. extern int txInit(void);
  232. extern void txExit(void);
  233. extern struct tlock *txLock(tid_t, struct inode *, struct metapage *, int);
  234. extern struct tlock *txMaplock(tid_t, struct inode *, int);
  235. extern int txCommit(tid_t, int, struct inode **, int);
  236. extern tid_t txBegin(struct super_block *, int);
  237. extern void txBeginAnon(struct super_block *);
  238. extern void txEnd(tid_t);
  239. extern void txAbort(tid_t, int);
  240. extern struct linelock *txLinelock(struct linelock *);
  241. extern void txFreeMap(struct inode *, struct maplock *, struct tblock *, int);
  242. extern void txEA(tid_t, struct inode *, dxd_t *, dxd_t *);
  243. extern void txFreelock(struct inode *);
  244. extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *,
  245. struct tlock *);
  246. extern void txQuiesce(struct super_block *);
  247. extern void txResume(struct super_block *);
  248. extern void txLazyUnlock(struct tblock *);
  249. extern int jfs_lazycommit(void *);
  250. extern int jfs_sync(void *);
  251. #endif /* _H_JFS_TXNMGR */