Line data Source code
1 : // SPDX-License-Identifier: GPL-2.0
2 : /*
3 : * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
4 : * All Rights Reserved.
5 : */
6 : #ifndef __XFS_LOG_FORMAT_H__
7 : #define __XFS_LOG_FORMAT_H__
8 :
9 : struct xfs_mount;
10 : struct xfs_trans_res;
11 :
12 : /*
13 : * On-disk Log Format definitions.
14 : *
15 : * This file contains all the on-disk format definitions used within the log. It
16 : * includes the physical log structure itself, as well as all the log item
17 : * format structures that are written into the log and intepreted by log
18 : * recovery. We start with the physical log format definitions, and then work
19 : * through all the log items definitions and everything they encode into the
20 : * log.
21 : */
22 : typedef uint32_t xlog_tid_t;
23 :
24 : #define XLOG_MIN_ICLOGS 2
25 : #define XLOG_MAX_ICLOGS 8
26 : #define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe /* Invalid cycle number */
27 : #define XLOG_VERSION_1 1
28 : #define XLOG_VERSION_2 2 /* Large IClogs, Log sunit */
29 : #define XLOG_VERSION_OKBITS (XLOG_VERSION_1 | XLOG_VERSION_2)
30 : #define XLOG_MIN_RECORD_BSIZE (16*1024) /* eventually 32k */
31 : #define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */
32 : #define XLOG_MAX_RECORD_BSIZE (256*1024)
33 : #define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */
34 : #define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */
35 : #define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */
36 : #define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */
37 :
38 : #define XLOG_HEADER_SIZE 512
39 :
40 : /* Minimum number of transactions that must fit in the log (defined by mkfs) */
41 : #define XFS_MIN_LOG_FACTOR 3
42 :
43 : #define XLOG_REC_SHIFT(log) \
44 : BTOBB(1 << (xfs_has_logv2(log->l_mp) ? \
45 : XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
46 : #define XLOG_TOTAL_REC_SHIFT(log) \
47 : BTOBB(XLOG_MAX_ICLOGS << (xfs_has_logv2(log->l_mp) ? \
48 : XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
49 :
50 : /* get lsn fields */
51 : #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
52 : #define BLOCK_LSN(lsn) ((uint)(lsn))
53 :
54 : /* this is used in a spot where we might otherwise double-endian-flip */
55 : #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
56 :
57 : static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
58 : {
59 130541560 : return ((xfs_lsn_t)cycle << 32) | block;
60 : }
61 :
62 71639546 : static inline uint xlog_get_cycle(char *ptr)
63 : {
64 71639546 : if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
65 1980907 : return be32_to_cpu(*((__be32 *)ptr + 1));
66 : else
67 69658639 : return be32_to_cpu(*(__be32 *)ptr);
68 : }
69 :
70 : /* Log Clients */
71 : #define XFS_TRANSACTION 0x69
72 : #define XFS_LOG 0xaa
73 :
74 : #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
75 :
76 : /*
77 : * Log item for unmount records.
78 : *
79 : * The unmount record used to have a string "Unmount filesystem--" in the
80 : * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE).
81 : * We just write the magic number now; see xfs_log_unmount_write.
82 : */
83 : struct xfs_unmount_log_format {
84 : uint16_t magic; /* XLOG_UNMOUNT_TYPE */
85 : uint16_t pad1;
86 : uint32_t pad2; /* may as well make it 64 bits */
87 : };
88 :
89 : /* Region types for iovec's i_type */
90 : #define XLOG_REG_TYPE_BFORMAT 1
91 : #define XLOG_REG_TYPE_BCHUNK 2
92 : #define XLOG_REG_TYPE_EFI_FORMAT 3
93 : #define XLOG_REG_TYPE_EFD_FORMAT 4
94 : #define XLOG_REG_TYPE_IFORMAT 5
95 : #define XLOG_REG_TYPE_ICORE 6
96 : #define XLOG_REG_TYPE_IEXT 7
97 : #define XLOG_REG_TYPE_IBROOT 8
98 : #define XLOG_REG_TYPE_ILOCAL 9
99 : #define XLOG_REG_TYPE_IATTR_EXT 10
100 : #define XLOG_REG_TYPE_IATTR_BROOT 11
101 : #define XLOG_REG_TYPE_IATTR_LOCAL 12
102 : #define XLOG_REG_TYPE_QFORMAT 13
103 : #define XLOG_REG_TYPE_DQUOT 14
104 : #define XLOG_REG_TYPE_QUOTAOFF 15
105 : #define XLOG_REG_TYPE_LRHEADER 16
106 : #define XLOG_REG_TYPE_UNMOUNT 17
107 : #define XLOG_REG_TYPE_COMMIT 18
108 : #define XLOG_REG_TYPE_TRANSHDR 19
109 : #define XLOG_REG_TYPE_ICREATE 20
110 : #define XLOG_REG_TYPE_RUI_FORMAT 21
111 : #define XLOG_REG_TYPE_RUD_FORMAT 22
112 : #define XLOG_REG_TYPE_CUI_FORMAT 23
113 : #define XLOG_REG_TYPE_CUD_FORMAT 24
114 : #define XLOG_REG_TYPE_BUI_FORMAT 25
115 : #define XLOG_REG_TYPE_BUD_FORMAT 26
116 : #define XLOG_REG_TYPE_ATTRI_FORMAT 27
117 : #define XLOG_REG_TYPE_ATTRD_FORMAT 28
118 : #define XLOG_REG_TYPE_ATTR_NAME 29
119 : #define XLOG_REG_TYPE_ATTR_VALUE 30
120 : #define XLOG_REG_TYPE_SXI_FORMAT 31
121 : #define XLOG_REG_TYPE_SXD_FORMAT 32
122 : #define XLOG_REG_TYPE_ATTR_NEWNAME 33
123 : #define XLOG_REG_TYPE_ATTR_NEWVALUE 34
124 : #define XLOG_REG_TYPE_MAX 34
125 :
126 : /*
127 : * Flags to log operation header
128 : *
129 : * The first write of a new transaction will be preceded with a start
130 : * record, XLOG_START_TRANS. Once a transaction is committed, a commit
131 : * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into
132 : * the remainder of the current active in-core log, it is split up into
133 : * multiple regions. Each partial region will be marked with a
134 : * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS.
135 : *
136 : */
137 : #define XLOG_START_TRANS 0x01 /* Start a new transaction */
138 : #define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */
139 : #define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */
140 : #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */
141 : #define XLOG_END_TRANS 0x10 /* End a continued transaction */
142 : #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */
143 :
144 :
145 : typedef struct xlog_op_header {
146 : __be32 oh_tid; /* transaction id of operation : 4 b */
147 : __be32 oh_len; /* bytes in data region : 4 b */
148 : __u8 oh_clientid; /* who sent me this : 1 b */
149 : __u8 oh_flags; /* : 1 b */
150 : __u16 oh_res2; /* 32 bit align : 2 b */
151 : } xlog_op_header_t;
152 :
153 : /* valid values for h_fmt */
154 : #define XLOG_FMT_UNKNOWN 0
155 : #define XLOG_FMT_LINUX_LE 1
156 : #define XLOG_FMT_LINUX_BE 2
157 : #define XLOG_FMT_IRIX_BE 3
158 :
159 : /* our fmt */
160 : #ifdef XFS_NATIVE_HOST
161 : #define XLOG_FMT XLOG_FMT_LINUX_BE
162 : #else
163 : #define XLOG_FMT XLOG_FMT_LINUX_LE
164 : #endif
165 :
166 : typedef struct xlog_rec_header {
167 : __be32 h_magicno; /* log record (LR) identifier : 4 */
168 : __be32 h_cycle; /* write cycle of log : 4 */
169 : __be32 h_version; /* LR version : 4 */
170 : __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */
171 : __be64 h_lsn; /* lsn of this LR : 8 */
172 : __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */
173 : __le32 h_crc; /* crc of log record : 4 */
174 : __be32 h_prev_block; /* block number to previous LR : 4 */
175 : __be32 h_num_logops; /* number of log operations in this LR : 4 */
176 : __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
177 : /* new fields */
178 : __be32 h_fmt; /* format of log record : 4 */
179 : uuid_t h_fs_uuid; /* uuid of FS : 16 */
180 : __be32 h_size; /* iclog size : 4 */
181 : } xlog_rec_header_t;
182 :
183 : typedef struct xlog_rec_ext_header {
184 : __be32 xh_cycle; /* write cycle of log : 4 */
185 : __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
186 : } xlog_rec_ext_header_t;
187 :
188 : /*
189 : * Quite misnamed, because this union lays out the actual on-disk log buffer.
190 : */
191 : typedef union xlog_in_core2 {
192 : xlog_rec_header_t hic_header;
193 : xlog_rec_ext_header_t hic_xheader;
194 : char hic_sector[XLOG_HEADER_SIZE];
195 : } xlog_in_core_2_t;
196 :
197 : /* not an on-disk structure, but needed by log recovery in userspace */
198 : typedef struct xfs_log_iovec {
199 : void *i_addr; /* beginning address of region */
200 : int i_len; /* length in bytes of region */
201 : uint i_type; /* type of region */
202 : } xfs_log_iovec_t;
203 :
204 :
205 : /*
206 : * Transaction Header definitions.
207 : *
208 : * This is the structure written in the log at the head of every transaction. It
209 : * identifies the type and id of the transaction, and contains the number of
210 : * items logged by the transaction so we know how many to expect during
211 : * recovery.
212 : *
213 : * Do not change the below structure without redoing the code in
214 : * xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans().
215 : */
216 : typedef struct xfs_trans_header {
217 : uint th_magic; /* magic number */
218 : uint th_type; /* transaction type */
219 : int32_t th_tid; /* transaction id (unused) */
220 : uint th_num_items; /* num items logged by trans */
221 : } xfs_trans_header_t;
222 :
223 : #define XFS_TRANS_HEADER_MAGIC 0x5452414e /* TRAN */
224 :
225 : /*
226 : * The only type valid for th_type in CIL-enabled file system logs:
227 : */
228 : #define XFS_TRANS_CHECKPOINT 40
229 :
230 : /*
231 : * Log item types.
232 : */
233 : #define XFS_LI_EFI 0x1236
234 : #define XFS_LI_EFD 0x1237
235 : #define XFS_LI_IUNLINK 0x1238
236 : #define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */
237 : #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */
238 : #define XFS_LI_DQUOT 0x123d
239 : #define XFS_LI_QUOTAOFF 0x123e
240 : #define XFS_LI_ICREATE 0x123f
241 : #define XFS_LI_RUI 0x1240 /* rmap update intent */
242 : #define XFS_LI_RUD 0x1241
243 : #define XFS_LI_CUI 0x1242 /* refcount update intent */
244 : #define XFS_LI_CUD 0x1243
245 : #define XFS_LI_BUI 0x1244 /* bmbt update intent */
246 : #define XFS_LI_BUD 0x1245
247 : #define XFS_LI_ATTRI 0x1246 /* attr set/remove intent*/
248 : #define XFS_LI_ATTRD 0x1247 /* attr set/remove done */
249 : #define XFS_LI_SXI 0x1248 /* extent swap intent */
250 : #define XFS_LI_SXD 0x1249 /* extent swap done */
251 :
252 : #define XFS_LI_TYPE_DESC \
253 : { XFS_LI_EFI, "XFS_LI_EFI" }, \
254 : { XFS_LI_EFD, "XFS_LI_EFD" }, \
255 : { XFS_LI_IUNLINK, "XFS_LI_IUNLINK" }, \
256 : { XFS_LI_INODE, "XFS_LI_INODE" }, \
257 : { XFS_LI_BUF, "XFS_LI_BUF" }, \
258 : { XFS_LI_DQUOT, "XFS_LI_DQUOT" }, \
259 : { XFS_LI_QUOTAOFF, "XFS_LI_QUOTAOFF" }, \
260 : { XFS_LI_ICREATE, "XFS_LI_ICREATE" }, \
261 : { XFS_LI_RUI, "XFS_LI_RUI" }, \
262 : { XFS_LI_RUD, "XFS_LI_RUD" }, \
263 : { XFS_LI_CUI, "XFS_LI_CUI" }, \
264 : { XFS_LI_CUD, "XFS_LI_CUD" }, \
265 : { XFS_LI_BUI, "XFS_LI_BUI" }, \
266 : { XFS_LI_BUD, "XFS_LI_BUD" }, \
267 : { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \
268 : { XFS_LI_ATTRD, "XFS_LI_ATTRD" }, \
269 : { XFS_LI_SXI, "XFS_LI_SXI" }, \
270 : { XFS_LI_SXD, "XFS_LI_SXD" }
271 :
272 : /*
273 : * Inode Log Item Format definitions.
274 : *
275 : * This is the structure used to lay out an inode log item in the
276 : * log. The size of the inline data/extents/b-tree root to be logged
277 : * (if any) is indicated in the ilf_dsize field. Changes to this structure
278 : * must be added on to the end.
279 : */
280 : struct xfs_inode_log_format {
281 : uint16_t ilf_type; /* inode log item type */
282 : uint16_t ilf_size; /* size of this item */
283 : uint32_t ilf_fields; /* flags for fields logged */
284 : uint16_t ilf_asize; /* size of attr d/ext/root */
285 : uint16_t ilf_dsize; /* size of data/ext/root */
286 : uint32_t ilf_pad; /* pad for 64 bit boundary */
287 : uint64_t ilf_ino; /* inode number */
288 : union {
289 : uint32_t ilfu_rdev; /* rdev value for dev inode*/
290 : uint8_t __pad[16]; /* unused */
291 : } ilf_u;
292 : int64_t ilf_blkno; /* blkno of inode buffer */
293 : int32_t ilf_len; /* len of inode buffer */
294 : int32_t ilf_boffset; /* off of inode in buffer */
295 : };
296 :
297 : /*
298 : * Old 32 bit systems will log in this format without the 64 bit
299 : * alignment padding. Recovery will detect this and convert it to the
300 : * correct format.
301 : */
302 : struct xfs_inode_log_format_32 {
303 : uint16_t ilf_type; /* inode log item type */
304 : uint16_t ilf_size; /* size of this item */
305 : uint32_t ilf_fields; /* flags for fields logged */
306 : uint16_t ilf_asize; /* size of attr d/ext/root */
307 : uint16_t ilf_dsize; /* size of data/ext/root */
308 : uint64_t ilf_ino; /* inode number */
309 : union {
310 : uint32_t ilfu_rdev; /* rdev value for dev inode*/
311 : uint8_t __pad[16]; /* unused */
312 : } ilf_u;
313 : int64_t ilf_blkno; /* blkno of inode buffer */
314 : int32_t ilf_len; /* len of inode buffer */
315 : int32_t ilf_boffset; /* off of inode in buffer */
316 : } __attribute__((packed));
317 :
318 :
319 : /*
320 : * Flags for xfs_trans_log_inode flags field.
321 : */
322 : #define XFS_ILOG_CORE 0x001 /* log standard inode fields */
323 : #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
324 : #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
325 : #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
326 : #define XFS_ILOG_DEV 0x010 /* log the dev field */
327 : #define XFS_ILOG_UUID 0x020 /* added long ago, but never used */
328 : #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
329 : #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
330 : #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
331 : #define XFS_ILOG_DOWNER 0x200 /* change the data fork owner on replay */
332 : #define XFS_ILOG_AOWNER 0x400 /* change the attr fork owner on replay */
333 :
334 : /*
335 : * The timestamps are dirty, but not necessarily anything else in the inode
336 : * core. Unlike the other fields above this one must never make it to disk
337 : * in the ilf_fields of the inode_log_format, but is purely store in-memory in
338 : * ili_fields in the inode_log_item.
339 : */
340 : #define XFS_ILOG_TIMESTAMP 0x4000
341 :
342 : /*
343 : * The version field has been changed, but not necessarily anything else of
344 : * interest. This must never make it to disk - it is used purely to ensure that
345 : * the inode item ->precommit operation can update the fsync flag triggers
346 : * in the inode item correctly.
347 : */
348 : #define XFS_ILOG_IVERSION 0x8000
349 :
350 : #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
351 : XFS_ILOG_DBROOT | XFS_ILOG_DEV | \
352 : XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
353 : XFS_ILOG_ABROOT | XFS_ILOG_DOWNER | \
354 : XFS_ILOG_AOWNER)
355 :
356 : #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
357 : XFS_ILOG_DBROOT)
358 :
359 : #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
360 : XFS_ILOG_ABROOT)
361 :
362 : #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
363 : XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
364 : XFS_ILOG_DEV | XFS_ILOG_ADATA | \
365 : XFS_ILOG_AEXT | XFS_ILOG_ABROOT | \
366 : XFS_ILOG_TIMESTAMP | XFS_ILOG_DOWNER | \
367 : XFS_ILOG_AOWNER)
368 :
369 : static inline int xfs_ilog_fbroot(int w)
370 : {
371 176464038 : return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
372 : }
373 :
374 : static inline int xfs_ilog_fext(int w)
375 : {
376 258370539 : return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
377 : }
378 :
379 : static inline int xfs_ilog_fdata(int w)
380 : {
381 168924 : return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
382 : }
383 :
384 : /*
385 : * Incore version of the on-disk inode core structures. We log this directly
386 : * into the journal in host CPU format (for better or worse) and as such
387 : * directly mirrors the xfs_dinode structure as it must contain all the same
388 : * information.
389 : */
390 : typedef uint64_t xfs_log_timestamp_t;
391 :
392 : /* Legacy timestamp encoding format. */
393 : struct xfs_log_legacy_timestamp {
394 : int32_t t_sec; /* timestamp seconds */
395 : int32_t t_nsec; /* timestamp nanoseconds */
396 : };
397 :
398 : /*
399 : * Define the format of the inode core that is logged. This structure must be
400 : * kept identical to struct xfs_dinode except for the endianness annotations.
401 : */
402 : struct xfs_log_dinode {
403 : uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
404 : uint16_t di_mode; /* mode and type of file */
405 : int8_t di_version; /* inode version */
406 : int8_t di_format; /* format of di_c data */
407 : uint8_t di_pad3[2]; /* unused in v2/3 inodes */
408 : uint32_t di_uid; /* owner's user id */
409 : uint32_t di_gid; /* owner's group id */
410 : uint32_t di_nlink; /* number of links to file */
411 : uint16_t di_projid_lo; /* lower part of owner's project id */
412 : uint16_t di_projid_hi; /* higher part of owner's project id */
413 : union {
414 : /* Number of data fork extents if NREXT64 is set */
415 : uint64_t di_big_nextents;
416 :
417 : /* Padding for V3 inodes without NREXT64 set. */
418 : uint64_t di_v3_pad;
419 :
420 : /* Padding and inode flush counter for V2 inodes. */
421 : struct {
422 : uint8_t di_v2_pad[6]; /* V2 inode zeroed space */
423 : uint16_t di_flushiter; /* V2 inode incremented on flush */
424 : };
425 : };
426 : xfs_log_timestamp_t di_atime; /* time last accessed */
427 : xfs_log_timestamp_t di_mtime; /* time last modified */
428 : xfs_log_timestamp_t di_ctime; /* time created/inode modified */
429 : xfs_fsize_t di_size; /* number of bytes in file */
430 : xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */
431 : xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
432 : union {
433 : /*
434 : * For V2 inodes and V3 inodes without NREXT64 set, this
435 : * is the number of data and attr fork extents.
436 : */
437 : struct {
438 : uint32_t di_nextents;
439 : uint16_t di_anextents;
440 : } __packed;
441 :
442 : /* Number of attr fork extents if NREXT64 is set. */
443 : struct {
444 : uint32_t di_big_anextents;
445 : uint16_t di_nrext64_pad;
446 : } __packed;
447 : } __packed;
448 : uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
449 : int8_t di_aformat; /* format of attr fork's data */
450 : uint32_t di_dmevmask; /* DMIG event mask */
451 : uint16_t di_dmstate; /* DMIG state info */
452 : uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
453 : uint32_t di_gen; /* generation number */
454 :
455 : /* di_next_unlinked is the only non-core field in the old dinode */
456 : xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */
457 :
458 : /* start of the extended dinode, writable fields */
459 : uint32_t di_crc; /* CRC of the inode */
460 : uint64_t di_changecount; /* number of attribute changes */
461 :
462 : /*
463 : * The LSN we write to this field during formatting is not a reflection
464 : * of the current on-disk LSN. It should never be used for recovery
465 : * sequencing, nor should it be recovered into the on-disk inode at all.
466 : * See xlog_recover_inode_commit_pass2() and xfs_log_dinode_to_disk()
467 : * for details.
468 : */
469 : xfs_lsn_t di_lsn;
470 :
471 : uint64_t di_flags2; /* more random flags */
472 : uint32_t di_cowextsize; /* basic cow extent size for file */
473 : uint8_t di_pad2[12]; /* more padding for future expansion */
474 :
475 : /* fields only written to during inode creation */
476 : xfs_log_timestamp_t di_crtime; /* time created */
477 : xfs_ino_t di_ino; /* inode number */
478 : uuid_t di_uuid; /* UUID of the filesystem */
479 :
480 : /* structure must be padded to 64 bit alignment */
481 : };
482 :
483 : #define xfs_log_dinode_size(mp) \
484 : (xfs_has_v3inodes((mp)) ? \
485 : sizeof(struct xfs_log_dinode) : \
486 : offsetof(struct xfs_log_dinode, di_next_unlinked))
487 :
488 : /*
489 : * Buffer Log Format definitions
490 : *
491 : * These are the physical dirty bitmap definitions for the log format structure.
492 : */
493 : #define XFS_BLF_CHUNK 128
494 : #define XFS_BLF_SHIFT 7
495 : #define BIT_TO_WORD_SHIFT 5
496 : #define NBWORD (NBBY * sizeof(unsigned int))
497 :
498 : /*
499 : * This flag indicates that the buffer contains on disk inodes
500 : * and requires special recovery handling.
501 : */
502 : #define XFS_BLF_INODE_BUF (1<<0)
503 :
504 : /*
505 : * This flag indicates that the buffer should not be replayed
506 : * during recovery because its blocks are being freed.
507 : */
508 : #define XFS_BLF_CANCEL (1<<1)
509 :
510 : /*
511 : * This flag indicates that the buffer contains on disk
512 : * user or group dquots and may require special recovery handling.
513 : */
514 : #define XFS_BLF_UDQUOT_BUF (1<<2)
515 : #define XFS_BLF_PDQUOT_BUF (1<<3)
516 : #define XFS_BLF_GDQUOT_BUF (1<<4)
517 :
518 : /*
519 : * This is the structure used to lay out a buf log item in the log. The data
520 : * map describes which 128 byte chunks of the buffer have been logged.
521 : *
522 : * The placement of blf_map_size causes blf_data_map to start at an odd
523 : * multiple of sizeof(unsigned int) offset within the struct. Because the data
524 : * bitmap size will always be an even number, the end of the data_map (and
525 : * therefore the structure) will also be at an odd multiple of sizeof(unsigned
526 : * int). Some 64-bit compilers will insert padding at the end of the struct to
527 : * ensure 64-bit alignment of blf_blkno, but 32-bit ones will not. Therefore,
528 : * XFS_BLF_DATAMAP_SIZE must be an odd number to make the padding explicit and
529 : * keep the structure size consistent between 32-bit and 64-bit platforms.
530 : */
531 : #define __XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
532 : #define XFS_BLF_DATAMAP_SIZE (__XFS_BLF_DATAMAP_SIZE + 1)
533 :
534 : typedef struct xfs_buf_log_format {
535 : unsigned short blf_type; /* buf log item type indicator */
536 : unsigned short blf_size; /* size of this item */
537 : unsigned short blf_flags; /* misc state */
538 : unsigned short blf_len; /* number of blocks in this buf */
539 : int64_t blf_blkno; /* starting blkno of this buf */
540 : unsigned int blf_map_size; /* used size of data bitmap in words */
541 : unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
542 : } xfs_buf_log_format_t;
543 :
544 : /*
545 : * All buffers now need to tell recovery where the magic number
546 : * is so that it can verify and calculate the CRCs on the buffer correctly
547 : * once the changes have been replayed into the buffer.
548 : *
549 : * The type value is held in the upper 5 bits of the blf_flags field, which is
550 : * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down.
551 : */
552 : #define XFS_BLFT_BITS 5
553 : #define XFS_BLFT_SHIFT 11
554 : #define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT)
555 :
556 : enum xfs_blft {
557 : XFS_BLFT_UNKNOWN_BUF = 0,
558 : XFS_BLFT_UDQUOT_BUF,
559 : XFS_BLFT_PDQUOT_BUF,
560 : XFS_BLFT_GDQUOT_BUF,
561 : XFS_BLFT_BTREE_BUF,
562 : XFS_BLFT_AGF_BUF,
563 : XFS_BLFT_AGFL_BUF,
564 : XFS_BLFT_AGI_BUF,
565 : XFS_BLFT_DINO_BUF,
566 : XFS_BLFT_SYMLINK_BUF,
567 : XFS_BLFT_DIR_BLOCK_BUF,
568 : XFS_BLFT_DIR_DATA_BUF,
569 : XFS_BLFT_DIR_FREE_BUF,
570 : XFS_BLFT_DIR_LEAF1_BUF,
571 : XFS_BLFT_DIR_LEAFN_BUF,
572 : XFS_BLFT_DA_NODE_BUF,
573 : XFS_BLFT_ATTR_LEAF_BUF,
574 : XFS_BLFT_ATTR_RMT_BUF,
575 : XFS_BLFT_SB_BUF,
576 : XFS_BLFT_RTBITMAP_BUF,
577 : XFS_BLFT_RTSUMMARY_BUF,
578 : XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
579 : };
580 :
581 : static inline void
582 6333305774 : xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
583 : {
584 6333305774 : ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
585 6333305774 : blf->blf_flags &= ~XFS_BLFT_MASK;
586 6333305774 : blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
587 6333305774 : }
588 :
589 : static inline uint16_t
590 : xfs_blft_from_flags(struct xfs_buf_log_format *blf)
591 : {
592 1775620032 : return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT;
593 : }
594 :
595 : /*
596 : * EFI/EFD log format definitions
597 : */
598 : typedef struct xfs_extent {
599 : xfs_fsblock_t ext_start;
600 : xfs_extlen_t ext_len;
601 : } xfs_extent_t;
602 :
603 : /*
604 : * Since an xfs_extent_t has types (start:64, len: 32)
605 : * there are different alignments on 32 bit and 64 bit kernels.
606 : * So we provide the different variants for use by a
607 : * conversion routine.
608 : */
609 : typedef struct xfs_extent_32 {
610 : uint64_t ext_start;
611 : uint32_t ext_len;
612 : } __attribute__((packed)) xfs_extent_32_t;
613 :
614 : typedef struct xfs_extent_64 {
615 : uint64_t ext_start;
616 : uint32_t ext_len;
617 : uint32_t ext_pad;
618 : } xfs_extent_64_t;
619 :
620 : /*
621 : * This is the structure used to lay out an efi log item in the
622 : * log. The efi_extents field is a variable size array whose
623 : * size is given by efi_nextents.
624 : */
625 : typedef struct xfs_efi_log_format {
626 : uint16_t efi_type; /* efi log item type */
627 : uint16_t efi_size; /* size of this item */
628 : uint32_t efi_nextents; /* # extents to free */
629 : uint64_t efi_id; /* efi identifier */
630 : xfs_extent_t efi_extents[]; /* array of extents to free */
631 : } xfs_efi_log_format_t;
632 :
633 : static inline size_t
634 : xfs_efi_log_format_sizeof(
635 : unsigned int nr)
636 : {
637 49465336 : return sizeof(struct xfs_efi_log_format) +
638 : nr * sizeof(struct xfs_extent);
639 : }
640 :
641 : typedef struct xfs_efi_log_format_32 {
642 : uint16_t efi_type; /* efi log item type */
643 : uint16_t efi_size; /* size of this item */
644 : uint32_t efi_nextents; /* # extents to free */
645 : uint64_t efi_id; /* efi identifier */
646 : xfs_extent_32_t efi_extents[]; /* array of extents to free */
647 : } __attribute__((packed)) xfs_efi_log_format_32_t;
648 :
649 : static inline size_t
650 : xfs_efi_log_format32_sizeof(
651 : unsigned int nr)
652 : {
653 69128 : return sizeof(struct xfs_efi_log_format_32) +
654 69128 : nr * sizeof(struct xfs_extent_32);
655 : }
656 :
657 : typedef struct xfs_efi_log_format_64 {
658 : uint16_t efi_type; /* efi log item type */
659 : uint16_t efi_size; /* size of this item */
660 : uint32_t efi_nextents; /* # extents to free */
661 : uint64_t efi_id; /* efi identifier */
662 : xfs_extent_64_t efi_extents[]; /* array of extents to free */
663 : } xfs_efi_log_format_64_t;
664 :
665 : static inline size_t
666 : xfs_efi_log_format64_sizeof(
667 : unsigned int nr)
668 : {
669 : return sizeof(struct xfs_efi_log_format_64) +
670 : nr * sizeof(struct xfs_extent_64);
671 : }
672 :
673 : /*
674 : * This is the structure used to lay out an efd log item in the
675 : * log. The efd_extents array is a variable size array whose
676 : * size is given by efd_nextents;
677 : */
678 : typedef struct xfs_efd_log_format {
679 : uint16_t efd_type; /* efd log item type */
680 : uint16_t efd_size; /* size of this item */
681 : uint32_t efd_nextents; /* # of extents freed */
682 : uint64_t efd_efi_id; /* id of corresponding efi */
683 : xfs_extent_t efd_extents[]; /* array of extents freed */
684 : } xfs_efd_log_format_t;
685 :
686 : static inline size_t
687 : xfs_efd_log_format_sizeof(
688 : unsigned int nr)
689 : {
690 311433 : return sizeof(struct xfs_efd_log_format) +
691 : nr * sizeof(struct xfs_extent);
692 : }
693 :
694 : typedef struct xfs_efd_log_format_32 {
695 : uint16_t efd_type; /* efd log item type */
696 : uint16_t efd_size; /* size of this item */
697 : uint32_t efd_nextents; /* # of extents freed */
698 : uint64_t efd_efi_id; /* id of corresponding efi */
699 : xfs_extent_32_t efd_extents[]; /* array of extents freed */
700 : } __attribute__((packed)) xfs_efd_log_format_32_t;
701 :
702 : static inline size_t
703 : xfs_efd_log_format32_sizeof(
704 : unsigned int nr)
705 : {
706 68644 : return sizeof(struct xfs_efd_log_format_32) +
707 68644 : nr * sizeof(struct xfs_extent_32);
708 : }
709 :
710 : typedef struct xfs_efd_log_format_64 {
711 : uint16_t efd_type; /* efd log item type */
712 : uint16_t efd_size; /* size of this item */
713 : uint32_t efd_nextents; /* # of extents freed */
714 : uint64_t efd_efi_id; /* id of corresponding efi */
715 : xfs_extent_64_t efd_extents[]; /* array of extents freed */
716 : } xfs_efd_log_format_64_t;
717 :
718 : static inline size_t
719 : xfs_efd_log_format64_sizeof(
720 : unsigned int nr)
721 : {
722 68644 : return sizeof(struct xfs_efd_log_format_64) +
723 : nr * sizeof(struct xfs_extent_64);
724 : }
725 :
726 : /*
727 : * RUI/RUD (reverse mapping) log format definitions
728 : */
729 : struct xfs_map_extent {
730 : uint64_t me_owner;
731 : uint64_t me_startblock;
732 : uint64_t me_startoff;
733 : uint32_t me_len;
734 : uint32_t me_flags;
735 : };
736 :
737 : /* rmap me_flags: upper bits are flags, lower byte is type code */
738 : #define XFS_RMAP_EXTENT_MAP 1
739 : #define XFS_RMAP_EXTENT_MAP_SHARED 2
740 : #define XFS_RMAP_EXTENT_UNMAP 3
741 : #define XFS_RMAP_EXTENT_UNMAP_SHARED 4
742 : #define XFS_RMAP_EXTENT_CONVERT 5
743 : #define XFS_RMAP_EXTENT_CONVERT_SHARED 6
744 : #define XFS_RMAP_EXTENT_ALLOC 7
745 : #define XFS_RMAP_EXTENT_FREE 8
746 : #define XFS_RMAP_EXTENT_TYPE_MASK 0xFF
747 :
748 : #define XFS_RMAP_EXTENT_ATTR_FORK (1U << 31)
749 : #define XFS_RMAP_EXTENT_BMBT_BLOCK (1U << 30)
750 : #define XFS_RMAP_EXTENT_UNWRITTEN (1U << 29)
751 :
752 : #define XFS_RMAP_EXTENT_FLAGS (XFS_RMAP_EXTENT_TYPE_MASK | \
753 : XFS_RMAP_EXTENT_ATTR_FORK | \
754 : XFS_RMAP_EXTENT_BMBT_BLOCK | \
755 : XFS_RMAP_EXTENT_UNWRITTEN)
756 :
757 : /*
758 : * This is the structure used to lay out an rui log item in the
759 : * log. The rui_extents field is a variable size array whose
760 : * size is given by rui_nextents.
761 : */
762 : struct xfs_rui_log_format {
763 : uint16_t rui_type; /* rui log item type */
764 : uint16_t rui_size; /* size of this item */
765 : uint32_t rui_nextents; /* # extents to free */
766 : uint64_t rui_id; /* rui identifier */
767 : struct xfs_map_extent rui_extents[]; /* array of extents to rmap */
768 : };
769 :
770 : static inline size_t
771 : xfs_rui_log_format_sizeof(
772 : unsigned int nr)
773 : {
774 429439593 : return sizeof(struct xfs_rui_log_format) +
775 214742198 : nr * sizeof(struct xfs_map_extent);
776 : }
777 :
778 : /*
779 : * This is the structure used to lay out an rud log item in the
780 : * log. The rud_extents array is a variable size array whose
781 : * size is given by rud_nextents;
782 : */
783 : struct xfs_rud_log_format {
784 : uint16_t rud_type; /* rud log item type */
785 : uint16_t rud_size; /* size of this item */
786 : uint32_t __pad;
787 : uint64_t rud_rui_id; /* id of corresponding rui */
788 : };
789 :
790 : /*
791 : * CUI/CUD (refcount update) log format definitions
792 : */
793 : struct xfs_phys_extent {
794 : uint64_t pe_startblock;
795 : uint32_t pe_len;
796 : uint32_t pe_flags;
797 : };
798 :
799 : /* refcount pe_flags: upper bits are flags, lower byte is type code */
800 : /* Type codes are taken directly from enum xfs_refcount_intent_type. */
801 : #define XFS_REFCOUNT_EXTENT_TYPE_MASK 0xFF
802 :
803 : #define XFS_REFCOUNT_EXTENT_FLAGS (XFS_REFCOUNT_EXTENT_TYPE_MASK)
804 :
805 : /*
806 : * This is the structure used to lay out a cui log item in the
807 : * log. The cui_extents field is a variable size array whose
808 : * size is given by cui_nextents.
809 : */
810 : struct xfs_cui_log_format {
811 : uint16_t cui_type; /* cui log item type */
812 : uint16_t cui_size; /* size of this item */
813 : uint32_t cui_nextents; /* # extents to free */
814 : uint64_t cui_id; /* cui identifier */
815 : struct xfs_phys_extent cui_extents[]; /* array of extents */
816 : };
817 :
818 : static inline size_t
819 : xfs_cui_log_format_sizeof(
820 : unsigned int nr)
821 : {
822 107619680 : return sizeof(struct xfs_cui_log_format) +
823 : nr * sizeof(struct xfs_phys_extent);
824 : }
825 :
826 : /*
827 : * This is the structure used to lay out a cud log item in the
828 : * log. The cud_extents array is a variable size array whose
829 : * size is given by cud_nextents;
830 : */
831 : struct xfs_cud_log_format {
832 : uint16_t cud_type; /* cud log item type */
833 : uint16_t cud_size; /* size of this item */
834 : uint32_t __pad;
835 : uint64_t cud_cui_id; /* id of corresponding cui */
836 : };
837 :
838 : /*
839 : * BUI/BUD (inode block mapping) log format definitions
840 : */
841 :
842 : /* bmbt me_flags: upper bits are flags, lower byte is type code */
843 : /* Type codes are taken directly from enum xfs_bmap_intent_type. */
844 : #define XFS_BMAP_EXTENT_TYPE_MASK 0xFF
845 :
846 : #define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
847 : #define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
848 : #define XFS_BMAP_EXTENT_REALTIME (1U << 29)
849 :
850 : #define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
851 : XFS_BMAP_EXTENT_ATTR_FORK | \
852 : XFS_BMAP_EXTENT_UNWRITTEN | \
853 : XFS_BMAP_EXTENT_REALTIME)
854 :
855 : /*
856 : * This is the structure used to lay out an bui log item in the
857 : * log. The bui_extents field is a variable size array whose
858 : * size is given by bui_nextents.
859 : */
860 : struct xfs_bui_log_format {
861 : uint16_t bui_type; /* bui log item type */
862 : uint16_t bui_size; /* size of this item */
863 : uint32_t bui_nextents; /* # extents to free */
864 : uint64_t bui_id; /* bui identifier */
865 : struct xfs_map_extent bui_extents[]; /* array of extents to bmap */
866 : };
867 :
868 : static inline size_t
869 : xfs_bui_log_format_sizeof(
870 : unsigned int nr)
871 : {
872 118507997 : return sizeof(struct xfs_bui_log_format) +
873 59254000 : nr * sizeof(struct xfs_map_extent);
874 : }
875 :
876 : /*
877 : * This is the structure used to lay out an bud log item in the
878 : * log. The bud_extents array is a variable size array whose
879 : * size is given by bud_nextents;
880 : */
881 : struct xfs_bud_log_format {
882 : uint16_t bud_type; /* bud log item type */
883 : uint16_t bud_size; /* size of this item */
884 : uint32_t __pad;
885 : uint64_t bud_bui_id; /* id of corresponding bui */
886 : };
887 :
888 : /*
889 : * SXI/SXD (extent swapping) log format definitions
890 : */
891 :
892 : struct xfs_swap_extent {
893 : uint64_t sx_inode1;
894 : uint64_t sx_inode2;
895 : uint64_t sx_startoff1;
896 : uint64_t sx_startoff2;
897 : uint64_t sx_blockcount;
898 : uint64_t sx_flags;
899 : int64_t sx_isize1;
900 : int64_t sx_isize2;
901 : };
902 :
903 : /* Swap extents between extended attribute forks. */
904 : #define XFS_SWAP_EXT_ATTR_FORK (1ULL << 0)
905 :
906 : /* Set the file sizes when finished. */
907 : #define XFS_SWAP_EXT_SET_SIZES (1ULL << 1)
908 :
909 : /*
910 : * Swap only the extents of the two files where the file allocation units
911 : * mapped to file1's range have been written to.
912 : */
913 : #define XFS_SWAP_EXT_INO1_WRITTEN (1ULL << 2)
914 :
915 : /* Clear the reflink flag from inode1 after the operation. */
916 : #define XFS_SWAP_EXT_CLEAR_INO1_REFLINK (1ULL << 3)
917 :
918 : /* Clear the reflink flag from inode2 after the operation. */
919 : #define XFS_SWAP_EXT_CLEAR_INO2_REFLINK (1ULL << 4)
920 :
921 : /* Try to convert inode2 from block to short format at the end, if possible. */
922 : #define XFS_SWAP_EXT_CVT_INO2_SF (1ULL << 5)
923 :
924 : #define XFS_SWAP_EXT_FLAGS (XFS_SWAP_EXT_ATTR_FORK | \
925 : XFS_SWAP_EXT_SET_SIZES | \
926 : XFS_SWAP_EXT_INO1_WRITTEN | \
927 : XFS_SWAP_EXT_CLEAR_INO1_REFLINK | \
928 : XFS_SWAP_EXT_CLEAR_INO2_REFLINK | \
929 : XFS_SWAP_EXT_CVT_INO2_SF)
930 :
931 : #define XFS_SWAP_EXT_STRINGS \
932 : { XFS_SWAP_EXT_ATTR_FORK, "ATTRFORK" }, \
933 : { XFS_SWAP_EXT_SET_SIZES, "SETSIZES" }, \
934 : { XFS_SWAP_EXT_INO1_WRITTEN, "INO1_WRITTEN" }, \
935 : { XFS_SWAP_EXT_CLEAR_INO1_REFLINK, "CLEAR_INO1_REFLINK" }, \
936 : { XFS_SWAP_EXT_CLEAR_INO2_REFLINK, "CLEAR_INO2_REFLINK" }, \
937 : { XFS_SWAP_EXT_CVT_INO2_SF, "CVT_INO2_SF" }
938 :
939 : /* This is the structure used to lay out an sxi log item in the log. */
940 : struct xfs_sxi_log_format {
941 : uint16_t sxi_type; /* sxi log item type */
942 : uint16_t sxi_size; /* size of this item */
943 : uint32_t __pad; /* must be zero */
944 : uint64_t sxi_id; /* sxi identifier */
945 : struct xfs_swap_extent sxi_extent; /* extent to swap */
946 : };
947 :
948 : /*
949 : * This is the structure used to lay out an sxd log item in the
950 : * log. The sxd_extents array is a variable size array whose
951 : * size is given by sxd_nextents;
952 : */
953 : struct xfs_sxd_log_format {
954 : uint16_t sxd_type; /* sxd log item type */
955 : uint16_t sxd_size; /* size of this item */
956 : uint32_t __pad;
957 : uint64_t sxd_sxi_id; /* id of corresponding bui */
958 : };
959 :
960 : /*
961 : * Dquot Log format definitions.
962 : *
963 : * The first two fields must be the type and size fitting into
964 : * 32 bits : log_recovery code assumes that.
965 : */
966 : typedef struct xfs_dq_logformat {
967 : uint16_t qlf_type; /* dquot log item type */
968 : uint16_t qlf_size; /* size of this item */
969 : xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
970 : int64_t qlf_blkno; /* blkno of dquot buffer */
971 : int32_t qlf_len; /* len of dquot buffer */
972 : uint32_t qlf_boffset; /* off of dquot in buffer */
973 : } xfs_dq_logformat_t;
974 :
975 : /*
976 : * log format struct for QUOTAOFF records.
977 : * The first two fields must be the type and size fitting into
978 : * 32 bits : log_recovery code assumes that.
979 : * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
980 : * to the first and ensures that the first logitem is taken out of the AIL
981 : * only when the last one is securely committed.
982 : */
983 : typedef struct xfs_qoff_logformat {
984 : unsigned short qf_type; /* quotaoff log item type */
985 : unsigned short qf_size; /* size of this item */
986 : unsigned int qf_flags; /* USR and/or GRP */
987 : char qf_pad[12]; /* padding for future */
988 : } xfs_qoff_logformat_t;
989 :
990 : /*
991 : * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
992 : */
993 : #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
994 : #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
995 : #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
996 : #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
997 : #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
998 : #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
999 : #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
1000 :
1001 : /*
1002 : * Conversion to and from the combined OQUOTA flag (if necessary)
1003 : * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
1004 : */
1005 : #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */
1006 : #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */
1007 : #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */
1008 : #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
1009 :
1010 : #define XFS_ALL_QUOTA_ACCT \
1011 : (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
1012 : #define XFS_ALL_QUOTA_ENFD \
1013 : (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
1014 : #define XFS_ALL_QUOTA_CHKD \
1015 : (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
1016 :
1017 : #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
1018 : XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
1019 : XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
1020 : XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
1021 : XFS_PQUOTA_CHKD)
1022 :
1023 : /*
1024 : * Inode create log item structure
1025 : *
1026 : * Log recovery assumes the first two entries are the type and size and they fit
1027 : * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so
1028 : * decoding can be done correctly.
1029 : */
1030 : struct xfs_icreate_log {
1031 : uint16_t icl_type; /* type of log format structure */
1032 : uint16_t icl_size; /* size of log format structure */
1033 : __be32 icl_ag; /* ag being allocated in */
1034 : __be32 icl_agbno; /* start block of inode range */
1035 : __be32 icl_count; /* number of inodes to initialise */
1036 : __be32 icl_isize; /* size of inodes */
1037 : __be32 icl_length; /* length of extent to initialise */
1038 : __be32 icl_gen; /* inode generation number to use */
1039 : };
1040 :
1041 : /*
1042 : * Flags for deferred attribute operations.
1043 : * Upper bits are flags, lower byte is type code
1044 : */
1045 : #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */
1046 : #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */
1047 : #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */
1048 : #define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */
1049 : #define XFS_ATTRI_OP_FLAGS_NVSET 5 /* Set attr with w/ vlookup */
1050 : #define XFS_ATTRI_OP_FLAGS_NVREPLACE 6 /* Replace attr name and val */
1051 : #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */
1052 :
1053 : /*
1054 : * alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should
1055 : * never have any other bits set.
1056 : */
1057 : #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \
1058 : XFS_ATTR_SECURE | \
1059 : XFS_ATTR_PARENT | \
1060 : XFS_ATTR_INCOMPLETE)
1061 :
1062 : /*
1063 : * This is the structure used to lay out an attr log item in the
1064 : * log.
1065 : */
1066 : struct xfs_attri_log_format {
1067 : uint16_t alfi_type; /* attri log item type */
1068 : uint16_t alfi_size; /* size of this item */
1069 :
1070 : /*
1071 : * For NVREPLACE, this is the length of the new xattr value.
1072 : * alfi_value_len contains the length of the old xattr value.
1073 : */
1074 : uint32_t alfi_new_value_len;
1075 :
1076 : uint64_t alfi_id; /* attri identifier */
1077 : uint64_t alfi_ino; /* the inode for this attr operation */
1078 : uint32_t alfi_op_flags; /* marks the op as a set or remove */
1079 : union {
1080 : uint32_t alfi_name_len; /* attr name length */
1081 : struct {
1082 : /*
1083 : * For NVREPLACE, these are the lengths of the old and
1084 : * new attr name.
1085 : */
1086 : uint16_t alfi_old_name_len;
1087 : uint16_t alfi_new_name_len;
1088 : };
1089 : };
1090 : uint32_t alfi_value_len; /* attr value length */
1091 : uint32_t alfi_attr_filter;/* attr filter flags */
1092 : };
1093 :
1094 : struct xfs_attrd_log_format {
1095 : uint16_t alfd_type; /* attrd log item type */
1096 : uint16_t alfd_size; /* size of this item */
1097 : uint32_t __pad; /* pad to 64 bit aligned */
1098 : uint64_t alfd_alf_id; /* id of corresponding attri */
1099 : };
1100 :
1101 : #endif /* __XFS_LOG_FORMAT_H__ */
|