1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) International Business Machines Corp., 2000-2004
8 #include "jfs_logmgr.h"
11 * Hide implementation of TxBlock and TxLock
13 #define tid_to_tblock(tid) (&TxBlock[tid])
15 #define lid_to_tlock(lid) (&TxLock[lid])
22 * tblock and jbuf_t common area: struct logsyncblk
24 * the following 5 fields are the same as struct logsyncblk
25 * which is common to tblock and jbuf to form logsynclist
27 u16 xflag
; /* tx commit type */
28 u16 flag
; /* tx commit state */
29 lid_t dummy
; /* Must keep structures common */
30 s32 lsn
; /* recovery lsn */
31 struct list_head synclist
; /* logsynclist link */
34 struct super_block
*sb
; /* super block */
35 lid_t next
; /* index of first tlock of tid */
36 lid_t last
; /* index of last tlock of tid */
37 wait_queue_head_t waitor
; /* tids waiting on this tid */
40 u32 logtid
; /* log transaction id */
42 /* commit management */
43 struct list_head cqueue
; /* commit queue list */
44 s32 clsn
; /* commit lsn */
46 s32 pn
; /* commit record log page number */
47 s32 eor
; /* commit record eor */
48 wait_queue_head_t gcwait
; /* group commit event list:
49 * ready transactions wait on this
50 * event for group commit completion.
53 struct inode
*ip
; /* inode being deleted */
54 pxd_t ixpxd
; /* pxd of inode extent for created inode */
56 u32 ino
; /* inode number being created */
59 extern struct tblock
*TxBlock
; /* transaction block table */
61 /* commit flags: tblk->xflag */
62 #define COMMIT_SYNC 0x0001 /* synchronous commit */
63 #define COMMIT_FORCE 0x0002 /* force pageout at end of commit */
64 #define COMMIT_FLUSH 0x0004 /* init flush at end of commit */
65 #define COMMIT_MAP 0x00f0
66 #define COMMIT_PMAP 0x0010 /* update pmap */
67 #define COMMIT_WMAP 0x0020 /* update wmap */
68 #define COMMIT_PWMAP 0x0040 /* update pwmap */
69 #define COMMIT_FREE 0x0f00
70 #define COMMIT_DELETE 0x0100 /* inode delete */
71 #define COMMIT_TRUNCATE 0x0200 /* file truncation */
72 #define COMMIT_CREATE 0x0400 /* inode create */
73 #define COMMIT_LAZY 0x0800 /* lazy commit */
74 #define COMMIT_PAGE 0x1000 /* Identifies element as metapage */
75 #define COMMIT_INODE 0x2000 /* Identifies element as inode */
77 /* group commit flags tblk->flag: see jfs_logmgr.h */
83 lid_t next
; /* 2: index next lockword on tid locklist
84 * next lockword on freelist
86 tid_t tid
; /* 2: transaction id holding lock */
88 u16 flag
; /* 2: lock control */
89 u16 type
; /* 2: log type */
91 struct metapage
*mp
; /* 4/8: object page buffer locked */
92 struct inode
*ip
; /* 4/8: object */
95 s16 lock
[24]; /* 48: overlay area */
98 extern struct tlock
*TxLock
; /* transaction lock table */
104 #define tlckPAGELOCK 0x8000
105 #define tlckINODELOCK 0x4000
106 #define tlckLINELOCK 0x2000
107 #define tlckINLINELOCK 0x1000
109 #define tlckLOG 0x0800
110 /* updateMap state */
111 #define tlckUPDATEMAP 0x0080
112 #define tlckDIRECTORY 0x0040
114 #define tlckFREELOCK 0x0008
115 #define tlckWRITEPAGE 0x0004
116 #define tlckFREEPAGE 0x0002
121 #define tlckTYPE 0xfe00
122 #define tlckINODE 0x8000
123 #define tlckXTREE 0x4000
124 #define tlckDTREE 0x2000
125 #define tlckMAP 0x1000
126 #define tlckEA 0x0800
127 #define tlckACL 0x0400
128 #define tlckDATA 0x0200
129 #define tlckBTROOT 0x0100
131 #define tlckOPERATION 0x00ff
132 #define tlckGROW 0x0001 /* file grow */
133 #define tlckREMOVE 0x0002 /* file delete */
134 #define tlckTRUNCATE 0x0004 /* file truncate */
135 #define tlckRELOCATE 0x0008 /* file/directory relocate */
136 #define tlckENTRY 0x0001 /* directory insert/delete */
137 #define tlckEXTEND 0x0002 /* directory extend in-line */
138 #define tlckSPLIT 0x0010 /* splited page */
139 #define tlckNEW 0x0020 /* new page from split */
140 #define tlckFREE 0x0040 /* free page */
141 #define tlckRELINK 0x0080 /* update sibling pointer */
144 * linelock for lmLog()
146 * note: linelock and its variations are overlaid
147 * at tlock.lock: watch for alignment;
154 #define TLOCKSHORT 20
158 lid_t next
; /* 2: next linelock */
165 u8 l2linesize
; /* 1: log2 of linesize */
168 struct lv lv
[20]; /* 40: */
171 #define dt_lock linelock
181 u8 l2linesize
; /* 1: log2 of linesize */
184 struct lv header
; /* 2: */
185 struct lv lwm
; /* 2: low water mark */
186 struct lv hwm
; /* 2: high water mark */
187 struct lv twm
; /* 2: */
190 s32 pxdlock
[8]; /* 32: */
195 * maplock for txUpdateMap()
197 * note: maplock and its variations are overlaid
198 * at tlock.lock/linelock: watch for alignment;
199 * N.B. next field may be set by linelock, and should not
200 * be modified by maplock;
201 * N.B. index of the first pxdlock specifies index of next
202 * free maplock (i.e., number of maplock) in the tlock;
208 u8 index
; /* 2: next free maplock index */
212 u8 count
; /* 1: number of pxd/xad */
219 #define mlckALLOC 0x00f0
220 #define mlckALLOCXADLIST 0x0080
221 #define mlckALLOCPXDLIST 0x0040
222 #define mlckALLOCXAD 0x0020
223 #define mlckALLOCPXD 0x0010
224 #define mlckFREE 0x000f
225 #define mlckFREEXADLIST 0x0008
226 #define mlckFREEPXDLIST 0x0004
227 #define mlckFREEXAD 0x0002
228 #define mlckFREEPXD 0x0001
230 #define pxd_lock maplock
240 u8 count
; /* 1: number of pxd/xad */
244 * We need xdlist to be 64 bits (8 bytes), regardless of
245 * whether void * is 32 or 64 bits
248 void *_xdlist
; /* pxd/xad list */
249 s64 pad
; /* 8: Force 64-bit xdlist size */
253 #define xdlist union64._xdlist
258 * parameter to the commit manager routines
261 tid_t tid
; /* tid = index of tblock */
262 int flag
; /* flags */
263 struct jfs_log
*log
; /* log */
264 struct super_block
*sb
; /* superblock */
266 int nip
; /* number of entries in iplist */
267 struct inode
**iplist
; /* list of pointers to inodes */
269 /* log record descriptor on 64-bit boundary */
270 struct lrd lrd
; /* : log record descriptor */
274 * external declarations
276 extern int jfs_tlocks_low
;
278 extern int txInit(void);
279 extern void txExit(void);
280 extern struct tlock
*txLock(tid_t
, struct inode
*, struct metapage
*, int);
281 extern struct tlock
*txMaplock(tid_t
, struct inode
*, int);
282 extern int txCommit(tid_t
, int, struct inode
**, int);
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 linelock
*);
288 extern void txFreeMap(struct inode
*, struct maplock
*, struct tblock
*, int);
289 extern void txEA(tid_t
, struct inode
*, dxd_t
*, dxd_t
*);
290 extern void txFreelock(struct inode
*);
291 extern int lmLog(struct jfs_log
*, struct tblock
*, struct lrd
*,
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_TXNMGR */