diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-08-12 06:49:22 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-12 17:03:51 -0400 |
commit | fc06c6d064dd50f7aa157065ef79216190d75c91 (patch) | |
tree | 014e558cfc5a9c55a795e0988b4e320a0a8f60df /fs/xfs/xfs_log_priv.h | |
parent | 7a378c9aeab3782a5f998c17313bc7027cee3454 (diff) |
xfs: separate out log format definitions
The on-disk format definitions for the log are spread randoms
through a couple of header files. Consolidate it all in a single
file that can be shared easily with userspace. This means that
xfs_log.h and xfs_log_priv.h no longer need to be shared with
userspace.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_log_priv.h')
-rw-r--r-- | fs/xfs/xfs_log_priv.h | 146 |
1 files changed, 6 insertions, 140 deletions
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index b9ea262dd1c2..edd0964fb65c 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -24,51 +24,13 @@ struct xlog_ticket; | |||
24 | struct xfs_mount; | 24 | struct xfs_mount; |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Macros, structures, prototypes for internal log manager use. | 27 | * Flags for log structure |
28 | */ | 28 | */ |
29 | 29 | #define XLOG_ACTIVE_RECOVERY 0x2 /* in the middle of recovery */ | |
30 | #define XLOG_MIN_ICLOGS 2 | 30 | #define XLOG_RECOVERY_NEEDED 0x4 /* log was recovered */ |
31 | #define XLOG_MAX_ICLOGS 8 | 31 | #define XLOG_IO_ERROR 0x8 /* log hit an I/O error, and being |
32 | #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */ | 32 | shutdown */ |
33 | #define XLOG_VERSION_1 1 | 33 | #define XLOG_TAIL_WARN 0x10 /* log tail verify warning issued */ |
34 | #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */ | ||
35 | #define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2) | ||
36 | #define XLOG_MIN_RECORD_BSIZE (16*1024) /* eventually 32k */ | ||
37 | #define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */ | ||
38 | #define XLOG_MAX_RECORD_BSIZE (256*1024) | ||
39 | #define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */ | ||
40 | #define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */ | ||
41 | #define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */ | ||
42 | #define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 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) | ||
46 | |||
47 | #define XLOG_HEADER_SIZE 512 | ||
48 | |||
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)) | ||
55 | |||
56 | static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block) | ||
57 | { | ||
58 | return ((xfs_lsn_t)cycle << 32) | block; | ||
59 | } | ||
60 | |||
61 | static inline uint xlog_get_cycle(char *ptr) | ||
62 | { | ||
63 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) | ||
64 | return be32_to_cpu(*((__be32 *)ptr + 1)); | ||
65 | else | ||
66 | return be32_to_cpu(*(__be32 *)ptr); | ||
67 | } | ||
68 | |||
69 | #define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1) | ||
70 | |||
71 | #ifdef __KERNEL__ | ||
72 | 34 | ||
73 | /* | 35 | /* |
74 | * get client id from packed copy. | 36 | * get client id from packed copy. |
@@ -101,28 +63,8 @@ static inline uint xlog_get_client_id(__be32 i) | |||
101 | #define XLOG_STATE_IOERROR 0x0080 /* IO error happened in sync'ing log */ | 63 | #define XLOG_STATE_IOERROR 0x0080 /* IO error happened in sync'ing log */ |
102 | #define XLOG_STATE_ALL 0x7FFF /* All possible valid flags */ | 64 | #define XLOG_STATE_ALL 0x7FFF /* All possible valid flags */ |
103 | #define XLOG_STATE_NOTUSED 0x8000 /* This IC log not being used */ | 65 | #define XLOG_STATE_NOTUSED 0x8000 /* This IC log not being used */ |
104 | #endif /* __KERNEL__ */ | ||
105 | 66 | ||
106 | /* | 67 | /* |
107 | * Flags to log operation header | ||
108 | * | ||
109 | * The first write of a new transaction will be preceded with a start | ||
110 | * record, XLOG_START_TRANS. Once a transaction is committed, a commit | ||
111 | * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into | ||
112 | * the remainder of the current active in-core log, it is split up into | ||
113 | * multiple regions. Each partial region will be marked with a | ||
114 | * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. | ||
115 | * | ||
116 | */ | ||
117 | #define XLOG_START_TRANS 0x01 /* Start a new transaction */ | ||
118 | #define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */ | ||
119 | #define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */ | ||
120 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ | ||
121 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ | ||
122 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ | ||
123 | |||
124 | #ifdef __KERNEL__ | ||
125 | /* | ||
126 | * Flags to log ticket | 68 | * Flags to log ticket |
127 | */ | 69 | */ |
128 | #define XLOG_TIC_INITED 0x1 /* has been initialized */ | 70 | #define XLOG_TIC_INITED 0x1 /* has been initialized */ |
@@ -132,22 +74,6 @@ static inline uint xlog_get_client_id(__be32 i) | |||
132 | { XLOG_TIC_INITED, "XLOG_TIC_INITED" }, \ | 74 | { XLOG_TIC_INITED, "XLOG_TIC_INITED" }, \ |
133 | { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" } | 75 | { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" } |
134 | 76 | ||
135 | #endif /* __KERNEL__ */ | ||
136 | |||
137 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ | ||
138 | |||
139 | /* | ||
140 | * Flags for log structure | ||
141 | */ | ||
142 | #define XLOG_ACTIVE_RECOVERY 0x2 /* in the middle of recovery */ | ||
143 | #define XLOG_RECOVERY_NEEDED 0x4 /* log was recovered */ | ||
144 | #define XLOG_IO_ERROR 0x8 /* log hit an I/O error, and being | ||
145 | shutdown */ | ||
146 | #define XLOG_TAIL_WARN 0x10 /* log tail verify warning issued */ | ||
147 | |||
148 | typedef __uint32_t xlog_tid_t; | ||
149 | |||
150 | #ifdef __KERNEL__ | ||
151 | /* | 77 | /* |
152 | * Below are states for covering allocation transactions. | 78 | * Below are states for covering allocation transactions. |
153 | * By covering, we mean changing the h_tail_lsn in the last on-disk | 79 | * By covering, we mean changing the h_tail_lsn in the last on-disk |
@@ -223,7 +149,6 @@ typedef __uint32_t xlog_tid_t; | |||
223 | 149 | ||
224 | #define XLOG_COVER_OPS 5 | 150 | #define XLOG_COVER_OPS 5 |
225 | 151 | ||
226 | |||
227 | /* Ticket reservation region accounting */ | 152 | /* Ticket reservation region accounting */ |
228 | #define XLOG_TIC_LEN_MAX 15 | 153 | #define XLOG_TIC_LEN_MAX 15 |
229 | 154 | ||
@@ -258,64 +183,6 @@ typedef struct xlog_ticket { | |||
258 | xlog_res_t t_res_arr[XLOG_TIC_LEN_MAX]; /* array of res : 8 * 15 */ | 183 | xlog_res_t t_res_arr[XLOG_TIC_LEN_MAX]; /* array of res : 8 * 15 */ |
259 | } xlog_ticket_t; | 184 | } xlog_ticket_t; |
260 | 185 | ||
261 | #endif | ||
262 | |||
263 | |||
264 | typedef struct xlog_op_header { | ||
265 | __be32 oh_tid; /* transaction id of operation : 4 b */ | ||
266 | __be32 oh_len; /* bytes in data region : 4 b */ | ||
267 | __u8 oh_clientid; /* who sent me this : 1 b */ | ||
268 | __u8 oh_flags; /* : 1 b */ | ||
269 | __u16 oh_res2; /* 32 bit align : 2 b */ | ||
270 | } xlog_op_header_t; | ||
271 | |||
272 | |||
273 | /* valid values for h_fmt */ | ||
274 | #define XLOG_FMT_UNKNOWN 0 | ||
275 | #define XLOG_FMT_LINUX_LE 1 | ||
276 | #define XLOG_FMT_LINUX_BE 2 | ||
277 | #define XLOG_FMT_IRIX_BE 3 | ||
278 | |||
279 | /* our fmt */ | ||
280 | #ifdef XFS_NATIVE_HOST | ||
281 | #define XLOG_FMT XLOG_FMT_LINUX_BE | ||
282 | #else | ||
283 | #define XLOG_FMT XLOG_FMT_LINUX_LE | ||
284 | #endif | ||
285 | |||
286 | typedef struct xlog_rec_header { | ||
287 | __be32 h_magicno; /* log record (LR) identifier : 4 */ | ||
288 | __be32 h_cycle; /* write cycle of log : 4 */ | ||
289 | __be32 h_version; /* LR version : 4 */ | ||
290 | __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */ | ||
291 | __be64 h_lsn; /* lsn of this LR : 8 */ | ||
292 | __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ | ||
293 | __le32 h_crc; /* crc of log record : 4 */ | ||
294 | __be32 h_prev_block; /* block number to previous LR : 4 */ | ||
295 | __be32 h_num_logops; /* number of log operations in this LR : 4 */ | ||
296 | __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; | ||
297 | /* new fields */ | ||
298 | __be32 h_fmt; /* format of log record : 4 */ | ||
299 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ | ||
300 | __be32 h_size; /* iclog size : 4 */ | ||
301 | } xlog_rec_header_t; | ||
302 | |||
303 | typedef struct xlog_rec_ext_header { | ||
304 | __be32 xh_cycle; /* write cycle of log : 4 */ | ||
305 | __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ | ||
306 | } xlog_rec_ext_header_t; | ||
307 | |||
308 | #ifdef __KERNEL__ | ||
309 | |||
310 | /* | ||
311 | * Quite misnamed, because this union lays out the actual on-disk log buffer. | ||
312 | */ | ||
313 | typedef union xlog_in_core2 { | ||
314 | xlog_rec_header_t hic_header; | ||
315 | xlog_rec_ext_header_t hic_xheader; | ||
316 | char hic_sector[XLOG_HEADER_SIZE]; | ||
317 | } xlog_in_core_2_t; | ||
318 | |||
319 | /* | 186 | /* |
320 | * - A log record header is 512 bytes. There is plenty of room to grow the | 187 | * - A log record header is 512 bytes. There is plenty of room to grow the |
321 | * xlog_rec_header_t into the reserved space. | 188 | * xlog_rec_header_t into the reserved space. |
@@ -686,6 +553,5 @@ static inline void xlog_wait(wait_queue_head_t *wq, spinlock_t *lock) | |||
686 | schedule(); | 553 | schedule(); |
687 | remove_wait_queue(wq, &wait); | 554 | remove_wait_queue(wq, &wait); |
688 | } | 555 | } |
689 | #endif /* __KERNEL__ */ | ||
690 | 556 | ||
691 | #endif /* __XFS_LOG_PRIV_H__ */ | 557 | #endif /* __XFS_LOG_PRIV_H__ */ |