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