]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_log_priv.h
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / include / xfs_log_priv.h
CommitLineData
2bd0ea18 1/*
0d3e0b37 2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
5000d01d 3 *
2bd0ea18
NS
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
5000d01d 7 *
2bd0ea18
NS
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5000d01d 11 *
2bd0ea18
NS
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
dfc130f3 14 * or the like. Any license provided herein, whether implied or
2bd0ea18
NS
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
5000d01d 18 *
2bd0ea18
NS
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
5000d01d 22 *
2bd0ea18
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
5000d01d
SL
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
2bd0ea18
NS
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
dfc130f3 32#ifndef __XFS_LOG_PRIV_H__
2bd0ea18
NS
33#define __XFS_LOG_PRIV_H__
34
35#if defined(XFS_ALL_TRACE)
dfc130f3 36#define XFS_LOG_TRACE
2bd0ea18
NS
37#endif
38
39#if !defined(DEBUG)
40#undef XFS_LOG_TRACE
41#endif
42
43struct xfs_buf;
44struct ktrace;
45struct log;
46struct xfs_buf_cancel;
47struct xfs_mount;
48
49/*
50 * Macros, structures, prototypes for internal log manager use.
51 */
52
53#define XLOG_NUM_ICLOGS 2
5ac5bb99 54#define XLOG_MAX_ICLOGS 8
2bd0ea18
NS
55#define XLOG_CALLBACK_SIZE 10
56#define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Illegal cycle number */
73bf5988
SL
57#define XLOG_VERSION_1 1
58#define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */
59#define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2)
2bd0ea18 60#define XLOG_RECORD_BSIZE (16*1024) /* eventually 32k */
73bf5988
SL
61#define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */
62#define XLOG_MAX_RECORD_BSIZE (256*1024)
63#define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */
2bd0ea18 64#define XLOG_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */
73bf5988
SL
65#define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */
66#define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */
2bd0ea18
NS
67#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_BTOLRBB)
68int xlog_btolrbb(int b);
69#define XLOG_BTOLRBB(b) xlog_btolrbb(b)
70#else
71#define XLOG_BTOLRBB(b) (((b)+XLOG_RECORD_BSIZE-1) >> XLOG_RECORD_BSHIFT)
72#endif
73
74#define XLOG_HEADER_SIZE 512
75
73bf5988
SL
76#define XLOG_TOTAL_REC_SHIFT(log) \
77 BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \
78 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
5000d01d 79
2bd0ea18
NS
80/*
81 * set lsns
82 */
83
84#define ASSIGN_LSN_CYCLE(lsn,cycle,arch) \
85 INT_SET(((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)], arch, (cycle));
86#define ASSIGN_LSN_BLOCK(lsn,block,arch) \
87 INT_SET(((uint *)&(lsn))[LSN_FIELD_BLOCK(arch)], arch, (block));
88#define ASSIGN_ANY_LSN(lsn,cycle,block,arch) \
89 { \
5000d01d
SL
90 ASSIGN_LSN_CYCLE(lsn,cycle,arch); \
91 ASSIGN_LSN_BLOCK(lsn,block,arch); \
2bd0ea18
NS
92 }
93#define ASSIGN_LSN(lsn,log,arch) \
94 ASSIGN_ANY_LSN(lsn,(log)->l_curr_cycle,(log)->l_curr_block,arch);
5000d01d 95
2bd0ea18
NS
96#define XLOG_SET(f,b) (((f) & (b)) == (b))
97
98#define GET_CYCLE(ptr, arch) \
99 (INT_GET(*(uint *)(ptr), arch) == XLOG_HEADER_MAGIC_NUM ? \
5000d01d
SL
100 INT_GET(*((uint *)(ptr)+1), arch) : \
101 INT_GET(*(uint *)(ptr), arch) \
2bd0ea18 102 )
5000d01d 103
2bd0ea18
NS
104#define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1)
105
106
107#ifdef __KERNEL__
108/*
109 * get client id from packed copy.
110 *
111 * this hack is here because the xlog_pack code copies four bytes
5000d01d 112 * of xlog_op_header containing the fields oh_clientid, oh_flags
2bd0ea18
NS
113 * and oh_res2 into the packed copy.
114 *
5000d01d 115 * later on this four byte chunk is treated as an int and the
2bd0ea18
NS
116 * client id is pulled out.
117 *
118 * this has endian issues, of course.
5000d01d 119 */
2bd0ea18
NS
120
121#if __BYTE_ORDER == __LITTLE_ENDIAN
122#define GET_CLIENT_ID(i,arch) \
123 ((i) & 0xff)
124#else
125#define GET_CLIENT_ID(i,arch) \
126 ((i) >> 24)
127#endif
73bf5988 128
2bd0ea18
NS
129#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_SUB_SPACE)
130void xlog_grant_sub_space(struct log *log, int bytes, int type);
131#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \
132 xlog_grant_sub_space(log,bytes,type)
133#else
134#define XLOG_GRANT_SUB_SPACE(log,bytes,type) \
135 { \
136 if (type == 'w') { \
137 (log)->l_grant_write_bytes -= (bytes); \
138 if ((log)->l_grant_write_bytes < 0) { \
dfc130f3 139 (log)->l_grant_write_bytes += (log)->l_logsize; \
2bd0ea18
NS
140 (log)->l_grant_write_cycle--; \
141 } \
142 } else { \
143 (log)->l_grant_reserve_bytes -= (bytes); \
144 if ((log)->l_grant_reserve_bytes < 0) { \
145 (log)->l_grant_reserve_bytes += (log)->l_logsize;\
146 (log)->l_grant_reserve_cycle--; \
147 } \
148 } \
149 }
150#endif
151#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XLOG_GRANT_ADD_SPACE)
152void xlog_grant_add_space(struct log *log, int bytes, int type);
153#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \
154 xlog_grant_add_space(log,bytes,type)
155#else
156#define XLOG_GRANT_ADD_SPACE(log,bytes,type) \
157 { \
158 if (type == 'w') { \
159 (log)->l_grant_write_bytes += (bytes); \
160 if ((log)->l_grant_write_bytes > (log)->l_logsize) { \
dfc130f3 161 (log)->l_grant_write_bytes -= (log)->l_logsize; \
2bd0ea18
NS
162 (log)->l_grant_write_cycle++; \
163 } \
164 } else { \
165 (log)->l_grant_reserve_bytes += (bytes); \
166 if ((log)->l_grant_reserve_bytes > (log)->l_logsize) { \
167 (log)->l_grant_reserve_bytes -= (log)->l_logsize;\
168 (log)->l_grant_reserve_cycle++; \
169 } \
170 } \
171 }
172#endif
173#define XLOG_INS_TICKETQ(q,tic) \
174 { \
175 if (q) { \
176 (tic)->t_next = (q); \
177 (tic)->t_prev = (q)->t_prev; \
178 (q)->t_prev->t_next = (tic); \
179 (q)->t_prev = (tic); \
180 } else { \
181 (tic)->t_prev = (tic)->t_next = (tic); \
182 (q) = (tic); \
183 } \
184 (tic)->t_flags |= XLOG_TIC_IN_Q; \
185 }
186#define XLOG_DEL_TICKETQ(q,tic) \
187 { \
188 if ((tic) == (tic)->t_next) { \
189 (q) = NULL; \
190 } else { \
191 (q) = (tic)->t_next; \
192 (tic)->t_next->t_prev = (tic)->t_prev; \
193 (tic)->t_prev->t_next = (tic)->t_next; \
194 } \
195 (tic)->t_next = (tic)->t_prev = NULL; \
196 (tic)->t_flags &= ~XLOG_TIC_IN_Q; \
197 }
198
199
200#define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock)
201#define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s)
202#define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock)
203#define LOG_UNLOCK(log, s) mutex_spinunlock(&(log)->l_icloglock, s)
204
205#define xlog_panic(s) {cmn_err(CE_PANIC, s); }
206#define xlog_exit(s) {cmn_err(CE_PANIC, s); }
207#define xlog_warn(s) {cmn_err(CE_WARN, s); }
208
209/*
210 * In core log state
211 */
212#define XLOG_STATE_ACTIVE 0x0001 /* Current IC log being written to */
213#define XLOG_STATE_WANT_SYNC 0x0002 /* Want to sync this iclog; no more writes */
214#define XLOG_STATE_SYNCING 0x0004 /* This IC log is syncing */
215#define XLOG_STATE_DONE_SYNC 0x0008 /* Done syncing to disk */
216#define XLOG_STATE_DO_CALLBACK \
217 0x0010 /* Process callback functions */
218#define XLOG_STATE_CALLBACK 0x0020 /* Callback functions now */
219#define XLOG_STATE_DIRTY 0x0040 /* Dirty IC log, not ready for ACTIVE status*/
220#define XLOG_STATE_IOERROR 0x0080 /* IO error happened in sync'ing log */
221#define XLOG_STATE_ALL 0x7FFF /* All possible valid flags */
222#define XLOG_STATE_NOTUSED 0x8000 /* This IC log not being used */
223#endif /* __KERNEL__ */
224
225/*
226 * Flags to log operation header
227 *
228 * The first write of a new transaction will be preceded with a start
229 * record, XLOG_START_TRANS. Once a transaction is committed, a commit
230 * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into
231 * the remainder of the current active in-core log, it is split up into
232 * multiple regions. Each partial region will be marked with a
233 * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS.
234 *
235 */
236#define XLOG_START_TRANS 0x01 /* Start a new transaction */
237#define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */
238#define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */
239#define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */
240#define XLOG_END_TRANS 0x10 /* End a continued transaction */
241#define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */
242#define XLOG_SKIP_TRANS (XLOG_COMMIT_TRANS | XLOG_CONTINUE_TRANS | \
243 XLOG_WAS_CONT_TRANS | XLOG_END_TRANS | \
244 XLOG_UNMOUNT_TRANS)
245
246#ifdef __KERNEL__
247/*
248 * Flags to log ticket
249 */
250#define XLOG_TIC_INITED 0x1 /* has been initialized */
251#define XLOG_TIC_PERM_RESERV 0x2 /* permanent reservation */
252#define XLOG_TIC_IN_Q 0x4
253#endif /* __KERNEL__ */
254
255#define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
256
257/*
258 * Flags for log structure
259 */
260#define XLOG_CHKSUM_MISMATCH 0x1 /* used only during recovery */
261#define XLOG_ACTIVE_RECOVERY 0x2 /* in the middle of recovery */
dfc130f3 262#define XLOG_RECOVERY_NEEDED 0x4 /* log was recovered */
2bd0ea18
NS
263#define XLOG_IO_ERROR 0x8 /* log hit an I/O error, and being
264 shutdown */
265typedef __uint32_t xlog_tid_t;
266
267
268#ifdef __KERNEL__
269/*
270 * Below are states for covering allocation transactions.
271 * By covering, we mean changing the h_tail_lsn in the last on-disk
272 * log write such that no allocation transactions will be re-done during
273 * recovery after a system crash. Recovery starts at the last on-disk
274 * log write.
275 *
276 * These states are used to insert dummy log entries to cover
277 * space allocation transactions which can undo non-transactional changes
278 * after a crash. Writes to a file with space
279 * already allocated do not result in any transactions. Allocations
280 * might include space beyond the EOF. So if we just push the EOF a
281 * little, the last transaction for the file could contain the wrong
282 * size. If there is no file system activity, after an allocation
283 * transaction, and the system crashes, the allocation transaction
284 * will get replayed and the file will be truncated. This could
285 * be hours/days/... after the allocation occurred.
286 *
287 * The fix for this is to do two dummy transactions when the
288 * system is idle. We need two dummy transaction because the h_tail_lsn
289 * in the log record header needs to point beyond the last possible
290 * non-dummy transaction. The first dummy changes the h_tail_lsn to
291 * the first transaction before the dummy. The second dummy causes
292 * h_tail_lsn to point to the first dummy. Recovery starts at h_tail_lsn.
5000d01d 293 *
2bd0ea18
NS
294 * These dummy transactions get committed when everything
295 * is idle (after there has been some activity).
296 *
297 * There are 5 states used to control this.
298 *
299 * IDLE -- no logging has been done on the file system or
300 * we are done covering previous transactions.
301 * NEED -- logging has occurred and we need a dummy transaction
302 * when the log becomes idle.
303 * DONE -- we were in the NEED state and have committed a dummy
304 * transaction.
305 * NEED2 -- we detected that a dummy transaction has gone to the
306 * on disk log with no other transactions.
307 * DONE2 -- we committed a dummy transaction when in the NEED2 state.
308 *
309 * There are two places where we switch states:
310 *
311 * 1.) In xfs_sync, when we detect an idle log and are in NEED or NEED2.
312 * We commit the dummy transaction and switch to DONE or DONE2,
5000d01d 313 * respectively. In all other states, we don't do anything.
2bd0ea18
NS
314 *
315 * 2.) When we finish writing the on-disk log (xlog_state_clean_log).
316 *
317 * No matter what state we are in, if this isn't the dummy
318 * transaction going out, the next state is NEED.
319 * So, if we aren't in the DONE or DONE2 states, the next state
320 * is NEED. We can't be finishing a write of the dummy record
321 * unless it was committed and the state switched to DONE or DONE2.
5000d01d 322 *
2bd0ea18
NS
323 * If we are in the DONE state and this was a write of the
324 * dummy transaction, we move to NEED2.
325 *
326 * If we are in the DONE2 state and this was a write of the
327 * dummy transaction, we move to IDLE.
328 *
329 *
330 * Writing only one dummy transaction can get appended to
331 * one file space allocation. When this happens, the log recovery
332 * code replays the space allocation and a file could be truncated.
333 * This is why we have the NEED2 and DONE2 states before going idle.
334 */
335
336#define XLOG_STATE_COVER_IDLE 0
337#define XLOG_STATE_COVER_NEED 1
338#define XLOG_STATE_COVER_DONE 2
339#define XLOG_STATE_COVER_NEED2 3
340#define XLOG_STATE_COVER_DONE2 4
341
342#define XLOG_COVER_OPS 5
343
344typedef struct xlog_ticket {
345 sv_t t_sema; /* sleep on this semaphore :20 */
dfc130f3 346 struct xlog_ticket *t_next; /* : 4 */
2bd0ea18
NS
347 struct xlog_ticket *t_prev; /* : 4 */
348 xlog_tid_t t_tid; /* transaction identifier : 4 */
349 int t_curr_res; /* current reservation in bytes : 4 */
dfc130f3 350 int t_unit_res; /* unit reservation in bytes : 4 */
a7565da0
NS
351 __uint8_t t_ocnt; /* original count : 1 */
352 __uint8_t t_cnt; /* current count : 1 */
353 __uint8_t t_clientid; /* who does this belong to; : 1 */
354 __uint8_t t_flags; /* properties of reservation : 1 */
2bd0ea18
NS
355} xlog_ticket_t;
356#endif
357
358
359typedef struct xlog_op_header {
360 xlog_tid_t oh_tid; /* transaction id of operation : 4 b */
73bf5988 361 int oh_len; /* bytes in data region : 4 b */
dfc130f3 362 __uint8_t oh_clientid; /* who sent me this : 1 b */
5000d01d 363 __uint8_t oh_flags; /* : 1 b */
2bd0ea18
NS
364 ushort oh_res2; /* 32 bit align : 2 b */
365} xlog_op_header_t;
366
367
368/* valid values for h_fmt */
369#define XLOG_FMT_UNKNOWN 0
370#define XLOG_FMT_LINUX_LE 1
371#define XLOG_FMT_LINUX_BE 2
372#define XLOG_FMT_IRIX_BE 3
373
374/* our fmt */
375#if __BYTE_ORDER == __LITTLE_ENDIAN
376#define XLOG_FMT XLOG_FMT_LINUX_LE
377#else
378#if __BYTE_ORDER == __BIG_ENDIAN
379#define XLOG_FMT XLOG_FMT_LINUX_BE
380#else
381#error unknown byte order
382#endif
383#endif
384
385typedef struct xlog_rec_header {
386 uint h_magicno; /* log record (LR) identifier : 4 */
387 uint h_cycle; /* write cycle of log : 4 */
388 int h_version; /* LR version : 4 */
389 int h_len; /* len in bytes; should be 64-bit aligned: 4 */
390 xfs_lsn_t h_lsn; /* lsn of this LR : 8 */
391 xfs_lsn_t h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */
392 uint h_chksum; /* may not be used; non-zero if used : 4 */
393 int h_prev_block; /* block number to previous LR : 4 */
dfc130f3 394 int h_num_logops; /* number of log operations in this LR : 4 */
5000d01d
SL
395 uint h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
396 /* new fields */
dfc130f3
RC
397 int h_fmt; /* format of log record : 4 */
398 uuid_t h_fs_uuid; /* uuid of FS : 16 */
399 int h_size; /* iclog size : 4 */
2bd0ea18
NS
400} xlog_rec_header_t;
401
73bf5988
SL
402typedef struct xlog_rec_ext_header {
403 uint xh_cycle; /* write cycle of log : 4 */
404 uint xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
405} xlog_rec_ext_header_t;
2bd0ea18
NS
406#ifdef __KERNEL__
407/*
dfc130f3 408 * - A log record header is 512 bytes. There is plenty of room to grow the
2bd0ea18
NS
409 * xlog_rec_header_t into the reserved space.
410 * - ic_data follows, so a write to disk can start at the beginning of
411 * the iclog.
412 * - ic_forcesema is used to implement synchronous forcing of the iclog to disk.
413 * - ic_next is the pointer to the next iclog in the ring.
414 * - ic_bp is a pointer to the buffer used to write this incore log to disk.
415 * - ic_log is a pointer back to the global log structure.
416 * - ic_callback is a linked list of callback function/argument pairs to be
417 * called after an iclog finishes writing.
418 * - ic_size is the full size of the header plus data.
419 * - ic_offset is the current number of bytes written to in this iclog.
420 * - ic_refcnt is bumped when someone is writing to the log.
421 * - ic_state is the state of the iclog.
422 */
423typedef struct xlog_iclog_fields {
424 sv_t ic_forcesema;
f9e56f43 425 sv_t ic_writesema;
2bd0ea18
NS
426 struct xlog_in_core *ic_next;
427 struct xlog_in_core *ic_prev;
5000d01d 428 struct xfs_buf *ic_bp;
2bd0ea18
NS
429 struct log *ic_log;
430 xfs_log_callback_t *ic_callback;
431 xfs_log_callback_t **ic_callback_tail;
432#ifdef DEBUG
433 struct ktrace *ic_trace;
434#endif
5000d01d
SL
435 int ic_size;
436 int ic_offset;
437 int ic_refcnt;
2bd0ea18
NS
438 int ic_roundoff;
439 int ic_bwritecnt;
440 ushort_t ic_state;
73bf5988 441 char *ic_datap; /* pointer to iclog data */
2bd0ea18
NS
442} xlog_iclog_fields_t;
443
b7d5131f 444typedef struct xlog_in_core2 {
2bd0ea18
NS
445 union {
446 xlog_rec_header_t hic_header;
73bf5988 447 xlog_rec_ext_header_t hic_xheader;
2bd0ea18 448 char hic_sector[XLOG_HEADER_SIZE];
b7d5131f 449 } ic_h;
b7d5131f
SL
450} xlog_in_core_2_t;
451
452typedef struct xlog_in_core {
453 xlog_iclog_fields_t hic_fields;
454 xlog_in_core_2_t *hic_data;
2bd0ea18
NS
455} xlog_in_core_t;
456
457/*
458 * Defines to save our code from this glop.
459 */
dfc130f3 460#define ic_forcesema hic_fields.ic_forcesema
f9e56f43 461#define ic_writesema hic_fields.ic_writesema
dfc130f3
RC
462#define ic_next hic_fields.ic_next
463#define ic_prev hic_fields.ic_prev
464#define ic_bp hic_fields.ic_bp
465#define ic_log hic_fields.ic_log
466#define ic_callback hic_fields.ic_callback
467#define ic_callback_tail hic_fields.ic_callback_tail
468#define ic_trace hic_fields.ic_trace
469#define ic_size hic_fields.ic_size
470#define ic_offset hic_fields.ic_offset
471#define ic_refcnt hic_fields.ic_refcnt
472#define ic_roundoff hic_fields.ic_roundoff
473#define ic_bwritecnt hic_fields.ic_bwritecnt
474#define ic_state hic_fields.ic_state
73bf5988 475#define ic_datap hic_fields.ic_datap
b7d5131f 476#define ic_header hic_data->ic_h.hic_header
2bd0ea18
NS
477
478/*
479 * The reservation head lsn is not made up of a cycle number and block number.
480 * Instead, it uses a cycle number and byte number. Logs don't expect to
481 * overflow 31 bits worth of byte offset, so using a byte number will mean
482 * that round off problems won't occur when releasing partial reservations.
483 */
484typedef struct log {
485 /* The following block of fields are changed while holding icloglock */
dfc130f3 486 sema_t l_flushsema; /* iclog flushing semaphore */
2bd0ea18
NS
487 int l_flushcnt; /* # of procs waiting on this sema */
488 int l_ticket_cnt; /* free ticket count */
489 int l_ticket_tcnt; /* total ticket count */
490 int l_covered_state;/* state of "covering disk log entries" */
dfc130f3 491 xlog_ticket_t *l_freelist; /* free list of tickets */
2bd0ea18 492 xlog_ticket_t *l_unmount_free;/* kmem_free these addresses */
dfc130f3
RC
493 xlog_ticket_t *l_tail; /* free list of tickets */
494 xlog_in_core_t *l_iclog; /* head log queue */
495 lock_t l_icloglock; /* grab to change iclog state */
496 xfs_lsn_t l_tail_lsn; /* lsn of 1st LR w/ unflush buffers */
2bd0ea18 497 xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */
dfc130f3
RC
498 struct xfs_mount *l_mp; /* mount point */
499 struct xfs_buf *l_xbuf; /* extra buffer for log wrapping */
500 dev_t l_dev; /* dev_t of log */
501 xfs_daddr_t l_logBBstart; /* start block of log */
502 int l_logsize; /* size of log in bytes */
503 int l_logBBsize; /* size of log in 512 byte chunks */
2bd0ea18 504 int l_roundoff; /* round off error of all iclogs */
dfc130f3
RC
505 int l_curr_cycle; /* Cycle number of log writes */
506 int l_prev_cycle; /* Cycle # b4 last block increment */
507 int l_curr_block; /* current logical block of log */
508 int l_prev_block; /* previous logical block of log */
2bd0ea18
NS
509 int l_iclog_size; /* size of log in bytes */
510 int l_iclog_size_log;/* log power size of log */
511 int l_iclog_bufs; /* number of iclog buffers */
512
513 /* The following field are used for debugging; need to hold icloglock */
514 char *l_iclog_bak[XLOG_MAX_ICLOGS];
515
516 /* The following block of fields are changed while holding grant_lock */
517 lock_t l_grant_lock; /* protects below fields */
518 xlog_ticket_t *l_reserve_headq; /* */
519 xlog_ticket_t *l_write_headq; /* */
520 int l_grant_reserve_cycle; /* */
521 int l_grant_reserve_bytes; /* */
522 int l_grant_write_cycle; /* */
523 int l_grant_write_bytes; /* */
524
525 /* The following fields don't need locking */
526#ifdef DEBUG
527 struct ktrace *l_trace;
528 struct ktrace *l_grant_trace;
529#endif
530 uint l_flags;
531 uint l_quotaoffs_flag;/* XFS_DQ_*, if QUOTAOFFs found */
5000d01d 532 struct xfs_buf_cancel **l_buf_cancel_table;
dfc130f3
RC
533 int l_iclog_hsize; /* size of iclog header */
534 int l_iclog_heads; /* number of iclog header sectors */
2bd0ea18
NS
535} xlog_t;
536
537
538/* common routines */
4ca431fc 539extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
2bd0ea18
NS
540extern int xlog_find_head(xlog_t *log, xfs_daddr_t *head_blk);
541extern int xlog_find_tail(xlog_t *log,
542 xfs_daddr_t *head_blk,
543 xfs_daddr_t *tail_blk,
544 int readonly);
545extern int xlog_print_find_oldest(xlog_t *log, xfs_daddr_t *last_blk);
546extern int xlog_recover(xlog_t *log, int readonly);
547extern int xlog_recover_finish(xlog_t *log, int mfsi_flags);
548extern void xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog);
549extern struct xfs_buf *xlog_get_bp(int,xfs_mount_t *);
550extern void xlog_put_bp(struct xfs_buf *);
551extern int xlog_bread(xlog_t *, xfs_daddr_t blkno, int bblks, struct xfs_buf *bp);
552extern void xlog_recover_process_iunlinks(xlog_t *log);
553
554#define XLOG_TRACE_GRAB_FLUSH 1
555#define XLOG_TRACE_REL_FLUSH 2
556#define XLOG_TRACE_SLEEP_FLUSH 3
557#define XLOG_TRACE_WAKE_FLUSH 4
558
559#endif /* __KERNEL__ */
560
561#endif /* __XFS_LOG_PRIV_H__ */