1 /*
2 * Copyright (c) International Business Machines Corp., 2000-2002
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 tblock *cqnext; /* commit queue link */
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 struct inode *ip; /* inode being created or deleted */
66 };
67
68 extern struct tblock *TxBlock; /* transaction block table */
69
70 /* commit flags: tblk->xflag */
71 #define COMMIT_SYNC 0x0001 /* synchronous commit */
72 #define COMMIT_FORCE 0x0002 /* force pageout at end of commit */
73 #define COMMIT_FLUSH 0x0004 /* init flush at end of commit */
74 #define COMMIT_MAP 0x00f0
75 #define COMMIT_PMAP 0x0010 /* update pmap */
76 #define COMMIT_WMAP 0x0020 /* update wmap */
77 #define COMMIT_PWMAP 0x0040 /* update pwmap */
78 #define COMMIT_FREE 0x0f00
79 #define COMMIT_DELETE 0x0100 /* inode delete */
80 #define COMMIT_TRUNCATE 0x0200 /* file truncation */
81 #define COMMIT_CREATE 0x0400 /* inode create */
82 #define COMMIT_LAZY 0x0800 /* lazy commit */
83 #define COMMIT_PAGE 0x1000 /* Identifies element as metapage */
84 #define COMMIT_INODE 0x2000 /* Identifies element as inode */
85
86 /* group commit flags tblk->flag: see jfs_logmgr.h */
87
88 /*
89 * transaction lock
90 */
91 struct tlock {
92 lid_t next; /* index next lockword on tid locklist
93 * next lockword on freelist
94 */
95 tid_t tid; /* transaction id holding lock */
96
97 u16 flag; /* 2: lock control */
98 u16 type; /* 2: log type */
99
100 struct metapage *mp; /* 4: object page buffer locked */
101 struct inode *ip; /* 4: object */
102 /* (16) */
103
104 s16 lock[24]; /* 48: overlay area */
105 }; /* (64) */
106
107 extern struct tlock *TxLock; /* transaction lock table */
108
109 /*
110 * tlock flag
111 */
112 /* txLock state */
113 #define tlckPAGELOCK 0x8000
114 #define tlckINODELOCK 0x4000
115 #define tlckLINELOCK 0x2000
116 #define tlckINLINELOCK 0x1000
117 /* lmLog state */
118 #define tlckLOG 0x0800
119 /* updateMap state */
120 #define tlckUPDATEMAP 0x0080
121 /* freeLock state */
122 #define tlckFREELOCK 0x0008
123 #define tlckWRITEPAGE 0x0004
124 #define tlckFREEPAGE 0x0002
125
126 /*
127 * tlock type
128 */
129 #define tlckTYPE 0xfe00
130 #define tlckINODE 0x8000
131 #define tlckXTREE 0x4000
132 #define tlckDTREE 0x2000
133 #define tlckMAP 0x1000
134 #define tlckEA 0x0800
135 #define tlckACL 0x0400
136 #define tlckDATA 0x0200
137 #define tlckBTROOT 0x0100
138
139 #define tlckOPERATION 0x00ff
140 #define tlckGROW 0x0001 /* file grow */
141 #define tlckREMOVE 0x0002 /* file delete */
142 #define tlckTRUNCATE 0x0004 /* file truncate */
143 #define tlckRELOCATE 0x0008 /* file/directory relocate */
144 #define tlckENTRY 0x0001 /* directory insert/delete */
145 #define tlckEXTEND 0x0002 /* directory extend in-line */
146 #define tlckSPLIT 0x0010 /* splited page */
147 #define tlckNEW 0x0020 /* new page from split */
148 #define tlckFREE 0x0040 /* free page */
149 #define tlckRELINK 0x0080 /* update sibling pointer */
150
151 /*
152 * linelock for lmLog()
153 *
154 * note: linelock and its variations are overlaid
155 * at tlock.lock: watch for alignment;
156 */
157 struct lv {
158 u8 offset; /* 1: */
159 u8 length; /* 1: */
160 }; /* (2) */
161
162 #define TLOCKSHORT 20
163 #define TLOCKLONG 28
164
165 struct linelock {
166 u16 next; /* 2: next linelock */
167
168 s8 maxcnt; /* 1: */
169 s8 index; /* 1: */
170
171 u16 flag; /* 2: */
172 u8 type; /* 1: */
173 u8 l2linesize; /* 1: log2 of linesize */
174 /* (8) */
175
176 struct lv lv[20]; /* 40: */
177 }; /* (48) */
178
179 #define dt_lock linelock
180
181 struct xtlock {
182 u16 next; /* 2: */
183
184 s8 maxcnt; /* 1: */
185 s8 index; /* 1: */
186
187 u16 flag; /* 2: */
188 u8 type; /* 1: */
189 u8 l2linesize; /* 1: log2 of linesize */
190 /* (8) */
191
192 struct lv header; /* 2: */
193 struct lv lwm; /* 2: low water mark */
194 struct lv hwm; /* 2: high water mark */
195 struct lv twm; /* 2: */
196 /* (16) */
197
198 s32 pxdlock[8]; /* 32: */
199 }; /* (48) */
200
201
202 /*
203 * maplock for txUpdateMap()
204 *
205 * note: maplock and its variations are overlaid
206 * at tlock.lock/linelock: watch for alignment;
207 * N.B. next field may be set by linelock, and should not
208 * be modified by maplock;
209 * N.B. index of the first pxdlock specifies index of next
210 * free maplock (i.e., number of maplock) in the tlock;
211 */
212 struct maplock {
213 u16 next; /* 2: */
214
215 u8 maxcnt; /* 2: */
216 u8 index; /* 2: next free maplock index */
217
218 u16 flag; /* 2: */
219 u8 type; /* 1: */
220 u8 count; /* 1: number of pxd/xad */
221 /* (8) */
222
223 pxd_t pxd; /* 8: */
224 }; /* (16): */
225
226 /* maplock flag */
227 #define mlckALLOC 0x00f0
228 #define mlckALLOCXADLIST 0x0080
229 #define mlckALLOCPXDLIST 0x0040
230 #define mlckALLOCXAD 0x0020
231 #define mlckALLOCPXD 0x0010
232 #define mlckFREE 0x000f
233 #define mlckFREEXADLIST 0x0008
234 #define mlckFREEPXDLIST 0x0004
235 #define mlckFREEXAD 0x0002
236 #define mlckFREEPXD 0x0001
237
238 #define pxd_lock maplock
239
240 struct xdlistlock {
241 u16 next; /* 2: */
242
243 u8 maxcnt; /* 2: */
244 u8 index; /* 2: */
245
246 u16 flag; /* 2: */
247 u8 type; /* 1: */
248 u8 count; /* 1: number of pxd/xad */
249 /* (8) */
250
251 /*
252 * We need xdlist to be 64 bits (8 bytes), regardless of
253 * whether void * is 32 or 64 bits
254 */
255 union {
256 void *_xdlist; /* pxd/xad list */
257 s64 pad; /* 8: Force 64-bit xdlist size */
258 } union64;
259 }; /* (16): */
260
261 #define xdlist union64._xdlist
262
263 /*
264 * commit
265 *
266 * parameter to the commit manager routines
267 */
268 struct commit {
269 tid_t tid; /* tid = index of tblock */
270 int flag; /* flags */
271 struct jfs_log *log; /* log */
272 struct super_block *sb; /* superblock */
273
274 int nip; /* number of entries in iplist */
275 struct inode **iplist; /* list of pointers to inodes */
276
277 /* log record descriptor on 64-bit boundary */
278 struct lrd lrd; /* : log record descriptor */
279 };
280
281 /*
282 * external declarations
283 */
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);
312
313 extern void txResume(struct super_block *sb);
314 #endif /* _H_JFS_TXNMGR */
Cache object: 3d8dd387e10b4aca34f72a61b4073d2f
|