Commit | Line | Data |
---|---|---|
fc06c6d0 DC |
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 | ||
69432832 DC |
21 | /* |
22 | * On-disk Log Format definitions. | |
23 | * | |
24 | * This file contains all the on-disk format definitions used within the log. It | |
25 | * includes the physical log structure itself, as well as all the log item | |
26 | * format structures that are written into the log and intepreted by log | |
27 | * recovery. We start with the physical log format definitions, and then work | |
28 | * through all the log items definitions and everything they encode into the | |
29 | * log. | |
30 | */ | |
fc06c6d0 DC |
31 | typedef __uint32_t xlog_tid_t; |
32 | ||
33 | #define XLOG_MIN_ICLOGS 2 | |
34 | #define XLOG_MAX_ICLOGS 8 | |
35 | #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */ | |
36 | #define XLOG_VERSION_1 1 | |
37 | #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */ | |
38 | #define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2) | |
39 | #define XLOG_MIN_RECORD_BSIZE (16*1024) /* eventually 32k */ | |
40 | #define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */ | |
41 | #define XLOG_MAX_RECORD_BSIZE (256*1024) | |
42 | #define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */ | |
43 | #define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */ | |
44 | #define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */ | |
45 | #define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */ | |
46 | #define XLOG_BTOLSUNIT(log, b) (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \ | |
47 | (log)->l_mp->m_sb.sb_logsunit) | |
48 | #define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit) | |
49 | ||
50 | #define XLOG_HEADER_SIZE 512 | |
51 | ||
52 | #define XLOG_REC_SHIFT(log) \ | |
53 | BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ | |
54 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) | |
55 | #define XLOG_TOTAL_REC_SHIFT(log) \ | |
56 | BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ | |
57 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) | |
58 | ||
59 | /* get lsn fields */ | |
60 | #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) | |
61 | #define BLOCK_LSN(lsn) ((uint)(lsn)) | |
62 | ||
63 | /* this is used in a spot where we might otherwise double-endian-flip */ | |
64 | #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) | |
65 | ||
66 | static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block) | |
67 | { | |
68 | return ((xfs_lsn_t)cycle << 32) | block; | |
69 | } | |
70 | ||
71 | static inline uint xlog_get_cycle(char *ptr) | |
72 | { | |
73 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) | |
74 | return be32_to_cpu(*((__be32 *)ptr + 1)); | |
75 | else | |
76 | return be32_to_cpu(*(__be32 *)ptr); | |
77 | } | |
78 | ||
79 | /* Log Clients */ | |
80 | #define XFS_TRANSACTION 0x69 | |
81 | #define XFS_VOLUME 0x2 | |
82 | #define XFS_LOG 0xaa | |
83 | ||
84 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ | |
85 | ||
86 | /* Region types for iovec's i_type */ | |
87 | #define XLOG_REG_TYPE_BFORMAT 1 | |
88 | #define XLOG_REG_TYPE_BCHUNK 2 | |
89 | #define XLOG_REG_TYPE_EFI_FORMAT 3 | |
90 | #define XLOG_REG_TYPE_EFD_FORMAT 4 | |
91 | #define XLOG_REG_TYPE_IFORMAT 5 | |
92 | #define XLOG_REG_TYPE_ICORE 6 | |
93 | #define XLOG_REG_TYPE_IEXT 7 | |
94 | #define XLOG_REG_TYPE_IBROOT 8 | |
95 | #define XLOG_REG_TYPE_ILOCAL 9 | |
96 | #define XLOG_REG_TYPE_IATTR_EXT 10 | |
97 | #define XLOG_REG_TYPE_IATTR_BROOT 11 | |
98 | #define XLOG_REG_TYPE_IATTR_LOCAL 12 | |
99 | #define XLOG_REG_TYPE_QFORMAT 13 | |
100 | #define XLOG_REG_TYPE_DQUOT 14 | |
101 | #define XLOG_REG_TYPE_QUOTAOFF 15 | |
102 | #define XLOG_REG_TYPE_LRHEADER 16 | |
103 | #define XLOG_REG_TYPE_UNMOUNT 17 | |
104 | #define XLOG_REG_TYPE_COMMIT 18 | |
105 | #define XLOG_REG_TYPE_TRANSHDR 19 | |
106 | #define XLOG_REG_TYPE_ICREATE 20 | |
107 | #define XLOG_REG_TYPE_MAX 20 | |
108 | ||
109 | /* | |
110 | * Flags to log operation header | |
111 | * | |
112 | * The first write of a new transaction will be preceded with a start | |
113 | * record, XLOG_START_TRANS. Once a transaction is committed, a commit | |
114 | * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into | |
115 | * the remainder of the current active in-core log, it is split up into | |
116 | * multiple regions. Each partial region will be marked with a | |
117 | * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. | |
118 | * | |
119 | */ | |
120 | #define XLOG_START_TRANS 0x01 /* Start a new transaction */ | |
121 | #define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */ | |
122 | #define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */ | |
123 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ | |
124 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ | |
125 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ | |
126 | ||
127 | ||
128 | typedef struct xlog_op_header { | |
129 | __be32 oh_tid; /* transaction id of operation : 4 b */ | |
130 | __be32 oh_len; /* bytes in data region : 4 b */ | |
131 | __u8 oh_clientid; /* who sent me this : 1 b */ | |
132 | __u8 oh_flags; /* : 1 b */ | |
133 | __u16 oh_res2; /* 32 bit align : 2 b */ | |
134 | } xlog_op_header_t; | |
135 | ||
136 | ||
137 | /* valid values for h_fmt */ | |
138 | #define XLOG_FMT_UNKNOWN 0 | |
139 | #define XLOG_FMT_LINUX_LE 1 | |
140 | #define XLOG_FMT_LINUX_BE 2 | |
141 | #define XLOG_FMT_IRIX_BE 3 | |
142 | ||
143 | /* our fmt */ | |
144 | #ifdef XFS_NATIVE_HOST | |
145 | #define XLOG_FMT XLOG_FMT_LINUX_BE | |
146 | #else | |
147 | #define XLOG_FMT XLOG_FMT_LINUX_LE | |
148 | #endif | |
149 | ||
150 | typedef struct xlog_rec_header { | |
151 | __be32 h_magicno; /* log record (LR) identifier : 4 */ | |
152 | __be32 h_cycle; /* write cycle of log : 4 */ | |
153 | __be32 h_version; /* LR version : 4 */ | |
154 | __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */ | |
155 | __be64 h_lsn; /* lsn of this LR : 8 */ | |
156 | __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ | |
157 | __le32 h_crc; /* crc of log record : 4 */ | |
158 | __be32 h_prev_block; /* block number to previous LR : 4 */ | |
159 | __be32 h_num_logops; /* number of log operations in this LR : 4 */ | |
160 | __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; | |
161 | /* new fields */ | |
162 | __be32 h_fmt; /* format of log record : 4 */ | |
163 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ | |
164 | __be32 h_size; /* iclog size : 4 */ | |
165 | } xlog_rec_header_t; | |
166 | ||
167 | typedef struct xlog_rec_ext_header { | |
168 | __be32 xh_cycle; /* write cycle of log : 4 */ | |
169 | __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ | |
170 | } xlog_rec_ext_header_t; | |
171 | ||
172 | /* | |
173 | * Quite misnamed, because this union lays out the actual on-disk log buffer. | |
174 | */ | |
175 | typedef union xlog_in_core2 { | |
176 | xlog_rec_header_t hic_header; | |
177 | xlog_rec_ext_header_t hic_xheader; | |
178 | char hic_sector[XLOG_HEADER_SIZE]; | |
179 | } xlog_in_core_2_t; | |
180 | ||
181 | /* not an on-disk structure, but needed by log recovery in userspace */ | |
182 | typedef struct xfs_log_iovec { | |
183 | void *i_addr; /* beginning address of region */ | |
184 | int i_len; /* length in bytes of region */ | |
185 | uint i_type; /* type of region */ | |
186 | } xfs_log_iovec_t; | |
187 | ||
69432832 DC |
188 | |
189 | /* | |
190 | * Inode Log Item Format definitions. | |
191 | * | |
192 | * This is the structure used to lay out an inode log item in the | |
193 | * log. The size of the inline data/extents/b-tree root to be logged | |
194 | * (if any) is indicated in the ilf_dsize field. Changes to this structure | |
195 | * must be added on to the end. | |
196 | */ | |
197 | typedef struct xfs_inode_log_format { | |
198 | __uint16_t ilf_type; /* inode log item type */ | |
199 | __uint16_t ilf_size; /* size of this item */ | |
200 | __uint32_t ilf_fields; /* flags for fields logged */ | |
201 | __uint16_t ilf_asize; /* size of attr d/ext/root */ | |
202 | __uint16_t ilf_dsize; /* size of data/ext/root */ | |
203 | __uint64_t ilf_ino; /* inode number */ | |
204 | union { | |
205 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ | |
206 | uuid_t ilfu_uuid; /* mount point value */ | |
207 | } ilf_u; | |
208 | __int64_t ilf_blkno; /* blkno of inode buffer */ | |
209 | __int32_t ilf_len; /* len of inode buffer */ | |
210 | __int32_t ilf_boffset; /* off of inode in buffer */ | |
211 | } xfs_inode_log_format_t; | |
212 | ||
213 | typedef struct xfs_inode_log_format_32 { | |
214 | __uint16_t ilf_type; /* inode log item type */ | |
215 | __uint16_t ilf_size; /* size of this item */ | |
216 | __uint32_t ilf_fields; /* flags for fields logged */ | |
217 | __uint16_t ilf_asize; /* size of attr d/ext/root */ | |
218 | __uint16_t ilf_dsize; /* size of data/ext/root */ | |
219 | __uint64_t ilf_ino; /* inode number */ | |
220 | union { | |
221 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ | |
222 | uuid_t ilfu_uuid; /* mount point value */ | |
223 | } ilf_u; | |
224 | __int64_t ilf_blkno; /* blkno of inode buffer */ | |
225 | __int32_t ilf_len; /* len of inode buffer */ | |
226 | __int32_t ilf_boffset; /* off of inode in buffer */ | |
227 | } __attribute__((packed)) xfs_inode_log_format_32_t; | |
228 | ||
229 | typedef struct xfs_inode_log_format_64 { | |
230 | __uint16_t ilf_type; /* inode log item type */ | |
231 | __uint16_t ilf_size; /* size of this item */ | |
232 | __uint32_t ilf_fields; /* flags for fields logged */ | |
233 | __uint16_t ilf_asize; /* size of attr d/ext/root */ | |
234 | __uint16_t ilf_dsize; /* size of data/ext/root */ | |
235 | __uint32_t ilf_pad; /* pad for 64 bit boundary */ | |
236 | __uint64_t ilf_ino; /* inode number */ | |
237 | union { | |
238 | __uint32_t ilfu_rdev; /* rdev value for dev inode*/ | |
239 | uuid_t ilfu_uuid; /* mount point value */ | |
240 | } ilf_u; | |
241 | __int64_t ilf_blkno; /* blkno of inode buffer */ | |
242 | __int32_t ilf_len; /* len of inode buffer */ | |
243 | __int32_t ilf_boffset; /* off of inode in buffer */ | |
244 | } xfs_inode_log_format_64_t; | |
245 | ||
246 | /* | |
247 | * Flags for xfs_trans_log_inode flags field. | |
248 | */ | |
249 | #define XFS_ILOG_CORE 0x001 /* log standard inode fields */ | |
250 | #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */ | |
251 | #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */ | |
252 | #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */ | |
253 | #define XFS_ILOG_DEV 0x010 /* log the dev field */ | |
254 | #define XFS_ILOG_UUID 0x020 /* log the uuid field */ | |
255 | #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */ | |
256 | #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */ | |
257 | #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */ | |
258 | ||
259 | ||
260 | /* | |
261 | * The timestamps are dirty, but not necessarily anything else in the inode | |
262 | * core. Unlike the other fields above this one must never make it to disk | |
263 | * in the ilf_fields of the inode_log_format, but is purely store in-memory in | |
264 | * ili_fields in the inode_log_item. | |
265 | */ | |
266 | #define XFS_ILOG_TIMESTAMP 0x4000 | |
267 | ||
268 | #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | |
269 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ | |
270 | XFS_ILOG_UUID | XFS_ILOG_ADATA | \ | |
271 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT) | |
272 | ||
273 | #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ | |
274 | XFS_ILOG_DBROOT) | |
275 | ||
276 | #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | |
277 | XFS_ILOG_ABROOT) | |
278 | ||
279 | #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \ | |
280 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ | |
281 | XFS_ILOG_DEV | XFS_ILOG_UUID | \ | |
282 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ | |
283 | XFS_ILOG_ABROOT | XFS_ILOG_TIMESTAMP) | |
284 | ||
285 | static inline int xfs_ilog_fbroot(int w) | |
286 | { | |
287 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); | |
288 | } | |
289 | ||
290 | static inline int xfs_ilog_fext(int w) | |
291 | { | |
292 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); | |
293 | } | |
294 | ||
295 | static inline int xfs_ilog_fdata(int w) | |
296 | { | |
297 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); | |
298 | } | |
299 | ||
300 | /* | |
301 | * Incore version of the on-disk inode core structures. We log this directly | |
302 | * into the journal in host CPU format (for better or worse) and as such | |
303 | * directly mirrors the xfs_dinode structure as it must contain all the same | |
304 | * information. | |
305 | */ | |
306 | typedef struct xfs_ictimestamp { | |
307 | __int32_t t_sec; /* timestamp seconds */ | |
308 | __int32_t t_nsec; /* timestamp nanoseconds */ | |
309 | } xfs_ictimestamp_t; | |
310 | ||
311 | /* | |
312 | * NOTE: This structure must be kept identical to struct xfs_dinode | |
313 | * in xfs_dinode.h except for the endianness annotations. | |
314 | */ | |
315 | typedef struct xfs_icdinode { | |
316 | __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | |
317 | __uint16_t di_mode; /* mode and type of file */ | |
318 | __int8_t di_version; /* inode version */ | |
319 | __int8_t di_format; /* format of di_c data */ | |
320 | __uint16_t di_onlink; /* old number of links to file */ | |
321 | __uint32_t di_uid; /* owner's user id */ | |
322 | __uint32_t di_gid; /* owner's group id */ | |
323 | __uint32_t di_nlink; /* number of links to file */ | |
324 | __uint16_t di_projid_lo; /* lower part of owner's project id */ | |
325 | __uint16_t di_projid_hi; /* higher part of owner's project id */ | |
326 | __uint8_t di_pad[6]; /* unused, zeroed space */ | |
327 | __uint16_t di_flushiter; /* incremented on flush */ | |
328 | xfs_ictimestamp_t di_atime; /* time last accessed */ | |
329 | xfs_ictimestamp_t di_mtime; /* time last modified */ | |
330 | xfs_ictimestamp_t di_ctime; /* time created/inode modified */ | |
331 | xfs_fsize_t di_size; /* number of bytes in file */ | |
332 | xfs_drfsbno_t di_nblocks; /* # of direct & btree blocks used */ | |
333 | xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ | |
334 | xfs_extnum_t di_nextents; /* number of extents in data fork */ | |
335 | xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ | |
336 | __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ | |
337 | __int8_t di_aformat; /* format of attr fork's data */ | |
338 | __uint32_t di_dmevmask; /* DMIG event mask */ | |
339 | __uint16_t di_dmstate; /* DMIG state info */ | |
340 | __uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ | |
341 | __uint32_t di_gen; /* generation number */ | |
342 | ||
343 | /* di_next_unlinked is the only non-core field in the old dinode */ | |
344 | xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ | |
345 | ||
346 | /* start of the extended dinode, writable fields */ | |
347 | __uint32_t di_crc; /* CRC of the inode */ | |
348 | __uint64_t di_changecount; /* number of attribute changes */ | |
349 | xfs_lsn_t di_lsn; /* flush sequence */ | |
350 | __uint64_t di_flags2; /* more random flags */ | |
351 | __uint8_t di_pad2[16]; /* more padding for future expansion */ | |
352 | ||
353 | /* fields only written to during inode creation */ | |
354 | xfs_ictimestamp_t di_crtime; /* time created */ | |
355 | xfs_ino_t di_ino; /* inode number */ | |
356 | uuid_t di_uuid; /* UUID of the filesystem */ | |
357 | ||
358 | /* structure must be padded to 64 bit alignment */ | |
359 | } xfs_icdinode_t; | |
360 | ||
361 | static inline uint xfs_icdinode_size(int version) | |
362 | { | |
363 | if (version == 3) | |
364 | return sizeof(struct xfs_icdinode); | |
365 | return offsetof(struct xfs_icdinode, di_next_unlinked); | |
366 | } | |
a8da0da2 DC |
367 | |
368 | /* | |
369 | * Buffer Log Format defintions | |
370 | * | |
371 | * These are the physical dirty bitmap defintions for the log format structure. | |
372 | */ | |
373 | #define XFS_BLF_CHUNK 128 | |
374 | #define XFS_BLF_SHIFT 7 | |
375 | #define BIT_TO_WORD_SHIFT 5 | |
376 | #define NBWORD (NBBY * sizeof(unsigned int)) | |
377 | ||
378 | /* | |
379 | * This flag indicates that the buffer contains on disk inodes | |
380 | * and requires special recovery handling. | |
381 | */ | |
382 | #define XFS_BLF_INODE_BUF (1<<0) | |
383 | ||
384 | /* | |
385 | * This flag indicates that the buffer should not be replayed | |
386 | * during recovery because its blocks are being freed. | |
387 | */ | |
388 | #define XFS_BLF_CANCEL (1<<1) | |
389 | ||
390 | /* | |
391 | * This flag indicates that the buffer contains on disk | |
392 | * user or group dquots and may require special recovery handling. | |
393 | */ | |
394 | #define XFS_BLF_UDQUOT_BUF (1<<2) | |
395 | #define XFS_BLF_PDQUOT_BUF (1<<3) | |
396 | #define XFS_BLF_GDQUOT_BUF (1<<4) | |
397 | ||
398 | /* | |
399 | * This is the structure used to lay out a buf log item in the | |
400 | * log. The data map describes which 128 byte chunks of the buffer | |
401 | * have been logged. | |
402 | */ | |
403 | #define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD) | |
404 | ||
405 | typedef struct xfs_buf_log_format { | |
406 | unsigned short blf_type; /* buf log item type indicator */ | |
407 | unsigned short blf_size; /* size of this item */ | |
408 | ushort blf_flags; /* misc state */ | |
409 | ushort blf_len; /* number of blocks in this buf */ | |
410 | __int64_t blf_blkno; /* starting blkno of this buf */ | |
411 | unsigned int blf_map_size; /* used size of data bitmap in words */ | |
412 | unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */ | |
413 | } xfs_buf_log_format_t; | |
414 | ||
415 | /* | |
416 | * All buffers now need to tell recovery where the magic number | |
417 | * is so that it can verify and calculate the CRCs on the buffer correctly | |
418 | * once the changes have been replayed into the buffer. | |
419 | * | |
420 | * The type value is held in the upper 5 bits of the blf_flags field, which is | |
421 | * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down. | |
422 | */ | |
423 | #define XFS_BLFT_BITS 5 | |
424 | #define XFS_BLFT_SHIFT 11 | |
425 | #define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT) | |
426 | ||
427 | enum xfs_blft { | |
428 | XFS_BLFT_UNKNOWN_BUF = 0, | |
429 | XFS_BLFT_UDQUOT_BUF, | |
430 | XFS_BLFT_PDQUOT_BUF, | |
431 | XFS_BLFT_GDQUOT_BUF, | |
432 | XFS_BLFT_BTREE_BUF, | |
433 | XFS_BLFT_AGF_BUF, | |
434 | XFS_BLFT_AGFL_BUF, | |
435 | XFS_BLFT_AGI_BUF, | |
436 | XFS_BLFT_DINO_BUF, | |
437 | XFS_BLFT_SYMLINK_BUF, | |
438 | XFS_BLFT_DIR_BLOCK_BUF, | |
439 | XFS_BLFT_DIR_DATA_BUF, | |
440 | XFS_BLFT_DIR_FREE_BUF, | |
441 | XFS_BLFT_DIR_LEAF1_BUF, | |
442 | XFS_BLFT_DIR_LEAFN_BUF, | |
443 | XFS_BLFT_DA_NODE_BUF, | |
444 | XFS_BLFT_ATTR_LEAF_BUF, | |
445 | XFS_BLFT_ATTR_RMT_BUF, | |
446 | XFS_BLFT_SB_BUF, | |
447 | XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS), | |
448 | }; | |
449 | ||
450 | static inline void | |
451 | xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type) | |
452 | { | |
453 | ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF); | |
454 | blf->blf_flags &= ~XFS_BLFT_MASK; | |
455 | blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK); | |
456 | } | |
457 | ||
458 | static inline __uint16_t | |
459 | xfs_blft_from_flags(struct xfs_buf_log_format *blf) | |
460 | { | |
461 | return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT; | |
462 | } | |
463 | ||
9fbe24d9 DC |
464 | /* |
465 | * EFI/EFD log format definitions | |
466 | */ | |
467 | typedef struct xfs_extent { | |
468 | xfs_dfsbno_t ext_start; | |
469 | xfs_extlen_t ext_len; | |
470 | } xfs_extent_t; | |
471 | ||
472 | /* | |
473 | * Since an xfs_extent_t has types (start:64, len: 32) | |
474 | * there are different alignments on 32 bit and 64 bit kernels. | |
475 | * So we provide the different variants for use by a | |
476 | * conversion routine. | |
477 | */ | |
478 | typedef struct xfs_extent_32 { | |
479 | __uint64_t ext_start; | |
480 | __uint32_t ext_len; | |
481 | } __attribute__((packed)) xfs_extent_32_t; | |
482 | ||
483 | typedef struct xfs_extent_64 { | |
484 | __uint64_t ext_start; | |
485 | __uint32_t ext_len; | |
486 | __uint32_t ext_pad; | |
487 | } xfs_extent_64_t; | |
488 | ||
489 | /* | |
490 | * This is the structure used to lay out an efi log item in the | |
491 | * log. The efi_extents field is a variable size array whose | |
492 | * size is given by efi_nextents. | |
493 | */ | |
494 | typedef struct xfs_efi_log_format { | |
495 | __uint16_t efi_type; /* efi log item type */ | |
496 | __uint16_t efi_size; /* size of this item */ | |
497 | __uint32_t efi_nextents; /* # extents to free */ | |
498 | __uint64_t efi_id; /* efi identifier */ | |
499 | xfs_extent_t efi_extents[1]; /* array of extents to free */ | |
500 | } xfs_efi_log_format_t; | |
501 | ||
502 | typedef struct xfs_efi_log_format_32 { | |
503 | __uint16_t efi_type; /* efi log item type */ | |
504 | __uint16_t efi_size; /* size of this item */ | |
505 | __uint32_t efi_nextents; /* # extents to free */ | |
506 | __uint64_t efi_id; /* efi identifier */ | |
507 | xfs_extent_32_t efi_extents[1]; /* array of extents to free */ | |
508 | } __attribute__((packed)) xfs_efi_log_format_32_t; | |
509 | ||
510 | typedef struct xfs_efi_log_format_64 { | |
511 | __uint16_t efi_type; /* efi log item type */ | |
512 | __uint16_t efi_size; /* size of this item */ | |
513 | __uint32_t efi_nextents; /* # extents to free */ | |
514 | __uint64_t efi_id; /* efi identifier */ | |
515 | xfs_extent_64_t efi_extents[1]; /* array of extents to free */ | |
516 | } xfs_efi_log_format_64_t; | |
517 | ||
518 | /* | |
519 | * This is the structure used to lay out an efd log item in the | |
520 | * log. The efd_extents array is a variable size array whose | |
521 | * size is given by efd_nextents; | |
522 | */ | |
523 | typedef struct xfs_efd_log_format { | |
524 | __uint16_t efd_type; /* efd log item type */ | |
525 | __uint16_t efd_size; /* size of this item */ | |
526 | __uint32_t efd_nextents; /* # of extents freed */ | |
527 | __uint64_t efd_efi_id; /* id of corresponding efi */ | |
528 | xfs_extent_t efd_extents[1]; /* array of extents freed */ | |
529 | } xfs_efd_log_format_t; | |
530 | ||
531 | typedef struct xfs_efd_log_format_32 { | |
532 | __uint16_t efd_type; /* efd log item type */ | |
533 | __uint16_t efd_size; /* size of this item */ | |
534 | __uint32_t efd_nextents; /* # of extents freed */ | |
535 | __uint64_t efd_efi_id; /* id of corresponding efi */ | |
536 | xfs_extent_32_t efd_extents[1]; /* array of extents freed */ | |
537 | } __attribute__((packed)) xfs_efd_log_format_32_t; | |
538 | ||
539 | typedef struct xfs_efd_log_format_64 { | |
540 | __uint16_t efd_type; /* efd log item type */ | |
541 | __uint16_t efd_size; /* size of this item */ | |
542 | __uint32_t efd_nextents; /* # of extents freed */ | |
543 | __uint64_t efd_efi_id; /* id of corresponding efi */ | |
544 | xfs_extent_64_t efd_extents[1]; /* array of extents freed */ | |
545 | } xfs_efd_log_format_64_t; | |
546 | ||
6ca1c906 DC |
547 | /* |
548 | * Dquot Log format definitions. | |
549 | * | |
550 | * The first two fields must be the type and size fitting into | |
551 | * 32 bits : log_recovery code assumes that. | |
552 | */ | |
553 | typedef struct xfs_dq_logformat { | |
554 | __uint16_t qlf_type; /* dquot log item type */ | |
555 | __uint16_t qlf_size; /* size of this item */ | |
556 | xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ | |
557 | __int64_t qlf_blkno; /* blkno of dquot buffer */ | |
558 | __int32_t qlf_len; /* len of dquot buffer */ | |
559 | __uint32_t qlf_boffset; /* off of dquot in buffer */ | |
560 | } xfs_dq_logformat_t; | |
561 | ||
562 | /* | |
563 | * log format struct for QUOTAOFF records. | |
564 | * The first two fields must be the type and size fitting into | |
565 | * 32 bits : log_recovery code assumes that. | |
566 | * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer | |
567 | * to the first and ensures that the first logitem is taken out of the AIL | |
568 | * only when the last one is securely committed. | |
569 | */ | |
570 | typedef struct xfs_qoff_logformat { | |
571 | unsigned short qf_type; /* quotaoff log item type */ | |
572 | unsigned short qf_size; /* size of this item */ | |
573 | unsigned int qf_flags; /* USR and/or GRP */ | |
574 | char qf_pad[12]; /* padding for future */ | |
575 | } xfs_qoff_logformat_t; | |
576 | ||
577 | ||
578 | /* | |
579 | * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. | |
580 | */ | |
581 | #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ | |
582 | #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ | |
583 | #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ | |
584 | #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */ | |
585 | #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */ | |
586 | #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */ | |
587 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ | |
588 | ||
589 | /* | |
590 | * Conversion to and from the combined OQUOTA flag (if necessary) | |
591 | * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk() | |
592 | */ | |
593 | #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */ | |
594 | #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */ | |
595 | #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */ | |
596 | #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */ | |
597 | ||
598 | #define XFS_ALL_QUOTA_ACCT \ | |
599 | (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) | |
600 | #define XFS_ALL_QUOTA_ENFD \ | |
601 | (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) | |
602 | #define XFS_ALL_QUOTA_CHKD \ | |
603 | (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD) | |
604 | ||
9cd047f3 DC |
605 | /* |
606 | * Inode create log item structure | |
607 | * | |
608 | * Log recovery assumes the first two entries are the type and size and they fit | |
609 | * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so | |
610 | * decoding can be done correctly. | |
611 | */ | |
612 | struct xfs_icreate_log { | |
613 | __uint16_t icl_type; /* type of log format structure */ | |
614 | __uint16_t icl_size; /* size of log format structure */ | |
615 | __be32 icl_ag; /* ag being allocated in */ | |
616 | __be32 icl_agbno; /* start block of inode range */ | |
617 | __be32 icl_count; /* number of inodes to initialise */ | |
618 | __be32 icl_isize; /* size of inodes */ | |
619 | __be32 icl_length; /* length of extent to initialise */ | |
620 | __be32 icl_gen; /* inode generation number to use */ | |
621 | }; | |
622 | ||
fc06c6d0 | 623 | #endif /* __XFS_LOG_FORMAT_H__ */ |