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_format.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_format.h')
-rw-r--r-- | fs/xfs/xfs_log_format.h | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/fs/xfs/xfs_log_format.h b/fs/xfs/xfs_log_format.h new file mode 100644 index 000000000000..9f9aeb63545a --- /dev/null +++ b/fs/xfs/xfs_log_format.h | |||
@@ -0,0 +1,178 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * 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 the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_LOG_FORMAT_H__ | ||
19 | #define __XFS_LOG_FORMAT_H__ | ||
20 | |||
21 | typedef __uint32_t xlog_tid_t; | ||
22 | |||
23 | #define XLOG_MIN_ICLOGS 2 | ||
24 | #define XLOG_MAX_ICLOGS 8 | ||
25 | #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */ | ||
26 | #define XLOG_VERSION_1 1 | ||
27 | #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */ | ||
28 | #define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2) | ||
29 | #define XLOG_MIN_RECORD_BSIZE (16*1024) /* eventually 32k */ | ||
30 | #define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */ | ||
31 | #define XLOG_MAX_RECORD_BSIZE (256*1024) | ||
32 | #define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */ | ||
33 | #define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */ | ||
34 | #define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */ | ||
35 | #define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */ | ||
36 | #define XLOG_BTOLSUNIT(log, b) (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \ | ||
37 | (log)->l_mp->m_sb.sb_logsunit) | ||
38 | #define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit) | ||
39 | |||
40 | #define XLOG_HEADER_SIZE 512 | ||
41 | |||
42 | #define XLOG_REC_SHIFT(log) \ | ||
43 | BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ | ||
44 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) | ||
45 | #define XLOG_TOTAL_REC_SHIFT(log) \ | ||
46 | BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ | ||
47 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) | ||
48 | |||
49 | /* get lsn fields */ | ||
50 | #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) | ||
51 | #define BLOCK_LSN(lsn) ((uint)(lsn)) | ||
52 | |||
53 | /* this is used in a spot where we might otherwise double-endian-flip */ | ||
54 | #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) | ||
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 | /* Log Clients */ | ||
70 | #define XFS_TRANSACTION 0x69 | ||
71 | #define XFS_VOLUME 0x2 | ||
72 | #define XFS_LOG 0xaa | ||
73 | |||
74 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ | ||
75 | |||
76 | /* Region types for iovec's i_type */ | ||
77 | #define XLOG_REG_TYPE_BFORMAT 1 | ||
78 | #define XLOG_REG_TYPE_BCHUNK 2 | ||
79 | #define XLOG_REG_TYPE_EFI_FORMAT 3 | ||
80 | #define XLOG_REG_TYPE_EFD_FORMAT 4 | ||
81 | #define XLOG_REG_TYPE_IFORMAT 5 | ||
82 | #define XLOG_REG_TYPE_ICORE 6 | ||
83 | #define XLOG_REG_TYPE_IEXT 7 | ||
84 | #define XLOG_REG_TYPE_IBROOT 8 | ||
85 | #define XLOG_REG_TYPE_ILOCAL 9 | ||
86 | #define XLOG_REG_TYPE_IATTR_EXT 10 | ||
87 | #define XLOG_REG_TYPE_IATTR_BROOT 11 | ||
88 | #define XLOG_REG_TYPE_IATTR_LOCAL 12 | ||
89 | #define XLOG_REG_TYPE_QFORMAT 13 | ||
90 | #define XLOG_REG_TYPE_DQUOT 14 | ||
91 | #define XLOG_REG_TYPE_QUOTAOFF 15 | ||
92 | #define XLOG_REG_TYPE_LRHEADER 16 | ||
93 | #define XLOG_REG_TYPE_UNMOUNT 17 | ||
94 | #define XLOG_REG_TYPE_COMMIT 18 | ||
95 | #define XLOG_REG_TYPE_TRANSHDR 19 | ||
96 | #define XLOG_REG_TYPE_ICREATE 20 | ||
97 | #define XLOG_REG_TYPE_MAX 20 | ||
98 | |||
99 | /* | ||
100 | * Flags to log operation header | ||
101 | * | ||
102 | * The first write of a new transaction will be preceded with a start | ||
103 | * record, XLOG_START_TRANS. Once a transaction is committed, a commit | ||
104 | * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into | ||
105 | * the remainder of the current active in-core log, it is split up into | ||
106 | * multiple regions. Each partial region will be marked with a | ||
107 | * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. | ||
108 | * | ||
109 | */ | ||
110 | #define XLOG_START_TRANS 0x01 /* Start a new transaction */ | ||
111 | #define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */ | ||
112 | #define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */ | ||
113 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ | ||
114 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ | ||
115 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ | ||
116 | |||
117 | |||
118 | typedef struct xlog_op_header { | ||
119 | __be32 oh_tid; /* transaction id of operation : 4 b */ | ||
120 | __be32 oh_len; /* bytes in data region : 4 b */ | ||
121 | __u8 oh_clientid; /* who sent me this : 1 b */ | ||
122 | __u8 oh_flags; /* : 1 b */ | ||
123 | __u16 oh_res2; /* 32 bit align : 2 b */ | ||
124 | } xlog_op_header_t; | ||
125 | |||
126 | |||
127 | /* valid values for h_fmt */ | ||
128 | #define XLOG_FMT_UNKNOWN 0 | ||
129 | #define XLOG_FMT_LINUX_LE 1 | ||
130 | #define XLOG_FMT_LINUX_BE 2 | ||
131 | #define XLOG_FMT_IRIX_BE 3 | ||
132 | |||
133 | /* our fmt */ | ||
134 | #ifdef XFS_NATIVE_HOST | ||
135 | #define XLOG_FMT XLOG_FMT_LINUX_BE | ||
136 | #else | ||
137 | #define XLOG_FMT XLOG_FMT_LINUX_LE | ||
138 | #endif | ||
139 | |||
140 | typedef struct xlog_rec_header { | ||
141 | __be32 h_magicno; /* log record (LR) identifier : 4 */ | ||
142 | __be32 h_cycle; /* write cycle of log : 4 */ | ||
143 | __be32 h_version; /* LR version : 4 */ | ||
144 | __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */ | ||
145 | __be64 h_lsn; /* lsn of this LR : 8 */ | ||
146 | __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ | ||
147 | __le32 h_crc; /* crc of log record : 4 */ | ||
148 | __be32 h_prev_block; /* block number to previous LR : 4 */ | ||
149 | __be32 h_num_logops; /* number of log operations in this LR : 4 */ | ||
150 | __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; | ||
151 | /* new fields */ | ||
152 | __be32 h_fmt; /* format of log record : 4 */ | ||
153 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ | ||
154 | __be32 h_size; /* iclog size : 4 */ | ||
155 | } xlog_rec_header_t; | ||
156 | |||
157 | typedef struct xlog_rec_ext_header { | ||
158 | __be32 xh_cycle; /* write cycle of log : 4 */ | ||
159 | __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ | ||
160 | } xlog_rec_ext_header_t; | ||
161 | |||
162 | /* | ||
163 | * Quite misnamed, because this union lays out the actual on-disk log buffer. | ||
164 | */ | ||
165 | typedef union xlog_in_core2 { | ||
166 | xlog_rec_header_t hic_header; | ||
167 | xlog_rec_ext_header_t hic_xheader; | ||
168 | char hic_sector[XLOG_HEADER_SIZE]; | ||
169 | } xlog_in_core_2_t; | ||
170 | |||
171 | /* not an on-disk structure, but needed by log recovery in userspace */ | ||
172 | typedef struct xfs_log_iovec { | ||
173 | void *i_addr; /* beginning address of region */ | ||
174 | int i_len; /* length in bytes of region */ | ||
175 | uint i_type; /* type of region */ | ||
176 | } xfs_log_iovec_t; | ||
177 | |||
178 | #endif /* __XFS_LOG_FORMAT_H__ */ | ||