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 373036595 : return ((xfs_lsn_t)cycle << 32) | block;
60 : }
61 :
62 : static inline uint xlog_get_cycle(char *ptr)
63 : {
64 131912399 : if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
65 6519260 : return be32_to_cpu(*((__be32 *)ptr + 1));
66 : else
67 : 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 556012453 : return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
372 : }
373 :
374 : static inline int xfs_ilog_fext(int w)
375 : {
376 674508421 : return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
377 : }
378 :
379 : static inline int xfs_ilog_fdata(int w)
380 : {
381 4755955 : 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 18181178544 : xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
583 : {
584 18181178544 : ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
585 18181178544 : blf->blf_flags &= ~XFS_BLFT_MASK;
586 18181178544 : blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
587 18181178544 : }
588 :
589 : static inline uint16_t
590 : xfs_blft_from_flags(struct xfs_buf_log_format *blf)
591 : {
592 4206703065 : 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 : * This EFI extent describes a realtime extent. We can never free more than
605 : * XFS_MAX_BMBT_EXTLEN (2^21) blocks at a time, so we know that the upper bits
606 : * of ext_len cannot be used.
607 : */
608 : #define XFS_EFI_EXTLEN_REALTIME_EXT (1U << 31)
609 :
610 : /*
611 : * Since an xfs_extent_t has types (start:64, len: 32)
612 : * there are different alignments on 32 bit and 64 bit kernels.
613 : * So we provide the different variants for use by a
614 : * conversion routine.
615 : */
616 : typedef struct xfs_extent_32 {
617 : uint64_t ext_start;
618 : uint32_t ext_len;
619 : } __attribute__((packed)) xfs_extent_32_t;
620 :
621 : typedef struct xfs_extent_64 {
622 : uint64_t ext_start;
623 : uint32_t ext_len;
624 : uint32_t ext_pad;
625 : } xfs_extent_64_t;
626 :
627 : /*
628 : * This is the structure used to lay out an efi log item in the
629 : * log. The efi_extents field is a variable size array whose
630 : * size is given by efi_nextents.
631 : */
632 : typedef struct xfs_efi_log_format {
633 : uint16_t efi_type; /* efi log item type */
634 : uint16_t efi_size; /* size of this item */
635 : uint32_t efi_nextents; /* # extents to free */
636 : uint64_t efi_id; /* efi identifier */
637 : xfs_extent_t efi_extents[]; /* array of extents to free */
638 : } xfs_efi_log_format_t;
639 :
640 : static inline size_t
641 : xfs_efi_log_format_sizeof(
642 : unsigned int nr)
643 : {
644 141783801 : return sizeof(struct xfs_efi_log_format) +
645 : nr * sizeof(struct xfs_extent);
646 : }
647 :
648 : typedef struct xfs_efi_log_format_32 {
649 : uint16_t efi_type; /* efi log item type */
650 : uint16_t efi_size; /* size of this item */
651 : uint32_t efi_nextents; /* # extents to free */
652 : uint64_t efi_id; /* efi identifier */
653 : xfs_extent_32_t efi_extents[]; /* array of extents to free */
654 : } __attribute__((packed)) xfs_efi_log_format_32_t;
655 :
656 : static inline size_t
657 : xfs_efi_log_format32_sizeof(
658 : unsigned int nr)
659 : {
660 72335 : return sizeof(struct xfs_efi_log_format_32) +
661 72335 : nr * sizeof(struct xfs_extent_32);
662 : }
663 :
664 : typedef struct xfs_efi_log_format_64 {
665 : uint16_t efi_type; /* efi log item type */
666 : uint16_t efi_size; /* size of this item */
667 : uint32_t efi_nextents; /* # extents to free */
668 : uint64_t efi_id; /* efi identifier */
669 : xfs_extent_64_t efi_extents[]; /* array of extents to free */
670 : } xfs_efi_log_format_64_t;
671 :
672 : static inline size_t
673 : xfs_efi_log_format64_sizeof(
674 : unsigned int nr)
675 : {
676 : return sizeof(struct xfs_efi_log_format_64) +
677 : nr * sizeof(struct xfs_extent_64);
678 : }
679 :
680 : /*
681 : * This is the structure used to lay out an efd log item in the
682 : * log. The efd_extents array is a variable size array whose
683 : * size is given by efd_nextents;
684 : */
685 : typedef struct xfs_efd_log_format {
686 : uint16_t efd_type; /* efd log item type */
687 : uint16_t efd_size; /* size of this item */
688 : uint32_t efd_nextents; /* # of extents freed */
689 : uint64_t efd_efi_id; /* id of corresponding efi */
690 : xfs_extent_t efd_extents[]; /* array of extents freed */
691 : } xfs_efd_log_format_t;
692 :
693 : static inline size_t
694 : xfs_efd_log_format_sizeof(
695 : unsigned int nr)
696 : {
697 1034323 : return sizeof(struct xfs_efd_log_format) +
698 : nr * sizeof(struct xfs_extent);
699 : }
700 :
701 : typedef struct xfs_efd_log_format_32 {
702 : uint16_t efd_type; /* efd log item type */
703 : uint16_t efd_size; /* size of this item */
704 : uint32_t efd_nextents; /* # of extents freed */
705 : uint64_t efd_efi_id; /* id of corresponding efi */
706 : xfs_extent_32_t efd_extents[]; /* array of extents freed */
707 : } __attribute__((packed)) xfs_efd_log_format_32_t;
708 :
709 : static inline size_t
710 : xfs_efd_log_format32_sizeof(
711 : unsigned int nr)
712 : {
713 71727 : return sizeof(struct xfs_efd_log_format_32) +
714 71727 : nr * sizeof(struct xfs_extent_32);
715 : }
716 :
717 : typedef struct xfs_efd_log_format_64 {
718 : uint16_t efd_type; /* efd log item type */
719 : uint16_t efd_size; /* size of this item */
720 : uint32_t efd_nextents; /* # of extents freed */
721 : uint64_t efd_efi_id; /* id of corresponding efi */
722 : xfs_extent_64_t efd_extents[]; /* array of extents freed */
723 : } xfs_efd_log_format_64_t;
724 :
725 : static inline size_t
726 : xfs_efd_log_format64_sizeof(
727 : unsigned int nr)
728 : {
729 71727 : return sizeof(struct xfs_efd_log_format_64) +
730 : nr * sizeof(struct xfs_extent_64);
731 : }
732 :
733 : /*
734 : * RUI/RUD (reverse mapping) log format definitions
735 : */
736 : struct xfs_map_extent {
737 : uint64_t me_owner;
738 : uint64_t me_startblock;
739 : uint64_t me_startoff;
740 : uint32_t me_len;
741 : uint32_t me_flags;
742 : };
743 :
744 : /* rmap me_flags: upper bits are flags, lower byte is type code */
745 : #define XFS_RMAP_EXTENT_MAP 1
746 : #define XFS_RMAP_EXTENT_MAP_SHARED 2
747 : #define XFS_RMAP_EXTENT_UNMAP 3
748 : #define XFS_RMAP_EXTENT_UNMAP_SHARED 4
749 : #define XFS_RMAP_EXTENT_CONVERT 5
750 : #define XFS_RMAP_EXTENT_CONVERT_SHARED 6
751 : #define XFS_RMAP_EXTENT_ALLOC 7
752 : #define XFS_RMAP_EXTENT_FREE 8
753 : #define XFS_RMAP_EXTENT_TYPE_MASK 0xFF
754 :
755 : #define XFS_RMAP_EXTENT_ATTR_FORK (1U << 31)
756 : #define XFS_RMAP_EXTENT_BMBT_BLOCK (1U << 30)
757 : #define XFS_RMAP_EXTENT_UNWRITTEN (1U << 29)
758 : #define XFS_RMAP_EXTENT_REALTIME (1U << 28)
759 :
760 : #define XFS_RMAP_EXTENT_FLAGS (XFS_RMAP_EXTENT_TYPE_MASK | \
761 : XFS_RMAP_EXTENT_ATTR_FORK | \
762 : XFS_RMAP_EXTENT_BMBT_BLOCK | \
763 : XFS_RMAP_EXTENT_UNWRITTEN | \
764 : XFS_RMAP_EXTENT_REALTIME)
765 :
766 : /*
767 : * This is the structure used to lay out an rui log item in the
768 : * log. The rui_extents field is a variable size array whose
769 : * size is given by rui_nextents.
770 : */
771 : struct xfs_rui_log_format {
772 : uint16_t rui_type; /* rui log item type */
773 : uint16_t rui_size; /* size of this item */
774 : uint32_t rui_nextents; /* # extents to free */
775 : uint64_t rui_id; /* rui identifier */
776 : struct xfs_map_extent rui_extents[]; /* array of extents to rmap */
777 : };
778 :
779 : static inline size_t
780 : xfs_rui_log_format_sizeof(
781 : unsigned int nr)
782 : {
783 1458013401 : return sizeof(struct xfs_rui_log_format) +
784 729034775 : nr * sizeof(struct xfs_map_extent);
785 : }
786 :
787 : /*
788 : * This is the structure used to lay out an rud log item in the
789 : * log. The rud_extents array is a variable size array whose
790 : * size is given by rud_nextents;
791 : */
792 : struct xfs_rud_log_format {
793 : uint16_t rud_type; /* rud log item type */
794 : uint16_t rud_size; /* size of this item */
795 : uint32_t __pad;
796 : uint64_t rud_rui_id; /* id of corresponding rui */
797 : };
798 :
799 : /*
800 : * CUI/CUD (refcount update) log format definitions
801 : */
802 : struct xfs_phys_extent {
803 : uint64_t pe_startblock;
804 : uint32_t pe_len;
805 : uint32_t pe_flags;
806 : };
807 :
808 : /* refcount pe_flags: upper bits are flags, lower byte is type code */
809 : /* Type codes are taken directly from enum xfs_refcount_intent_type. */
810 : #define XFS_REFCOUNT_EXTENT_TYPE_MASK 0xFF
811 :
812 : #define XFS_REFCOUNT_EXTENT_REALTIME (1U << 31)
813 :
814 : #define XFS_REFCOUNT_EXTENT_FLAGS (XFS_REFCOUNT_EXTENT_TYPE_MASK | \
815 : XFS_REFCOUNT_EXTENT_REALTIME)
816 :
817 : /*
818 : * This is the structure used to lay out a cui log item in the
819 : * log. The cui_extents field is a variable size array whose
820 : * size is given by cui_nextents.
821 : */
822 : struct xfs_cui_log_format {
823 : uint16_t cui_type; /* cui log item type */
824 : uint16_t cui_size; /* size of this item */
825 : uint32_t cui_nextents; /* # extents to free */
826 : uint64_t cui_id; /* cui identifier */
827 : struct xfs_phys_extent cui_extents[]; /* array of extents */
828 : };
829 :
830 : static inline size_t
831 : xfs_cui_log_format_sizeof(
832 : unsigned int nr)
833 : {
834 291338698 : return sizeof(struct xfs_cui_log_format) +
835 : nr * sizeof(struct xfs_phys_extent);
836 : }
837 :
838 : /*
839 : * This is the structure used to lay out a cud log item in the
840 : * log. The cud_extents array is a variable size array whose
841 : * size is given by cud_nextents;
842 : */
843 : struct xfs_cud_log_format {
844 : uint16_t cud_type; /* cud log item type */
845 : uint16_t cud_size; /* size of this item */
846 : uint32_t __pad;
847 : uint64_t cud_cui_id; /* id of corresponding cui */
848 : };
849 :
850 : /*
851 : * BUI/BUD (inode block mapping) log format definitions
852 : */
853 :
854 : /* bmbt me_flags: upper bits are flags, lower byte is type code */
855 : /* Type codes are taken directly from enum xfs_bmap_intent_type. */
856 : #define XFS_BMAP_EXTENT_TYPE_MASK 0xFF
857 :
858 : #define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
859 : #define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
860 : #define XFS_BMAP_EXTENT_REALTIME (1U << 29)
861 :
862 : #define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
863 : XFS_BMAP_EXTENT_ATTR_FORK | \
864 : XFS_BMAP_EXTENT_UNWRITTEN | \
865 : XFS_BMAP_EXTENT_REALTIME)
866 :
867 : /*
868 : * This is the structure used to lay out an bui log item in the
869 : * log. The bui_extents field is a variable size array whose
870 : * size is given by bui_nextents.
871 : */
872 : struct xfs_bui_log_format {
873 : uint16_t bui_type; /* bui log item type */
874 : uint16_t bui_size; /* size of this item */
875 : uint32_t bui_nextents; /* # extents to free */
876 : uint64_t bui_id; /* bui identifier */
877 : struct xfs_map_extent bui_extents[]; /* array of extents to bmap */
878 : };
879 :
880 : static inline size_t
881 : xfs_bui_log_format_sizeof(
882 : unsigned int nr)
883 : {
884 435959158 : return sizeof(struct xfs_bui_log_format) +
885 217979415 : nr * sizeof(struct xfs_map_extent);
886 : }
887 :
888 : /*
889 : * This is the structure used to lay out an bud log item in the
890 : * log. The bud_extents array is a variable size array whose
891 : * size is given by bud_nextents;
892 : */
893 : struct xfs_bud_log_format {
894 : uint16_t bud_type; /* bud log item type */
895 : uint16_t bud_size; /* size of this item */
896 : uint32_t __pad;
897 : uint64_t bud_bui_id; /* id of corresponding bui */
898 : };
899 :
900 : /*
901 : * SXI/SXD (extent swapping) log format definitions
902 : */
903 :
904 : struct xfs_swap_extent {
905 : uint64_t sx_inode1;
906 : uint64_t sx_inode2;
907 : uint64_t sx_startoff1;
908 : uint64_t sx_startoff2;
909 : uint64_t sx_blockcount;
910 : uint64_t sx_flags;
911 : int64_t sx_isize1;
912 : int64_t sx_isize2;
913 : };
914 :
915 : /* Swap extents between extended attribute forks. */
916 : #define XFS_SWAP_EXT_ATTR_FORK (1ULL << 0)
917 :
918 : /* Set the file sizes when finished. */
919 : #define XFS_SWAP_EXT_SET_SIZES (1ULL << 1)
920 :
921 : /*
922 : * Swap only the extents of the two files where the file allocation units
923 : * mapped to file1's range have been written to.
924 : */
925 : #define XFS_SWAP_EXT_INO1_WRITTEN (1ULL << 2)
926 :
927 : /* Clear the reflink flag from inode1 after the operation. */
928 : #define XFS_SWAP_EXT_CLEAR_INO1_REFLINK (1ULL << 3)
929 :
930 : /* Clear the reflink flag from inode2 after the operation. */
931 : #define XFS_SWAP_EXT_CLEAR_INO2_REFLINK (1ULL << 4)
932 :
933 : /* Try to convert inode2 from block to short format at the end, if possible. */
934 : #define XFS_SWAP_EXT_CVT_INO2_SF (1ULL << 5)
935 :
936 : #define XFS_SWAP_EXT_FLAGS (XFS_SWAP_EXT_ATTR_FORK | \
937 : XFS_SWAP_EXT_SET_SIZES | \
938 : XFS_SWAP_EXT_INO1_WRITTEN | \
939 : XFS_SWAP_EXT_CLEAR_INO1_REFLINK | \
940 : XFS_SWAP_EXT_CLEAR_INO2_REFLINK | \
941 : XFS_SWAP_EXT_CVT_INO2_SF)
942 :
943 : #define XFS_SWAP_EXT_STRINGS \
944 : { XFS_SWAP_EXT_ATTR_FORK, "ATTRFORK" }, \
945 : { XFS_SWAP_EXT_SET_SIZES, "SETSIZES" }, \
946 : { XFS_SWAP_EXT_INO1_WRITTEN, "INO1_WRITTEN" }, \
947 : { XFS_SWAP_EXT_CLEAR_INO1_REFLINK, "CLEAR_INO1_REFLINK" }, \
948 : { XFS_SWAP_EXT_CLEAR_INO2_REFLINK, "CLEAR_INO2_REFLINK" }, \
949 : { XFS_SWAP_EXT_CVT_INO2_SF, "CVT_INO2_SF" }
950 :
951 : /* This is the structure used to lay out an sxi log item in the log. */
952 : struct xfs_sxi_log_format {
953 : uint16_t sxi_type; /* sxi log item type */
954 : uint16_t sxi_size; /* size of this item */
955 : uint32_t __pad; /* must be zero */
956 : uint64_t sxi_id; /* sxi identifier */
957 : struct xfs_swap_extent sxi_extent; /* extent to swap */
958 : };
959 :
960 : /*
961 : * This is the structure used to lay out an sxd log item in the
962 : * log. The sxd_extents array is a variable size array whose
963 : * size is given by sxd_nextents;
964 : */
965 : struct xfs_sxd_log_format {
966 : uint16_t sxd_type; /* sxd log item type */
967 : uint16_t sxd_size; /* size of this item */
968 : uint32_t __pad;
969 : uint64_t sxd_sxi_id; /* id of corresponding bui */
970 : };
971 :
972 : /*
973 : * Dquot Log format definitions.
974 : *
975 : * The first two fields must be the type and size fitting into
976 : * 32 bits : log_recovery code assumes that.
977 : */
978 : typedef struct xfs_dq_logformat {
979 : uint16_t qlf_type; /* dquot log item type */
980 : uint16_t qlf_size; /* size of this item */
981 : xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
982 : int64_t qlf_blkno; /* blkno of dquot buffer */
983 : int32_t qlf_len; /* len of dquot buffer */
984 : uint32_t qlf_boffset; /* off of dquot in buffer */
985 : } xfs_dq_logformat_t;
986 :
987 : /*
988 : * log format struct for QUOTAOFF records.
989 : * The first two fields must be the type and size fitting into
990 : * 32 bits : log_recovery code assumes that.
991 : * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
992 : * to the first and ensures that the first logitem is taken out of the AIL
993 : * only when the last one is securely committed.
994 : */
995 : typedef struct xfs_qoff_logformat {
996 : unsigned short qf_type; /* quotaoff log item type */
997 : unsigned short qf_size; /* size of this item */
998 : unsigned int qf_flags; /* USR and/or GRP */
999 : char qf_pad[12]; /* padding for future */
1000 : } xfs_qoff_logformat_t;
1001 :
1002 : /*
1003 : * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
1004 : */
1005 : #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
1006 : #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
1007 : #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
1008 : #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
1009 : #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
1010 : #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
1011 : #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
1012 :
1013 : /*
1014 : * Conversion to and from the combined OQUOTA flag (if necessary)
1015 : * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
1016 : */
1017 : #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */
1018 : #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */
1019 : #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */
1020 : #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
1021 :
1022 : #define XFS_ALL_QUOTA_ACCT \
1023 : (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
1024 : #define XFS_ALL_QUOTA_ENFD \
1025 : (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
1026 : #define XFS_ALL_QUOTA_CHKD \
1027 : (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
1028 :
1029 : #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
1030 : XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
1031 : XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
1032 : XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
1033 : XFS_PQUOTA_CHKD)
1034 :
1035 : /*
1036 : * Inode create log item structure
1037 : *
1038 : * Log recovery assumes the first two entries are the type and size and they fit
1039 : * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so
1040 : * decoding can be done correctly.
1041 : */
1042 : struct xfs_icreate_log {
1043 : uint16_t icl_type; /* type of log format structure */
1044 : uint16_t icl_size; /* size of log format structure */
1045 : __be32 icl_ag; /* ag being allocated in */
1046 : __be32 icl_agbno; /* start block of inode range */
1047 : __be32 icl_count; /* number of inodes to initialise */
1048 : __be32 icl_isize; /* size of inodes */
1049 : __be32 icl_length; /* length of extent to initialise */
1050 : __be32 icl_gen; /* inode generation number to use */
1051 : };
1052 :
1053 : /*
1054 : * Flags for deferred attribute operations.
1055 : * Upper bits are flags, lower byte is type code
1056 : */
1057 : #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */
1058 : #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */
1059 : #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */
1060 : #define XFS_ATTRI_OP_FLAGS_NVREMOVE 4 /* Remove attr w/ vlookup */
1061 : #define XFS_ATTRI_OP_FLAGS_NVSET 5 /* Set attr with w/ vlookup */
1062 : #define XFS_ATTRI_OP_FLAGS_NVREPLACE 6 /* Replace attr name and val */
1063 : #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */
1064 :
1065 : /*
1066 : * alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should
1067 : * never have any other bits set.
1068 : */
1069 : #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \
1070 : XFS_ATTR_SECURE | \
1071 : XFS_ATTR_PARENT | \
1072 : XFS_ATTR_INCOMPLETE)
1073 :
1074 : /*
1075 : * This is the structure used to lay out an attr log item in the
1076 : * log.
1077 : */
1078 : struct xfs_attri_log_format {
1079 : uint16_t alfi_type; /* attri log item type */
1080 : uint16_t alfi_size; /* size of this item */
1081 :
1082 : /*
1083 : * For NVREPLACE, this is the length of the new xattr value.
1084 : * alfi_value_len contains the length of the old xattr value.
1085 : */
1086 : uint32_t alfi_new_value_len;
1087 :
1088 : uint64_t alfi_id; /* attri identifier */
1089 : uint64_t alfi_ino; /* the inode for this attr operation */
1090 : uint32_t alfi_op_flags; /* marks the op as a set or remove */
1091 : union {
1092 : uint32_t alfi_name_len; /* attr name length */
1093 : struct {
1094 : /*
1095 : * For NVREPLACE, these are the lengths of the old and
1096 : * new attr name.
1097 : */
1098 : uint16_t alfi_old_name_len;
1099 : uint16_t alfi_new_name_len;
1100 : };
1101 : };
1102 : uint32_t alfi_value_len; /* attr value length */
1103 : uint32_t alfi_attr_filter;/* attr filter flags */
1104 : };
1105 :
1106 : struct xfs_attrd_log_format {
1107 : uint16_t alfd_type; /* attrd log item type */
1108 : uint16_t alfd_size; /* size of this item */
1109 : uint32_t __pad; /* pad to 64 bit aligned */
1110 : uint64_t alfd_alf_id; /* id of corresponding attri */
1111 : };
1112 :
1113 : #endif /* __XFS_LOG_FORMAT_H__ */
|