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