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
xlog_assign_lsn(uint cycle,uint block)57 static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
58 {
59 return ((xfs_lsn_t)cycle << 32) | block;
60 }
61
xlog_get_cycle(char * ptr)62 static inline uint xlog_get_cycle(char *ptr)
63 {
64 if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
65 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_XMI_FORMAT 31
121 #define XLOG_REG_TYPE_XMD_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_XMI 0x1248 /* mapping exchange intent */
250 #define XFS_LI_XMD 0x1249 /* mapping exchange done */
251 #define XFS_LI_EFI_RT 0x124a /* realtime extent free intent */
252 #define XFS_LI_EFD_RT 0x124b /* realtime extent free done */
253 #define XFS_LI_RUI_RT 0x124c /* realtime rmap update intent */
254 #define XFS_LI_RUD_RT 0x124d /* realtime rmap update done */
255 #define XFS_LI_CUI_RT 0x124e /* realtime refcount update intent */
256 #define XFS_LI_CUD_RT 0x124f /* realtime refcount update done */
257
258 #define XFS_LI_TYPE_DESC \
259 { XFS_LI_EFI, "XFS_LI_EFI" }, \
260 { XFS_LI_EFD, "XFS_LI_EFD" }, \
261 { XFS_LI_IUNLINK, "XFS_LI_IUNLINK" }, \
262 { XFS_LI_INODE, "XFS_LI_INODE" }, \
263 { XFS_LI_BUF, "XFS_LI_BUF" }, \
264 { XFS_LI_DQUOT, "XFS_LI_DQUOT" }, \
265 { XFS_LI_QUOTAOFF, "XFS_LI_QUOTAOFF" }, \
266 { XFS_LI_ICREATE, "XFS_LI_ICREATE" }, \
267 { XFS_LI_RUI, "XFS_LI_RUI" }, \
268 { XFS_LI_RUD, "XFS_LI_RUD" }, \
269 { XFS_LI_CUI, "XFS_LI_CUI" }, \
270 { XFS_LI_CUD, "XFS_LI_CUD" }, \
271 { XFS_LI_BUI, "XFS_LI_BUI" }, \
272 { XFS_LI_BUD, "XFS_LI_BUD" }, \
273 { XFS_LI_ATTRI, "XFS_LI_ATTRI" }, \
274 { XFS_LI_ATTRD, "XFS_LI_ATTRD" }, \
275 { XFS_LI_XMI, "XFS_LI_XMI" }, \
276 { XFS_LI_XMD, "XFS_LI_XMD" }, \
277 { XFS_LI_EFI_RT, "XFS_LI_EFI_RT" }, \
278 { XFS_LI_EFD_RT, "XFS_LI_EFD_RT" }, \
279 { XFS_LI_RUI_RT, "XFS_LI_RUI_RT" }, \
280 { XFS_LI_RUD_RT, "XFS_LI_RUD_RT" }, \
281 { XFS_LI_CUI_RT, "XFS_LI_CUI_RT" }, \
282 { XFS_LI_CUD_RT, "XFS_LI_CUD_RT" }
283
284 /*
285 * Inode Log Item Format definitions.
286 *
287 * This is the structure used to lay out an inode log item in the
288 * log. The size of the inline data/extents/b-tree root to be logged
289 * (if any) is indicated in the ilf_dsize field. Changes to this structure
290 * must be added on to the end.
291 */
292 struct xfs_inode_log_format {
293 uint16_t ilf_type; /* inode log item type */
294 uint16_t ilf_size; /* size of this item */
295 uint32_t ilf_fields; /* flags for fields logged */
296 uint16_t ilf_asize; /* size of attr d/ext/root */
297 uint16_t ilf_dsize; /* size of data/ext/root */
298 uint32_t ilf_pad; /* pad for 64 bit boundary */
299 uint64_t ilf_ino; /* inode number */
300 union {
301 uint32_t ilfu_rdev; /* rdev value for dev inode*/
302 uint8_t __pad[16]; /* unused */
303 } ilf_u;
304 int64_t ilf_blkno; /* blkno of inode buffer */
305 int32_t ilf_len; /* len of inode buffer */
306 int32_t ilf_boffset; /* off of inode in buffer */
307 };
308
309 /*
310 * Old 32 bit systems will log in this format without the 64 bit
311 * alignment padding. Recovery will detect this and convert it to the
312 * correct format.
313 */
314 struct xfs_inode_log_format_32 {
315 uint16_t ilf_type; /* inode log item type */
316 uint16_t ilf_size; /* size of this item */
317 uint32_t ilf_fields; /* flags for fields logged */
318 uint16_t ilf_asize; /* size of attr d/ext/root */
319 uint16_t ilf_dsize; /* size of data/ext/root */
320 uint64_t ilf_ino; /* inode number */
321 union {
322 uint32_t ilfu_rdev; /* rdev value for dev inode*/
323 uint8_t __pad[16]; /* unused */
324 } ilf_u;
325 int64_t ilf_blkno; /* blkno of inode buffer */
326 int32_t ilf_len; /* len of inode buffer */
327 int32_t ilf_boffset; /* off of inode in buffer */
328 } __attribute__((packed));
329
330
331 /*
332 * Flags for xfs_trans_log_inode flags field.
333 */
334 #define XFS_ILOG_CORE 0x001 /* log standard inode fields */
335 #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */
336 #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
337 #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */
338 #define XFS_ILOG_DEV 0x010 /* log the dev field */
339 #define XFS_ILOG_UUID 0x020 /* added long ago, but never used */
340 #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */
341 #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */
342 #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */
343 #define XFS_ILOG_DOWNER 0x200 /* change the data fork owner on replay */
344 #define XFS_ILOG_AOWNER 0x400 /* change the attr fork owner on replay */
345
346 /*
347 * The timestamps are dirty, but not necessarily anything else in the inode
348 * core. Unlike the other fields above this one must never make it to disk
349 * in the ilf_fields of the inode_log_format, but is purely store in-memory in
350 * ili_fields in the inode_log_item.
351 */
352 #define XFS_ILOG_TIMESTAMP 0x4000
353
354 /*
355 * The version field has been changed, but not necessarily anything else of
356 * interest. This must never make it to disk - it is used purely to ensure that
357 * the inode item ->precommit operation can update the fsync flag triggers
358 * in the inode item correctly.
359 */
360 #define XFS_ILOG_IVERSION 0x8000
361
362 #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \
363 XFS_ILOG_DBROOT)
364
365 #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \
366 XFS_ILOG_ABROOT)
367
368 #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \
369 XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \
370 XFS_ILOG_DEV | XFS_ILOG_ADATA | \
371 XFS_ILOG_AEXT | XFS_ILOG_ABROOT | \
372 XFS_ILOG_TIMESTAMP | XFS_ILOG_DOWNER | \
373 XFS_ILOG_AOWNER)
374
xfs_ilog_fbroot(int w)375 static inline int xfs_ilog_fbroot(int w)
376 {
377 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
378 }
379
xfs_ilog_fext(int w)380 static inline int xfs_ilog_fext(int w)
381 {
382 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
383 }
384
xfs_ilog_fdata(int w)385 static inline int xfs_ilog_fdata(int w)
386 {
387 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
388 }
389
390 /*
391 * Incore version of the on-disk inode core structures. We log this directly
392 * into the journal in host CPU format (for better or worse) and as such
393 * directly mirrors the xfs_dinode structure as it must contain all the same
394 * information.
395 */
396 typedef uint64_t xfs_log_timestamp_t;
397
398 /* Legacy timestamp encoding format. */
399 struct xfs_log_legacy_timestamp {
400 int32_t t_sec; /* timestamp seconds */
401 int32_t t_nsec; /* timestamp nanoseconds */
402 };
403
404 /*
405 * Define the format of the inode core that is logged. This structure must be
406 * kept identical to struct xfs_dinode except for the endianness annotations.
407 */
408 struct xfs_log_dinode {
409 uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
410 uint16_t di_mode; /* mode and type of file */
411 int8_t di_version; /* inode version */
412 int8_t di_format; /* format of di_c data */
413 uint16_t di_metatype; /* metadata type, if DIFLAG2_METADATA */
414 uint32_t di_uid; /* owner's user id */
415 uint32_t di_gid; /* owner's group id */
416 uint32_t di_nlink; /* number of links to file */
417 uint16_t di_projid_lo; /* lower part of owner's project id */
418 uint16_t di_projid_hi; /* higher part of owner's project id */
419 union {
420 /* Number of data fork extents if NREXT64 is set */
421 uint64_t di_big_nextents;
422
423 /* Padding for V3 inodes without NREXT64 set. */
424 uint64_t di_v3_pad;
425
426 /* Padding and inode flush counter for V2 inodes. */
427 struct {
428 uint8_t di_v2_pad[6]; /* V2 inode zeroed space */
429 uint16_t di_flushiter; /* V2 inode incremented on flush */
430 };
431 };
432 xfs_log_timestamp_t di_atime; /* time last accessed */
433 xfs_log_timestamp_t di_mtime; /* time last modified */
434 xfs_log_timestamp_t di_ctime; /* time created/inode modified */
435 xfs_fsize_t di_size; /* number of bytes in file */
436 xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */
437 xfs_extlen_t di_extsize; /* basic/minimum extent size for file */
438 union {
439 /*
440 * For V2 inodes and V3 inodes without NREXT64 set, this
441 * is the number of data and attr fork extents.
442 */
443 struct {
444 uint32_t di_nextents;
445 uint16_t di_anextents;
446 } __packed;
447
448 /* Number of attr fork extents if NREXT64 is set. */
449 struct {
450 uint32_t di_big_anextents;
451 uint16_t di_nrext64_pad;
452 } __packed;
453 } __packed;
454 uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */
455 int8_t di_aformat; /* format of attr fork's data */
456 uint32_t di_dmevmask; /* DMIG event mask */
457 uint16_t di_dmstate; /* DMIG state info */
458 uint16_t di_flags; /* random flags, XFS_DIFLAG_... */
459 uint32_t di_gen; /* generation number */
460
461 /* di_next_unlinked is the only non-core field in the old dinode */
462 xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */
463
464 /* start of the extended dinode, writable fields */
465 uint32_t di_crc; /* CRC of the inode */
466 uint64_t di_changecount; /* number of attribute changes */
467
468 /*
469 * The LSN we write to this field during formatting is not a reflection
470 * of the current on-disk LSN. It should never be used for recovery
471 * sequencing, nor should it be recovered into the on-disk inode at all.
472 * See xlog_recover_inode_commit_pass2() and xfs_log_dinode_to_disk()
473 * for details.
474 */
475 xfs_lsn_t di_lsn;
476
477 uint64_t di_flags2; /* more random flags */
478 union {
479 /* basic cow extent size for (regular) file */
480 uint32_t di_cowextsize;
481 /* used blocks in RTG for (zoned) rtrmap inode */
482 uint32_t di_used_blocks;
483 };
484 uint8_t di_pad2[12]; /* more padding for future expansion */
485
486 /* fields only written to during inode creation */
487 xfs_log_timestamp_t di_crtime; /* time created */
488 xfs_ino_t di_ino; /* inode number */
489 uuid_t di_uuid; /* UUID of the filesystem */
490
491 /* structure must be padded to 64 bit alignment */
492 };
493
494 #define xfs_log_dinode_size(mp) \
495 (xfs_has_v3inodes((mp)) ? \
496 sizeof(struct xfs_log_dinode) : \
497 offsetof(struct xfs_log_dinode, di_next_unlinked))
498
499 /*
500 * Buffer Log Format definitions
501 *
502 * These are the physical dirty bitmap definitions for the log format structure.
503 */
504 #define XFS_BLF_CHUNK 128
505 #define XFS_BLF_SHIFT 7
506 #define BIT_TO_WORD_SHIFT 5
507 #define NBWORD (NBBY * sizeof(unsigned int))
508
509 /*
510 * This flag indicates that the buffer contains on disk inodes
511 * and requires special recovery handling.
512 */
513 #define XFS_BLF_INODE_BUF (1<<0)
514
515 /*
516 * This flag indicates that the buffer should not be replayed
517 * during recovery because its blocks are being freed.
518 */
519 #define XFS_BLF_CANCEL (1<<1)
520
521 /*
522 * This flag indicates that the buffer contains on disk
523 * user or group dquots and may require special recovery handling.
524 */
525 #define XFS_BLF_UDQUOT_BUF (1<<2)
526 #define XFS_BLF_PDQUOT_BUF (1<<3)
527 #define XFS_BLF_GDQUOT_BUF (1<<4)
528
529 /*
530 * This is the structure used to lay out a buf log item in the log. The data
531 * map describes which 128 byte chunks of the buffer have been logged.
532 *
533 * The placement of blf_map_size causes blf_data_map to start at an odd
534 * multiple of sizeof(unsigned int) offset within the struct. Because the data
535 * bitmap size will always be an even number, the end of the data_map (and
536 * therefore the structure) will also be at an odd multiple of sizeof(unsigned
537 * int). Some 64-bit compilers will insert padding at the end of the struct to
538 * ensure 64-bit alignment of blf_blkno, but 32-bit ones will not. Therefore,
539 * XFS_BLF_DATAMAP_SIZE must be an odd number to make the padding explicit and
540 * keep the structure size consistent between 32-bit and 64-bit platforms.
541 */
542 #define __XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
543 #define XFS_BLF_DATAMAP_SIZE (__XFS_BLF_DATAMAP_SIZE + 1)
544
545 typedef struct xfs_buf_log_format {
546 unsigned short blf_type; /* buf log item type indicator */
547 unsigned short blf_size; /* size of this item */
548 unsigned short blf_flags; /* misc state */
549 unsigned short blf_len; /* number of blocks in this buf */
550 int64_t blf_blkno; /* starting blkno of this buf */
551 unsigned int blf_map_size; /* used size of data bitmap in words */
552 unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
553 } xfs_buf_log_format_t;
554
555 /*
556 * All buffers now need to tell recovery where the magic number
557 * is so that it can verify and calculate the CRCs on the buffer correctly
558 * once the changes have been replayed into the buffer.
559 *
560 * The type value is held in the upper 5 bits of the blf_flags field, which is
561 * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down.
562 */
563 #define XFS_BLFT_BITS 5
564 #define XFS_BLFT_SHIFT 11
565 #define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT)
566
567 enum xfs_blft {
568 XFS_BLFT_UNKNOWN_BUF = 0,
569 XFS_BLFT_UDQUOT_BUF,
570 XFS_BLFT_PDQUOT_BUF,
571 XFS_BLFT_GDQUOT_BUF,
572 XFS_BLFT_BTREE_BUF,
573 XFS_BLFT_AGF_BUF,
574 XFS_BLFT_AGFL_BUF,
575 XFS_BLFT_AGI_BUF,
576 XFS_BLFT_DINO_BUF,
577 XFS_BLFT_SYMLINK_BUF,
578 XFS_BLFT_DIR_BLOCK_BUF,
579 XFS_BLFT_DIR_DATA_BUF,
580 XFS_BLFT_DIR_FREE_BUF,
581 XFS_BLFT_DIR_LEAF1_BUF,
582 XFS_BLFT_DIR_LEAFN_BUF,
583 XFS_BLFT_DA_NODE_BUF,
584 XFS_BLFT_ATTR_LEAF_BUF,
585 XFS_BLFT_ATTR_RMT_BUF,
586 XFS_BLFT_SB_BUF,
587 XFS_BLFT_RTBITMAP_BUF,
588 XFS_BLFT_RTSUMMARY_BUF,
589 XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
590 };
591
592 static inline void
xfs_blft_to_flags(struct xfs_buf_log_format * blf,enum xfs_blft type)593 xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
594 {
595 ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
596 blf->blf_flags &= ~XFS_BLFT_MASK;
597 blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
598 }
599
600 static inline uint16_t
xfs_blft_from_flags(struct xfs_buf_log_format * blf)601 xfs_blft_from_flags(struct xfs_buf_log_format *blf)
602 {
603 return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT;
604 }
605
606 /*
607 * EFI/EFD log format definitions
608 */
609 typedef struct xfs_extent {
610 xfs_fsblock_t ext_start;
611 xfs_extlen_t ext_len;
612 } xfs_extent_t;
613
614 /*
615 * Since an xfs_extent_t has types (start:64, len: 32)
616 * there are different alignments on 32 bit and 64 bit kernels.
617 * So we provide the different variants for use by a
618 * conversion routine.
619 */
620 typedef struct xfs_extent_32 {
621 uint64_t ext_start;
622 uint32_t ext_len;
623 } __attribute__((packed)) xfs_extent_32_t;
624
625 typedef struct xfs_extent_64 {
626 uint64_t ext_start;
627 uint32_t ext_len;
628 uint32_t ext_pad;
629 } xfs_extent_64_t;
630
631 /*
632 * This is the structure used to lay out an efi log item in the
633 * log. The efi_extents field is a variable size array whose
634 * size is given by efi_nextents.
635 */
636 typedef struct xfs_efi_log_format {
637 uint16_t efi_type; /* efi log item type */
638 uint16_t efi_size; /* size of this item */
639 uint32_t efi_nextents; /* # extents to free */
640 uint64_t efi_id; /* efi identifier */
641 xfs_extent_t efi_extents[]; /* array of extents to free */
642 } xfs_efi_log_format_t;
643
644 static inline size_t
xfs_efi_log_format_sizeof(unsigned int nr)645 xfs_efi_log_format_sizeof(
646 unsigned int nr)
647 {
648 return sizeof(struct xfs_efi_log_format) +
649 nr * sizeof(struct xfs_extent);
650 }
651
652 typedef struct xfs_efi_log_format_32 {
653 uint16_t efi_type; /* efi log item type */
654 uint16_t efi_size; /* size of this item */
655 uint32_t efi_nextents; /* # extents to free */
656 uint64_t efi_id; /* efi identifier */
657 xfs_extent_32_t efi_extents[]; /* array of extents to free */
658 } __attribute__((packed)) xfs_efi_log_format_32_t;
659
660 static inline size_t
xfs_efi_log_format32_sizeof(unsigned int nr)661 xfs_efi_log_format32_sizeof(
662 unsigned int nr)
663 {
664 return sizeof(struct xfs_efi_log_format_32) +
665 nr * sizeof(struct xfs_extent_32);
666 }
667
668 typedef struct xfs_efi_log_format_64 {
669 uint16_t efi_type; /* efi log item type */
670 uint16_t efi_size; /* size of this item */
671 uint32_t efi_nextents; /* # extents to free */
672 uint64_t efi_id; /* efi identifier */
673 xfs_extent_64_t efi_extents[]; /* array of extents to free */
674 } xfs_efi_log_format_64_t;
675
676 static inline size_t
xfs_efi_log_format64_sizeof(unsigned int nr)677 xfs_efi_log_format64_sizeof(
678 unsigned int nr)
679 {
680 return sizeof(struct xfs_efi_log_format_64) +
681 nr * sizeof(struct xfs_extent_64);
682 }
683
684 /*
685 * This is the structure used to lay out an efd log item in the
686 * log. The efd_extents array is a variable size array whose
687 * size is given by efd_nextents;
688 */
689 typedef struct xfs_efd_log_format {
690 uint16_t efd_type; /* efd log item type */
691 uint16_t efd_size; /* size of this item */
692 uint32_t efd_nextents; /* # of extents freed */
693 uint64_t efd_efi_id; /* id of corresponding efi */
694 xfs_extent_t efd_extents[]; /* array of extents freed */
695 } xfs_efd_log_format_t;
696
697 static inline size_t
xfs_efd_log_format_sizeof(unsigned int nr)698 xfs_efd_log_format_sizeof(
699 unsigned int nr)
700 {
701 return sizeof(struct xfs_efd_log_format) +
702 nr * sizeof(struct xfs_extent);
703 }
704
705 typedef struct xfs_efd_log_format_32 {
706 uint16_t efd_type; /* efd log item type */
707 uint16_t efd_size; /* size of this item */
708 uint32_t efd_nextents; /* # of extents freed */
709 uint64_t efd_efi_id; /* id of corresponding efi */
710 xfs_extent_32_t efd_extents[]; /* array of extents freed */
711 } __attribute__((packed)) xfs_efd_log_format_32_t;
712
713 static inline size_t
xfs_efd_log_format32_sizeof(unsigned int nr)714 xfs_efd_log_format32_sizeof(
715 unsigned int nr)
716 {
717 return sizeof(struct xfs_efd_log_format_32) +
718 nr * sizeof(struct xfs_extent_32);
719 }
720
721 typedef struct xfs_efd_log_format_64 {
722 uint16_t efd_type; /* efd log item type */
723 uint16_t efd_size; /* size of this item */
724 uint32_t efd_nextents; /* # of extents freed */
725 uint64_t efd_efi_id; /* id of corresponding efi */
726 xfs_extent_64_t efd_extents[]; /* array of extents freed */
727 } xfs_efd_log_format_64_t;
728
729 static inline size_t
xfs_efd_log_format64_sizeof(unsigned int nr)730 xfs_efd_log_format64_sizeof(
731 unsigned int nr)
732 {
733 return sizeof(struct xfs_efd_log_format_64) +
734 nr * sizeof(struct xfs_extent_64);
735 }
736
737 /*
738 * RUI/RUD (reverse mapping) log format definitions
739 */
740 struct xfs_map_extent {
741 uint64_t me_owner;
742 uint64_t me_startblock;
743 uint64_t me_startoff;
744 uint32_t me_len;
745 uint32_t me_flags;
746 };
747
748 /* rmap me_flags: upper bits are flags, lower byte is type code */
749 #define XFS_RMAP_EXTENT_MAP 1
750 #define XFS_RMAP_EXTENT_MAP_SHARED 2
751 #define XFS_RMAP_EXTENT_UNMAP 3
752 #define XFS_RMAP_EXTENT_UNMAP_SHARED 4
753 #define XFS_RMAP_EXTENT_CONVERT 5
754 #define XFS_RMAP_EXTENT_CONVERT_SHARED 6
755 #define XFS_RMAP_EXTENT_ALLOC 7
756 #define XFS_RMAP_EXTENT_FREE 8
757 #define XFS_RMAP_EXTENT_TYPE_MASK 0xFF
758
759 #define XFS_RMAP_EXTENT_ATTR_FORK (1U << 31)
760 #define XFS_RMAP_EXTENT_BMBT_BLOCK (1U << 30)
761 #define XFS_RMAP_EXTENT_UNWRITTEN (1U << 29)
762
763 #define XFS_RMAP_EXTENT_FLAGS (XFS_RMAP_EXTENT_TYPE_MASK | \
764 XFS_RMAP_EXTENT_ATTR_FORK | \
765 XFS_RMAP_EXTENT_BMBT_BLOCK | \
766 XFS_RMAP_EXTENT_UNWRITTEN)
767
768 /*
769 * This is the structure used to lay out an rui log item in the
770 * log. The rui_extents field is a variable size array whose
771 * size is given by rui_nextents.
772 */
773 struct xfs_rui_log_format {
774 uint16_t rui_type; /* rui log item type */
775 uint16_t rui_size; /* size of this item */
776 uint32_t rui_nextents; /* # extents to free */
777 uint64_t rui_id; /* rui identifier */
778 struct xfs_map_extent rui_extents[]; /* array of extents to rmap */
779 };
780
781 static inline size_t
xfs_rui_log_format_sizeof(unsigned int nr)782 xfs_rui_log_format_sizeof(
783 unsigned int nr)
784 {
785 return sizeof(struct xfs_rui_log_format) +
786 nr * sizeof(struct xfs_map_extent);
787 }
788
789 /*
790 * This is the structure used to lay out an rud log item in the
791 * log. The rud_extents array is a variable size array whose
792 * size is given by rud_nextents;
793 */
794 struct xfs_rud_log_format {
795 uint16_t rud_type; /* rud log item type */
796 uint16_t rud_size; /* size of this item */
797 uint32_t __pad;
798 uint64_t rud_rui_id; /* id of corresponding rui */
799 };
800
801 /*
802 * CUI/CUD (refcount update) log format definitions
803 */
804 struct xfs_phys_extent {
805 uint64_t pe_startblock;
806 uint32_t pe_len;
807 uint32_t pe_flags;
808 };
809
810 /* refcount pe_flags: upper bits are flags, lower byte is type code */
811 /* Type codes are taken directly from enum xfs_refcount_intent_type. */
812 #define XFS_REFCOUNT_EXTENT_TYPE_MASK 0xFF
813
814 #define XFS_REFCOUNT_EXTENT_FLAGS (XFS_REFCOUNT_EXTENT_TYPE_MASK)
815
816 /*
817 * This is the structure used to lay out a cui log item in the
818 * log. The cui_extents field is a variable size array whose
819 * size is given by cui_nextents.
820 */
821 struct xfs_cui_log_format {
822 uint16_t cui_type; /* cui log item type */
823 uint16_t cui_size; /* size of this item */
824 uint32_t cui_nextents; /* # extents to free */
825 uint64_t cui_id; /* cui identifier */
826 struct xfs_phys_extent cui_extents[]; /* array of extents */
827 };
828
829 static inline size_t
xfs_cui_log_format_sizeof(unsigned int nr)830 xfs_cui_log_format_sizeof(
831 unsigned int nr)
832 {
833 return sizeof(struct xfs_cui_log_format) +
834 nr * sizeof(struct xfs_phys_extent);
835 }
836
837 /*
838 * This is the structure used to lay out a cud log item in the
839 * log. The cud_extents array is a variable size array whose
840 * size is given by cud_nextents;
841 */
842 struct xfs_cud_log_format {
843 uint16_t cud_type; /* cud log item type */
844 uint16_t cud_size; /* size of this item */
845 uint32_t __pad;
846 uint64_t cud_cui_id; /* id of corresponding cui */
847 };
848
849 /*
850 * BUI/BUD (inode block mapping) log format definitions
851 */
852
853 /* bmbt me_flags: upper bits are flags, lower byte is type code */
854 /* Type codes are taken directly from enum xfs_bmap_intent_type. */
855 #define XFS_BMAP_EXTENT_TYPE_MASK 0xFF
856
857 #define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
858 #define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
859 #define XFS_BMAP_EXTENT_REALTIME (1U << 29)
860
861 #define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
862 XFS_BMAP_EXTENT_ATTR_FORK | \
863 XFS_BMAP_EXTENT_UNWRITTEN | \
864 XFS_BMAP_EXTENT_REALTIME)
865
866 /*
867 * This is the structure used to lay out an bui log item in the
868 * log. The bui_extents field is a variable size array whose
869 * size is given by bui_nextents.
870 */
871 struct xfs_bui_log_format {
872 uint16_t bui_type; /* bui log item type */
873 uint16_t bui_size; /* size of this item */
874 uint32_t bui_nextents; /* # extents to free */
875 uint64_t bui_id; /* bui identifier */
876 struct xfs_map_extent bui_extents[]; /* array of extents to bmap */
877 };
878
879 static inline size_t
xfs_bui_log_format_sizeof(unsigned int nr)880 xfs_bui_log_format_sizeof(
881 unsigned int nr)
882 {
883 return sizeof(struct xfs_bui_log_format) +
884 nr * sizeof(struct xfs_map_extent);
885 }
886
887 /*
888 * This is the structure used to lay out an bud log item in the
889 * log. The bud_extents array is a variable size array whose
890 * size is given by bud_nextents;
891 */
892 struct xfs_bud_log_format {
893 uint16_t bud_type; /* bud log item type */
894 uint16_t bud_size; /* size of this item */
895 uint32_t __pad;
896 uint64_t bud_bui_id; /* id of corresponding bui */
897 };
898
899 /*
900 * XMI/XMD (file mapping exchange) log format definitions
901 */
902
903 /* This is the structure used to lay out an mapping exchange log item. */
904 struct xfs_xmi_log_format {
905 uint16_t xmi_type; /* xmi log item type */
906 uint16_t xmi_size; /* size of this item */
907 uint32_t __pad; /* must be zero */
908 uint64_t xmi_id; /* xmi identifier */
909
910 uint64_t xmi_inode1; /* inumber of first file */
911 uint64_t xmi_inode2; /* inumber of second file */
912 uint32_t xmi_igen1; /* generation of first file */
913 uint32_t xmi_igen2; /* generation of second file */
914 uint64_t xmi_startoff1; /* block offset into file1 */
915 uint64_t xmi_startoff2; /* block offset into file2 */
916 uint64_t xmi_blockcount; /* number of blocks */
917 uint64_t xmi_flags; /* XFS_EXCHMAPS_* */
918 uint64_t xmi_isize1; /* intended file1 size */
919 uint64_t xmi_isize2; /* intended file2 size */
920 };
921
922 /* Exchange mappings between extended attribute forks instead of data forks. */
923 #define XFS_EXCHMAPS_ATTR_FORK (1ULL << 0)
924
925 /* Set the file sizes when finished. */
926 #define XFS_EXCHMAPS_SET_SIZES (1ULL << 1)
927
928 /*
929 * Exchange the mappings of the two files only if the file allocation units
930 * mapped to file1's range have been written.
931 */
932 #define XFS_EXCHMAPS_INO1_WRITTEN (1ULL << 2)
933
934 /* Clear the reflink flag from inode1 after the operation. */
935 #define XFS_EXCHMAPS_CLEAR_INO1_REFLINK (1ULL << 3)
936
937 /* Clear the reflink flag from inode2 after the operation. */
938 #define XFS_EXCHMAPS_CLEAR_INO2_REFLINK (1ULL << 4)
939
940 #define XFS_EXCHMAPS_LOGGED_FLAGS (XFS_EXCHMAPS_ATTR_FORK | \
941 XFS_EXCHMAPS_SET_SIZES | \
942 XFS_EXCHMAPS_INO1_WRITTEN | \
943 XFS_EXCHMAPS_CLEAR_INO1_REFLINK | \
944 XFS_EXCHMAPS_CLEAR_INO2_REFLINK)
945
946 /* This is the structure used to lay out an mapping exchange done log item. */
947 struct xfs_xmd_log_format {
948 uint16_t xmd_type; /* xmd log item type */
949 uint16_t xmd_size; /* size of this item */
950 uint32_t __pad;
951 uint64_t xmd_xmi_id; /* id of corresponding xmi */
952 };
953
954 /*
955 * Dquot Log format definitions.
956 *
957 * The first two fields must be the type and size fitting into
958 * 32 bits : log_recovery code assumes that.
959 */
960 typedef struct xfs_dq_logformat {
961 uint16_t qlf_type; /* dquot log item type */
962 uint16_t qlf_size; /* size of this item */
963 xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
964 int64_t qlf_blkno; /* blkno of dquot buffer */
965 int32_t qlf_len; /* len of dquot buffer */
966 uint32_t qlf_boffset; /* off of dquot in buffer */
967 } xfs_dq_logformat_t;
968
969 /*
970 * log format struct for QUOTAOFF records.
971 * The first two fields must be the type and size fitting into
972 * 32 bits : log_recovery code assumes that.
973 * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
974 * to the first and ensures that the first logitem is taken out of the AIL
975 * only when the last one is securely committed.
976 */
977 typedef struct xfs_qoff_logformat {
978 unsigned short qf_type; /* quotaoff log item type */
979 unsigned short qf_size; /* size of this item */
980 unsigned int qf_flags; /* USR and/or GRP */
981 char qf_pad[12]; /* padding for future */
982 } xfs_qoff_logformat_t;
983
984 /*
985 * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
986 */
987 #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
988 #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
989 #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
990 #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
991 #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
992 #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
993 #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
994
995 /*
996 * Conversion to and from the combined OQUOTA flag (if necessary)
997 * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
998 */
999 #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */
1000 #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */
1001 #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */
1002 #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
1003
1004 #define XFS_ALL_QUOTA_ACCT \
1005 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
1006 #define XFS_ALL_QUOTA_ENFD \
1007 (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
1008 #define XFS_ALL_QUOTA_CHKD \
1009 (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
1010
1011 #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
1012 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
1013 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
1014 XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
1015 XFS_PQUOTA_CHKD)
1016
1017 /*
1018 * Inode create log item structure
1019 *
1020 * Log recovery assumes the first two entries are the type and size and they fit
1021 * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so
1022 * decoding can be done correctly.
1023 */
1024 struct xfs_icreate_log {
1025 uint16_t icl_type; /* type of log format structure */
1026 uint16_t icl_size; /* size of log format structure */
1027 __be32 icl_ag; /* ag being allocated in */
1028 __be32 icl_agbno; /* start block of inode range */
1029 __be32 icl_count; /* number of inodes to initialise */
1030 __be32 icl_isize; /* size of inodes */
1031 __be32 icl_length; /* length of extent to initialise */
1032 __be32 icl_gen; /* inode generation number to use */
1033 };
1034
1035 /*
1036 * Flags for deferred attribute operations.
1037 * Upper bits are flags, lower byte is type code
1038 */
1039 #define XFS_ATTRI_OP_FLAGS_SET 1 /* Set the attribute */
1040 #define XFS_ATTRI_OP_FLAGS_REMOVE 2 /* Remove the attribute */
1041 #define XFS_ATTRI_OP_FLAGS_REPLACE 3 /* Replace the attribute */
1042 #define XFS_ATTRI_OP_FLAGS_PPTR_SET 4 /* Set parent pointer */
1043 #define XFS_ATTRI_OP_FLAGS_PPTR_REMOVE 5 /* Remove parent pointer */
1044 #define XFS_ATTRI_OP_FLAGS_PPTR_REPLACE 6 /* Replace parent pointer */
1045 #define XFS_ATTRI_OP_FLAGS_TYPE_MASK 0xFF /* Flags type mask */
1046
1047 /*
1048 * alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should
1049 * never have any other bits set.
1050 */
1051 #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \
1052 XFS_ATTR_SECURE | \
1053 XFS_ATTR_PARENT | \
1054 XFS_ATTR_INCOMPLETE)
1055
1056 /*
1057 * This is the structure used to lay out an attr log item in the
1058 * log.
1059 */
1060 struct xfs_attri_log_format {
1061 uint16_t alfi_type; /* attri log item type */
1062 uint16_t alfi_size; /* size of this item */
1063 uint32_t alfi_igen; /* generation of alfi_ino for pptr ops */
1064 uint64_t alfi_id; /* attri identifier */
1065 uint64_t alfi_ino; /* the inode for this attr operation */
1066 uint32_t alfi_op_flags; /* marks the op as a set or remove */
1067 union {
1068 uint32_t alfi_name_len; /* attr name length */
1069 struct {
1070 /*
1071 * For PPTR_REPLACE, these are the lengths of the old
1072 * and new attr names. The new and old values must
1073 * have the same length.
1074 */
1075 uint16_t alfi_old_name_len;
1076 uint16_t alfi_new_name_len;
1077 };
1078 };
1079 uint32_t alfi_value_len; /* attr value length */
1080 uint32_t alfi_attr_filter;/* attr filter flags */
1081 };
1082
1083 struct xfs_attrd_log_format {
1084 uint16_t alfd_type; /* attrd log item type */
1085 uint16_t alfd_size; /* size of this item */
1086 uint32_t __pad; /* pad to 64 bit aligned */
1087 uint64_t alfd_alf_id; /* id of corresponding attri */
1088 };
1089
1090 #endif /* __XFS_LOG_FORMAT_H__ */
1091