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