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