18 #ifndef __XFS_LOG_PRIV_H__
19 #define __XFS_LOG_PRIV_H__
30 #define XLOG_MIN_ICLOGS 2
31 #define XLOG_MAX_ICLOGS 8
32 #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe
33 #define XLOG_VERSION_1 1
34 #define XLOG_VERSION_2 2
35 #define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2)
36 #define XLOG_MIN_RECORD_BSIZE (16*1024)
37 #define XLOG_BIG_RECORD_BSIZE (32*1024)
38 #define XLOG_MAX_RECORD_BSIZE (256*1024)
39 #define XLOG_HEADER_CYCLE_SIZE (32*1024)
40 #define XLOG_MIN_RECORD_BSHIFT 14
41 #define XLOG_BIG_RECORD_BSHIFT 15
42 #define XLOG_MAX_RECORD_BSHIFT 18
43 #define XLOG_BTOLSUNIT(log, b) (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \
44 (log)->l_mp->m_sb.sb_logsunit)
45 #define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit)
47 #define XLOG_HEADER_SIZE 512
49 #define XLOG_REC_SHIFT(log) \
50 BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
51 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
52 #define XLOG_TOTAL_REC_SHIFT(log) \
53 BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
54 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
61 static inline uint xlog_get_cycle(
char *
ptr)
69 #define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1)
93 #define XLOG_STATE_ACTIVE 0x0001
94 #define XLOG_STATE_WANT_SYNC 0x0002
95 #define XLOG_STATE_SYNCING 0x0004
96 #define XLOG_STATE_DONE_SYNC 0x0008
97 #define XLOG_STATE_DO_CALLBACK \
99 #define XLOG_STATE_CALLBACK 0x0020
100 #define XLOG_STATE_DIRTY 0x0040
101 #define XLOG_STATE_IOERROR 0x0080
102 #define XLOG_STATE_ALL 0x7FFF
103 #define XLOG_STATE_NOTUSED 0x8000
117 #define XLOG_START_TRANS 0x01
118 #define XLOG_COMMIT_TRANS 0x02
119 #define XLOG_CONTINUE_TRANS 0x04
120 #define XLOG_WAS_CONT_TRANS 0x08
121 #define XLOG_END_TRANS 0x10
122 #define XLOG_UNMOUNT_TRANS 0x20
128 #define XLOG_TIC_INITED 0x1
129 #define XLOG_TIC_PERM_RESERV 0x2
131 #define XLOG_TIC_FLAGS \
132 { XLOG_TIC_INITED, "XLOG_TIC_INITED" }, \
133 { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" }
137 #define XLOG_UNMOUNT_TYPE 0x556e
142 #define XLOG_CHKSUM_MISMATCH 0x1
143 #define XLOG_ACTIVE_RECOVERY 0x2
144 #define XLOG_RECOVERY_NEEDED 0x4
145 #define XLOG_IO_ERROR 0x8
147 #define XLOG_TAIL_WARN 0x10
219 #define XLOG_STATE_COVER_IDLE 0
220 #define XLOG_STATE_COVER_NEED 1
221 #define XLOG_STATE_COVER_DONE 2
222 #define XLOG_STATE_COVER_NEED2 3
223 #define XLOG_STATE_COVER_DONE2 4
225 #define XLOG_COVER_OPS 5
229 #define XLOG_TIC_LEN_MAX 15
236 typedef struct xlog_res {
241 typedef struct xlog_ticket {
256 uint t_res_num_ophdrs;
259 xlog_res_t t_res_arr[XLOG_TIC_LEN_MAX];
275 #define XLOG_FMT_UNKNOWN 0
276 #define XLOG_FMT_LINUX_LE 1
277 #define XLOG_FMT_LINUX_BE 2
278 #define XLOG_FMT_IRIX_BE 3
281 #ifdef XFS_NATIVE_HOST
282 #define XLOG_FMT XLOG_FMT_LINUX_BE
284 #define XLOG_FMT XLOG_FMT_LINUX_LE
314 typedef union xlog_in_core2 {
349 typedef struct xlog_in_core {
352 struct xlog_in_core *ic_next;
353 struct xlog_in_core *ic_prev;
359 unsigned short ic_state;
369 xlog_in_core_2_t *ic_data;
370 #define ic_header ic_data->hic_header
386 struct xlog_ticket *ticket;
415 struct xfs_cil_ctx *xc_ctx;
471 #define XLOG_CIL_SPACE_LIMIT(log) (log->l_logsize >> 3)
472 #define XLOG_CIL_HARD_SPACE_LIMIT(log) (3 * (log->l_logsize >> 4))
478 struct xlog_grant_head {
492 struct xfs_mount *l_mp;
494 struct xfs_cil *l_cilp;
499 uint l_quotaoffs_flag;
505 int l_iclog_size_log;
507 xfs_daddr_t l_logBBstart;
516 xlog_in_core_t *l_iclog;
535 struct xlog_grant_head l_reserve_head;
536 struct xlog_grant_head l_write_head;
545 #define XLOG_BUF_CANCEL_BUCKET(log, blkno) \
546 ((log)->l_buf_cancel_table + ((__uint64_t)blkno % XLOG_BC_TABLE_SIZE))
548 #define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR)
560 struct xlog_in_core *iclog,
575 xlog_write_adv_cnt(
void **ptr,
int *len,
int *off,
size_t bytes)
587 struct xlog_ticket *tic,
589 struct xlog_in_core **commit_iclog,
623 xlog_crack_grant_head_val(int64_t
val,
int *cycle,
int *space)
626 *space = val & 0xffffffff;
632 xlog_crack_grant_head_val(
atomic64_read(head), cycle, space);
635 static inline int64_t
636 xlog_assign_grant_head_val(
int cycle,
int space)
638 return ((int64_t)cycle << 32) | space;
642 xlog_assign_grant_head(
atomic64_t *head,
int cycle,
int space)
644 atomic64_set(head, xlog_assign_grant_head_val(cycle, space));
666 xlog_cil_force(
struct xlog *
log)
675 #define XLOG_UNMOUNT_REC_TYPE (-1U)