jfs_txnmgr.h 8.2 KB

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