xref: /linux/fs/xfs/libxfs/xfs_log_format.h (revision b477ff98d903618a1ab8247861f2ea6e70c0f0f8)
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 	uint32_t	di_cowextsize;	/* basic cow extent size for file */
479 	uint8_t		di_pad2[12];	/* more padding for future expansion */
480 
481 	/* fields only written to during inode creation */
482 	xfs_log_timestamp_t di_crtime;	/* time created */
483 	xfs_ino_t	di_ino;		/* inode number */
484 	uuid_t		di_uuid;	/* UUID of the filesystem */
485 
486 	/* structure must be padded to 64 bit alignment */
487 };
488 
489 #define xfs_log_dinode_size(mp)						\
490 	(xfs_has_v3inodes((mp)) ?					\
491 		sizeof(struct xfs_log_dinode) :				\
492 		offsetof(struct xfs_log_dinode, di_next_unlinked))
493 
494 /*
495  * Buffer Log Format definitions
496  *
497  * These are the physical dirty bitmap definitions for the log format structure.
498  */
499 #define	XFS_BLF_CHUNK		128
500 #define	XFS_BLF_SHIFT		7
501 #define	BIT_TO_WORD_SHIFT	5
502 #define	NBWORD			(NBBY * sizeof(unsigned int))
503 
504 /*
505  * This flag indicates that the buffer contains on disk inodes
506  * and requires special recovery handling.
507  */
508 #define	XFS_BLF_INODE_BUF	(1<<0)
509 
510 /*
511  * This flag indicates that the buffer should not be replayed
512  * during recovery because its blocks are being freed.
513  */
514 #define	XFS_BLF_CANCEL		(1<<1)
515 
516 /*
517  * This flag indicates that the buffer contains on disk
518  * user or group dquots and may require special recovery handling.
519  */
520 #define	XFS_BLF_UDQUOT_BUF	(1<<2)
521 #define XFS_BLF_PDQUOT_BUF	(1<<3)
522 #define	XFS_BLF_GDQUOT_BUF	(1<<4)
523 
524 /*
525  * This is the structure used to lay out a buf log item in the log.  The data
526  * map describes which 128 byte chunks of the buffer have been logged.
527  *
528  * The placement of blf_map_size causes blf_data_map to start at an odd
529  * multiple of sizeof(unsigned int) offset within the struct.  Because the data
530  * bitmap size will always be an even number, the end of the data_map (and
531  * therefore the structure) will also be at an odd multiple of sizeof(unsigned
532  * int).  Some 64-bit compilers will insert padding at the end of the struct to
533  * ensure 64-bit alignment of blf_blkno, but 32-bit ones will not.  Therefore,
534  * XFS_BLF_DATAMAP_SIZE must be an odd number to make the padding explicit and
535  * keep the structure size consistent between 32-bit and 64-bit platforms.
536  */
537 #define __XFS_BLF_DATAMAP_SIZE	((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
538 #define XFS_BLF_DATAMAP_SIZE	(__XFS_BLF_DATAMAP_SIZE + 1)
539 
540 typedef struct xfs_buf_log_format {
541 	unsigned short	blf_type;	/* buf log item type indicator */
542 	unsigned short	blf_size;	/* size of this item */
543 	unsigned short	blf_flags;	/* misc state */
544 	unsigned short	blf_len;	/* number of blocks in this buf */
545 	int64_t		blf_blkno;	/* starting blkno of this buf */
546 	unsigned int	blf_map_size;	/* used size of data bitmap in words */
547 	unsigned int	blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
548 } xfs_buf_log_format_t;
549 
550 /*
551  * All buffers now need to tell recovery where the magic number
552  * is so that it can verify and calculate the CRCs on the buffer correctly
553  * once the changes have been replayed into the buffer.
554  *
555  * The type value is held in the upper 5 bits of the blf_flags field, which is
556  * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down.
557  */
558 #define XFS_BLFT_BITS	5
559 #define XFS_BLFT_SHIFT	11
560 #define XFS_BLFT_MASK	(((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT)
561 
562 enum xfs_blft {
563 	XFS_BLFT_UNKNOWN_BUF = 0,
564 	XFS_BLFT_UDQUOT_BUF,
565 	XFS_BLFT_PDQUOT_BUF,
566 	XFS_BLFT_GDQUOT_BUF,
567 	XFS_BLFT_BTREE_BUF,
568 	XFS_BLFT_AGF_BUF,
569 	XFS_BLFT_AGFL_BUF,
570 	XFS_BLFT_AGI_BUF,
571 	XFS_BLFT_DINO_BUF,
572 	XFS_BLFT_SYMLINK_BUF,
573 	XFS_BLFT_DIR_BLOCK_BUF,
574 	XFS_BLFT_DIR_DATA_BUF,
575 	XFS_BLFT_DIR_FREE_BUF,
576 	XFS_BLFT_DIR_LEAF1_BUF,
577 	XFS_BLFT_DIR_LEAFN_BUF,
578 	XFS_BLFT_DA_NODE_BUF,
579 	XFS_BLFT_ATTR_LEAF_BUF,
580 	XFS_BLFT_ATTR_RMT_BUF,
581 	XFS_BLFT_SB_BUF,
582 	XFS_BLFT_RTBITMAP_BUF,
583 	XFS_BLFT_RTSUMMARY_BUF,
584 	XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
585 };
586 
587 static inline void
xfs_blft_to_flags(struct xfs_buf_log_format * blf,enum xfs_blft type)588 xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
589 {
590 	ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
591 	blf->blf_flags &= ~XFS_BLFT_MASK;
592 	blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
593 }
594 
595 static inline uint16_t
xfs_blft_from_flags(struct xfs_buf_log_format * blf)596 xfs_blft_from_flags(struct xfs_buf_log_format *blf)
597 {
598 	return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT;
599 }
600 
601 /*
602  * EFI/EFD log format definitions
603  */
604 typedef struct xfs_extent {
605 	xfs_fsblock_t	ext_start;
606 	xfs_extlen_t	ext_len;
607 } xfs_extent_t;
608 
609 /*
610  * Since an xfs_extent_t has types (start:64, len: 32)
611  * there are different alignments on 32 bit and 64 bit kernels.
612  * So we provide the different variants for use by a
613  * conversion routine.
614  */
615 typedef struct xfs_extent_32 {
616 	uint64_t	ext_start;
617 	uint32_t	ext_len;
618 } __attribute__((packed)) xfs_extent_32_t;
619 
620 typedef struct xfs_extent_64 {
621 	uint64_t	ext_start;
622 	uint32_t	ext_len;
623 	uint32_t	ext_pad;
624 } xfs_extent_64_t;
625 
626 /*
627  * This is the structure used to lay out an efi log item in the
628  * log.  The efi_extents field is a variable size array whose
629  * size is given by efi_nextents.
630  */
631 typedef struct xfs_efi_log_format {
632 	uint16_t		efi_type;	/* efi log item type */
633 	uint16_t		efi_size;	/* size of this item */
634 	uint32_t		efi_nextents;	/* # extents to free */
635 	uint64_t		efi_id;		/* efi identifier */
636 	xfs_extent_t		efi_extents[];	/* array of extents to free */
637 } xfs_efi_log_format_t;
638 
639 static inline size_t
xfs_efi_log_format_sizeof(unsigned int nr)640 xfs_efi_log_format_sizeof(
641 	unsigned int		nr)
642 {
643 	return sizeof(struct xfs_efi_log_format) +
644 			nr * sizeof(struct xfs_extent);
645 }
646 
647 typedef struct xfs_efi_log_format_32 {
648 	uint16_t		efi_type;	/* efi log item type */
649 	uint16_t		efi_size;	/* size of this item */
650 	uint32_t		efi_nextents;	/* # extents to free */
651 	uint64_t		efi_id;		/* efi identifier */
652 	xfs_extent_32_t		efi_extents[];	/* array of extents to free */
653 } __attribute__((packed)) xfs_efi_log_format_32_t;
654 
655 static inline size_t
xfs_efi_log_format32_sizeof(unsigned int nr)656 xfs_efi_log_format32_sizeof(
657 	unsigned int		nr)
658 {
659 	return sizeof(struct xfs_efi_log_format_32) +
660 			nr * sizeof(struct xfs_extent_32);
661 }
662 
663 typedef struct xfs_efi_log_format_64 {
664 	uint16_t		efi_type;	/* efi log item type */
665 	uint16_t		efi_size;	/* size of this item */
666 	uint32_t		efi_nextents;	/* # extents to free */
667 	uint64_t		efi_id;		/* efi identifier */
668 	xfs_extent_64_t		efi_extents[];	/* array of extents to free */
669 } xfs_efi_log_format_64_t;
670 
671 static inline size_t
xfs_efi_log_format64_sizeof(unsigned int nr)672 xfs_efi_log_format64_sizeof(
673 	unsigned int		nr)
674 {
675 	return sizeof(struct xfs_efi_log_format_64) +
676 			nr * sizeof(struct xfs_extent_64);
677 }
678 
679 /*
680  * This is the structure used to lay out an efd log item in the
681  * log.  The efd_extents array is a variable size array whose
682  * size is given by efd_nextents;
683  */
684 typedef struct xfs_efd_log_format {
685 	uint16_t		efd_type;	/* efd log item type */
686 	uint16_t		efd_size;	/* size of this item */
687 	uint32_t		efd_nextents;	/* # of extents freed */
688 	uint64_t		efd_efi_id;	/* id of corresponding efi */
689 	xfs_extent_t		efd_extents[];	/* array of extents freed */
690 } xfs_efd_log_format_t;
691 
692 static inline size_t
xfs_efd_log_format_sizeof(unsigned int nr)693 xfs_efd_log_format_sizeof(
694 	unsigned int		nr)
695 {
696 	return sizeof(struct xfs_efd_log_format) +
697 			nr * sizeof(struct xfs_extent);
698 }
699 
700 typedef struct xfs_efd_log_format_32 {
701 	uint16_t		efd_type;	/* efd log item type */
702 	uint16_t		efd_size;	/* size of this item */
703 	uint32_t		efd_nextents;	/* # of extents freed */
704 	uint64_t		efd_efi_id;	/* id of corresponding efi */
705 	xfs_extent_32_t		efd_extents[];	/* array of extents freed */
706 } __attribute__((packed)) xfs_efd_log_format_32_t;
707 
708 static inline size_t
xfs_efd_log_format32_sizeof(unsigned int nr)709 xfs_efd_log_format32_sizeof(
710 	unsigned int		nr)
711 {
712 	return sizeof(struct xfs_efd_log_format_32) +
713 			nr * sizeof(struct xfs_extent_32);
714 }
715 
716 typedef struct xfs_efd_log_format_64 {
717 	uint16_t		efd_type;	/* efd log item type */
718 	uint16_t		efd_size;	/* size of this item */
719 	uint32_t		efd_nextents;	/* # of extents freed */
720 	uint64_t		efd_efi_id;	/* id of corresponding efi */
721 	xfs_extent_64_t		efd_extents[];	/* array of extents freed */
722 } xfs_efd_log_format_64_t;
723 
724 static inline size_t
xfs_efd_log_format64_sizeof(unsigned int nr)725 xfs_efd_log_format64_sizeof(
726 	unsigned int		nr)
727 {
728 	return sizeof(struct xfs_efd_log_format_64) +
729 			nr * sizeof(struct xfs_extent_64);
730 }
731 
732 /*
733  * RUI/RUD (reverse mapping) log format definitions
734  */
735 struct xfs_map_extent {
736 	uint64_t		me_owner;
737 	uint64_t		me_startblock;
738 	uint64_t		me_startoff;
739 	uint32_t		me_len;
740 	uint32_t		me_flags;
741 };
742 
743 /* rmap me_flags: upper bits are flags, lower byte is type code */
744 #define XFS_RMAP_EXTENT_MAP		1
745 #define XFS_RMAP_EXTENT_MAP_SHARED	2
746 #define XFS_RMAP_EXTENT_UNMAP		3
747 #define XFS_RMAP_EXTENT_UNMAP_SHARED	4
748 #define XFS_RMAP_EXTENT_CONVERT		5
749 #define XFS_RMAP_EXTENT_CONVERT_SHARED	6
750 #define XFS_RMAP_EXTENT_ALLOC		7
751 #define XFS_RMAP_EXTENT_FREE		8
752 #define XFS_RMAP_EXTENT_TYPE_MASK	0xFF
753 
754 #define XFS_RMAP_EXTENT_ATTR_FORK	(1U << 31)
755 #define XFS_RMAP_EXTENT_BMBT_BLOCK	(1U << 30)
756 #define XFS_RMAP_EXTENT_UNWRITTEN	(1U << 29)
757 
758 #define XFS_RMAP_EXTENT_FLAGS		(XFS_RMAP_EXTENT_TYPE_MASK | \
759 					 XFS_RMAP_EXTENT_ATTR_FORK | \
760 					 XFS_RMAP_EXTENT_BMBT_BLOCK | \
761 					 XFS_RMAP_EXTENT_UNWRITTEN)
762 
763 /*
764  * This is the structure used to lay out an rui log item in the
765  * log.  The rui_extents field is a variable size array whose
766  * size is given by rui_nextents.
767  */
768 struct xfs_rui_log_format {
769 	uint16_t		rui_type;	/* rui log item type */
770 	uint16_t		rui_size;	/* size of this item */
771 	uint32_t		rui_nextents;	/* # extents to free */
772 	uint64_t		rui_id;		/* rui identifier */
773 	struct xfs_map_extent	rui_extents[];	/* array of extents to rmap */
774 };
775 
776 static inline size_t
xfs_rui_log_format_sizeof(unsigned int nr)777 xfs_rui_log_format_sizeof(
778 	unsigned int		nr)
779 {
780 	return sizeof(struct xfs_rui_log_format) +
781 			nr * sizeof(struct xfs_map_extent);
782 }
783 
784 /*
785  * This is the structure used to lay out an rud log item in the
786  * log.  The rud_extents array is a variable size array whose
787  * size is given by rud_nextents;
788  */
789 struct xfs_rud_log_format {
790 	uint16_t		rud_type;	/* rud log item type */
791 	uint16_t		rud_size;	/* size of this item */
792 	uint32_t		__pad;
793 	uint64_t		rud_rui_id;	/* id of corresponding rui */
794 };
795 
796 /*
797  * CUI/CUD (refcount update) log format definitions
798  */
799 struct xfs_phys_extent {
800 	uint64_t		pe_startblock;
801 	uint32_t		pe_len;
802 	uint32_t		pe_flags;
803 };
804 
805 /* refcount pe_flags: upper bits are flags, lower byte is type code */
806 /* Type codes are taken directly from enum xfs_refcount_intent_type. */
807 #define XFS_REFCOUNT_EXTENT_TYPE_MASK	0xFF
808 
809 #define XFS_REFCOUNT_EXTENT_FLAGS	(XFS_REFCOUNT_EXTENT_TYPE_MASK)
810 
811 /*
812  * This is the structure used to lay out a cui log item in the
813  * log.  The cui_extents field is a variable size array whose
814  * size is given by cui_nextents.
815  */
816 struct xfs_cui_log_format {
817 	uint16_t		cui_type;	/* cui log item type */
818 	uint16_t		cui_size;	/* size of this item */
819 	uint32_t		cui_nextents;	/* # extents to free */
820 	uint64_t		cui_id;		/* cui identifier */
821 	struct xfs_phys_extent	cui_extents[];	/* array of extents */
822 };
823 
824 static inline size_t
xfs_cui_log_format_sizeof(unsigned int nr)825 xfs_cui_log_format_sizeof(
826 	unsigned int		nr)
827 {
828 	return sizeof(struct xfs_cui_log_format) +
829 			nr * sizeof(struct xfs_phys_extent);
830 }
831 
832 /*
833  * This is the structure used to lay out a cud log item in the
834  * log.  The cud_extents array is a variable size array whose
835  * size is given by cud_nextents;
836  */
837 struct xfs_cud_log_format {
838 	uint16_t		cud_type;	/* cud log item type */
839 	uint16_t		cud_size;	/* size of this item */
840 	uint32_t		__pad;
841 	uint64_t		cud_cui_id;	/* id of corresponding cui */
842 };
843 
844 /*
845  * BUI/BUD (inode block mapping) log format definitions
846  */
847 
848 /* bmbt me_flags: upper bits are flags, lower byte is type code */
849 /* Type codes are taken directly from enum xfs_bmap_intent_type. */
850 #define XFS_BMAP_EXTENT_TYPE_MASK	0xFF
851 
852 #define XFS_BMAP_EXTENT_ATTR_FORK	(1U << 31)
853 #define XFS_BMAP_EXTENT_UNWRITTEN	(1U << 30)
854 #define XFS_BMAP_EXTENT_REALTIME	(1U << 29)
855 
856 #define XFS_BMAP_EXTENT_FLAGS		(XFS_BMAP_EXTENT_TYPE_MASK | \
857 					 XFS_BMAP_EXTENT_ATTR_FORK | \
858 					 XFS_BMAP_EXTENT_UNWRITTEN | \
859 					 XFS_BMAP_EXTENT_REALTIME)
860 
861 /*
862  * This is the structure used to lay out an bui log item in the
863  * log.  The bui_extents field is a variable size array whose
864  * size is given by bui_nextents.
865  */
866 struct xfs_bui_log_format {
867 	uint16_t		bui_type;	/* bui log item type */
868 	uint16_t		bui_size;	/* size of this item */
869 	uint32_t		bui_nextents;	/* # extents to free */
870 	uint64_t		bui_id;		/* bui identifier */
871 	struct xfs_map_extent	bui_extents[];	/* array of extents to bmap */
872 };
873 
874 static inline size_t
xfs_bui_log_format_sizeof(unsigned int nr)875 xfs_bui_log_format_sizeof(
876 	unsigned int		nr)
877 {
878 	return sizeof(struct xfs_bui_log_format) +
879 			nr * sizeof(struct xfs_map_extent);
880 }
881 
882 /*
883  * This is the structure used to lay out an bud log item in the
884  * log.  The bud_extents array is a variable size array whose
885  * size is given by bud_nextents;
886  */
887 struct xfs_bud_log_format {
888 	uint16_t		bud_type;	/* bud log item type */
889 	uint16_t		bud_size;	/* size of this item */
890 	uint32_t		__pad;
891 	uint64_t		bud_bui_id;	/* id of corresponding bui */
892 };
893 
894 /*
895  * XMI/XMD (file mapping exchange) log format definitions
896  */
897 
898 /* This is the structure used to lay out an mapping exchange log item. */
899 struct xfs_xmi_log_format {
900 	uint16_t		xmi_type;	/* xmi log item type */
901 	uint16_t		xmi_size;	/* size of this item */
902 	uint32_t		__pad;		/* must be zero */
903 	uint64_t		xmi_id;		/* xmi identifier */
904 
905 	uint64_t		xmi_inode1;	/* inumber of first file */
906 	uint64_t		xmi_inode2;	/* inumber of second file */
907 	uint32_t		xmi_igen1;	/* generation of first file */
908 	uint32_t		xmi_igen2;	/* generation of second file */
909 	uint64_t		xmi_startoff1;	/* block offset into file1 */
910 	uint64_t		xmi_startoff2;	/* block offset into file2 */
911 	uint64_t		xmi_blockcount;	/* number of blocks */
912 	uint64_t		xmi_flags;	/* XFS_EXCHMAPS_* */
913 	uint64_t		xmi_isize1;	/* intended file1 size */
914 	uint64_t		xmi_isize2;	/* intended file2 size */
915 };
916 
917 /* Exchange mappings between extended attribute forks instead of data forks. */
918 #define XFS_EXCHMAPS_ATTR_FORK		(1ULL << 0)
919 
920 /* Set the file sizes when finished. */
921 #define XFS_EXCHMAPS_SET_SIZES		(1ULL << 1)
922 
923 /*
924  * Exchange the mappings of the two files only if the file allocation units
925  * mapped to file1's range have been written.
926  */
927 #define XFS_EXCHMAPS_INO1_WRITTEN	(1ULL << 2)
928 
929 /* Clear the reflink flag from inode1 after the operation. */
930 #define XFS_EXCHMAPS_CLEAR_INO1_REFLINK	(1ULL << 3)
931 
932 /* Clear the reflink flag from inode2 after the operation. */
933 #define XFS_EXCHMAPS_CLEAR_INO2_REFLINK	(1ULL << 4)
934 
935 #define XFS_EXCHMAPS_LOGGED_FLAGS	(XFS_EXCHMAPS_ATTR_FORK | \
936 					 XFS_EXCHMAPS_SET_SIZES | \
937 					 XFS_EXCHMAPS_INO1_WRITTEN | \
938 					 XFS_EXCHMAPS_CLEAR_INO1_REFLINK | \
939 					 XFS_EXCHMAPS_CLEAR_INO2_REFLINK)
940 
941 /* This is the structure used to lay out an mapping exchange done log item. */
942 struct xfs_xmd_log_format {
943 	uint16_t		xmd_type;	/* xmd log item type */
944 	uint16_t		xmd_size;	/* size of this item */
945 	uint32_t		__pad;
946 	uint64_t		xmd_xmi_id;	/* id of corresponding xmi */
947 };
948 
949 /*
950  * Dquot Log format definitions.
951  *
952  * The first two fields must be the type and size fitting into
953  * 32 bits : log_recovery code assumes that.
954  */
955 typedef struct xfs_dq_logformat {
956 	uint16_t		qlf_type;      /* dquot log item type */
957 	uint16_t		qlf_size;      /* size of this item */
958 	xfs_dqid_t		qlf_id;	       /* usr/grp/proj id : 32 bits */
959 	int64_t			qlf_blkno;     /* blkno of dquot buffer */
960 	int32_t			qlf_len;       /* len of dquot buffer */
961 	uint32_t		qlf_boffset;   /* off of dquot in buffer */
962 } xfs_dq_logformat_t;
963 
964 /*
965  * log format struct for QUOTAOFF records.
966  * The first two fields must be the type and size fitting into
967  * 32 bits : log_recovery code assumes that.
968  * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
969  * to the first and ensures that the first logitem is taken out of the AIL
970  * only when the last one is securely committed.
971  */
972 typedef struct xfs_qoff_logformat {
973 	unsigned short		qf_type;	/* quotaoff log item type */
974 	unsigned short		qf_size;	/* size of this item */
975 	unsigned int		qf_flags;	/* USR and/or GRP */
976 	char			qf_pad[12];	/* padding for future */
977 } xfs_qoff_logformat_t;
978 
979 /*
980  * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
981  */
982 #define XFS_UQUOTA_ACCT	0x0001  /* user quota accounting ON */
983 #define XFS_UQUOTA_ENFD	0x0002  /* user quota limits enforced */
984 #define XFS_UQUOTA_CHKD	0x0004  /* quotacheck run on usr quotas */
985 #define XFS_PQUOTA_ACCT	0x0008  /* project quota accounting ON */
986 #define XFS_OQUOTA_ENFD	0x0010  /* other (grp/prj) quota limits enforced */
987 #define XFS_OQUOTA_CHKD	0x0020  /* quotacheck run on other (grp/prj) quotas */
988 #define XFS_GQUOTA_ACCT	0x0040  /* group quota accounting ON */
989 
990 /*
991  * Conversion to and from the combined OQUOTA flag (if necessary)
992  * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
993  */
994 #define XFS_GQUOTA_ENFD	0x0080  /* group quota limits enforced */
995 #define XFS_GQUOTA_CHKD	0x0100  /* quotacheck run on group quotas */
996 #define XFS_PQUOTA_ENFD	0x0200  /* project quota limits enforced */
997 #define XFS_PQUOTA_CHKD	0x0400  /* quotacheck run on project quotas */
998 
999 #define XFS_ALL_QUOTA_ACCT	\
1000 		(XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
1001 #define XFS_ALL_QUOTA_ENFD	\
1002 		(XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
1003 #define XFS_ALL_QUOTA_CHKD	\
1004 		(XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
1005 
1006 #define XFS_MOUNT_QUOTA_ALL	(XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
1007 				 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
1008 				 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
1009 				 XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
1010 				 XFS_PQUOTA_CHKD)
1011 
1012 /*
1013  * Inode create log item structure
1014  *
1015  * Log recovery assumes the first two entries are the type and size and they fit
1016  * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so
1017  * decoding can be done correctly.
1018  */
1019 struct xfs_icreate_log {
1020 	uint16_t	icl_type;	/* type of log format structure */
1021 	uint16_t	icl_size;	/* size of log format structure */
1022 	__be32		icl_ag;		/* ag being allocated in */
1023 	__be32		icl_agbno;	/* start block of inode range */
1024 	__be32		icl_count;	/* number of inodes to initialise */
1025 	__be32		icl_isize;	/* size of inodes */
1026 	__be32		icl_length;	/* length of extent to initialise */
1027 	__be32		icl_gen;	/* inode generation number to use */
1028 };
1029 
1030 /*
1031  * Flags for deferred attribute operations.
1032  * Upper bits are flags, lower byte is type code
1033  */
1034 #define XFS_ATTRI_OP_FLAGS_SET		1	/* Set the attribute */
1035 #define XFS_ATTRI_OP_FLAGS_REMOVE	2	/* Remove the attribute */
1036 #define XFS_ATTRI_OP_FLAGS_REPLACE	3	/* Replace the attribute */
1037 #define XFS_ATTRI_OP_FLAGS_PPTR_SET	4	/* Set parent pointer */
1038 #define XFS_ATTRI_OP_FLAGS_PPTR_REMOVE	5	/* Remove parent pointer */
1039 #define XFS_ATTRI_OP_FLAGS_PPTR_REPLACE	6	/* Replace parent pointer */
1040 #define XFS_ATTRI_OP_FLAGS_TYPE_MASK	0xFF	/* Flags type mask */
1041 
1042 /*
1043  * alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should
1044  * never have any other bits set.
1045  */
1046 #define XFS_ATTRI_FILTER_MASK		(XFS_ATTR_ROOT | \
1047 					 XFS_ATTR_SECURE | \
1048 					 XFS_ATTR_PARENT | \
1049 					 XFS_ATTR_INCOMPLETE)
1050 
1051 /*
1052  * This is the structure used to lay out an attr log item in the
1053  * log.
1054  */
1055 struct xfs_attri_log_format {
1056 	uint16_t	alfi_type;	/* attri log item type */
1057 	uint16_t	alfi_size;	/* size of this item */
1058 	uint32_t	alfi_igen;	/* generation of alfi_ino for pptr ops */
1059 	uint64_t	alfi_id;	/* attri identifier */
1060 	uint64_t	alfi_ino;	/* the inode for this attr operation */
1061 	uint32_t	alfi_op_flags;	/* marks the op as a set or remove */
1062 	union {
1063 		uint32_t	alfi_name_len;	/* attr name length */
1064 		struct {
1065 			/*
1066 			 * For PPTR_REPLACE, these are the lengths of the old
1067 			 * and new attr names.  The new and old values must
1068 			 * have the same length.
1069 			 */
1070 			uint16_t	alfi_old_name_len;
1071 			uint16_t	alfi_new_name_len;
1072 		};
1073 	};
1074 	uint32_t	alfi_value_len;	/* attr value length */
1075 	uint32_t	alfi_attr_filter;/* attr filter flags */
1076 };
1077 
1078 struct xfs_attrd_log_format {
1079 	uint16_t	alfd_type;	/* attrd log item type */
1080 	uint16_t	alfd_size;	/* size of this item */
1081 	uint32_t	__pad;		/* pad to 64 bit aligned */
1082 	uint64_t	alfd_alf_id;	/* id of corresponding attri */
1083 };
1084 
1085 #endif /* __XFS_LOG_FORMAT_H__ */
1086