Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_LOG_FORMAT_H__ |
| 7 | #define __XFS_LOG_FORMAT_H__ |
| 8 | |
Jie Liu | e773fc93 | 2013-08-12 20:50:01 +1000 | [diff] [blame] | 9 | struct xfs_mount; |
Jie Liu | 5a96a94 | 2013-08-12 20:50:02 +1000 | [diff] [blame] | 10 | struct xfs_trans_res; |
Jie Liu | e773fc93 | 2013-08-12 20:50:01 +1000 | [diff] [blame] | 11 | |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 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 | */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 22 | typedef uint32_t xlog_tid_t; |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 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 | #define XLOG_BTOLSUNIT(log, b) (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \ |
| 38 | (log)->l_mp->m_sb.sb_logsunit) |
| 39 | #define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit) |
| 40 | |
| 41 | #define XLOG_HEADER_SIZE 512 |
| 42 | |
Jie Liu | 5a96a94 | 2013-08-12 20:50:02 +1000 | [diff] [blame] | 43 | /* Minimum number of transactions that must fit in the log (defined by mkfs) */ |
| 44 | #define XFS_MIN_LOG_FACTOR 3 |
| 45 | |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 46 | #define XLOG_REC_SHIFT(log) \ |
| 47 | BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ |
| 48 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) |
| 49 | #define XLOG_TOTAL_REC_SHIFT(log) \ |
| 50 | BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \ |
| 51 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) |
| 52 | |
| 53 | /* get lsn fields */ |
| 54 | #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) |
| 55 | #define BLOCK_LSN(lsn) ((uint)(lsn)) |
| 56 | |
| 57 | /* this is used in a spot where we might otherwise double-endian-flip */ |
| 58 | #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) |
| 59 | |
| 60 | static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block) |
| 61 | { |
| 62 | return ((xfs_lsn_t)cycle << 32) | block; |
| 63 | } |
| 64 | |
| 65 | static inline uint xlog_get_cycle(char *ptr) |
| 66 | { |
| 67 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) |
| 68 | return be32_to_cpu(*((__be32 *)ptr + 1)); |
| 69 | else |
| 70 | return be32_to_cpu(*(__be32 *)ptr); |
| 71 | } |
| 72 | |
| 73 | /* Log Clients */ |
| 74 | #define XFS_TRANSACTION 0x69 |
| 75 | #define XFS_VOLUME 0x2 |
| 76 | #define XFS_LOG 0xaa |
| 77 | |
| 78 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ |
| 79 | |
Darrick J. Wong | 53235f2 | 2018-07-20 09:28:39 -0700 | [diff] [blame] | 80 | /* |
| 81 | * Log item for unmount records. |
| 82 | * |
| 83 | * The unmount record used to have a string "Unmount filesystem--" in the |
| 84 | * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE). |
| 85 | * We just write the magic number now; see xfs_log_unmount_write. |
| 86 | */ |
| 87 | struct xfs_unmount_log_format { |
| 88 | uint16_t magic; /* XLOG_UNMOUNT_TYPE */ |
| 89 | uint16_t pad1; |
| 90 | uint32_t pad2; /* may as well make it 64 bits */ |
| 91 | }; |
| 92 | |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 93 | /* Region types for iovec's i_type */ |
| 94 | #define XLOG_REG_TYPE_BFORMAT 1 |
| 95 | #define XLOG_REG_TYPE_BCHUNK 2 |
| 96 | #define XLOG_REG_TYPE_EFI_FORMAT 3 |
| 97 | #define XLOG_REG_TYPE_EFD_FORMAT 4 |
| 98 | #define XLOG_REG_TYPE_IFORMAT 5 |
| 99 | #define XLOG_REG_TYPE_ICORE 6 |
| 100 | #define XLOG_REG_TYPE_IEXT 7 |
| 101 | #define XLOG_REG_TYPE_IBROOT 8 |
| 102 | #define XLOG_REG_TYPE_ILOCAL 9 |
| 103 | #define XLOG_REG_TYPE_IATTR_EXT 10 |
| 104 | #define XLOG_REG_TYPE_IATTR_BROOT 11 |
| 105 | #define XLOG_REG_TYPE_IATTR_LOCAL 12 |
| 106 | #define XLOG_REG_TYPE_QFORMAT 13 |
| 107 | #define XLOG_REG_TYPE_DQUOT 14 |
| 108 | #define XLOG_REG_TYPE_QUOTAOFF 15 |
| 109 | #define XLOG_REG_TYPE_LRHEADER 16 |
| 110 | #define XLOG_REG_TYPE_UNMOUNT 17 |
| 111 | #define XLOG_REG_TYPE_COMMIT 18 |
| 112 | #define XLOG_REG_TYPE_TRANSHDR 19 |
| 113 | #define XLOG_REG_TYPE_ICREATE 20 |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 114 | #define XLOG_REG_TYPE_RUI_FORMAT 21 |
| 115 | #define XLOG_REG_TYPE_RUD_FORMAT 22 |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 116 | #define XLOG_REG_TYPE_CUI_FORMAT 23 |
| 117 | #define XLOG_REG_TYPE_CUD_FORMAT 24 |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 118 | #define XLOG_REG_TYPE_BUI_FORMAT 25 |
| 119 | #define XLOG_REG_TYPE_BUD_FORMAT 26 |
| 120 | #define XLOG_REG_TYPE_MAX 26 |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Flags to log operation header |
| 124 | * |
| 125 | * The first write of a new transaction will be preceded with a start |
| 126 | * record, XLOG_START_TRANS. Once a transaction is committed, a commit |
| 127 | * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into |
| 128 | * the remainder of the current active in-core log, it is split up into |
| 129 | * multiple regions. Each partial region will be marked with a |
| 130 | * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. |
| 131 | * |
| 132 | */ |
| 133 | #define XLOG_START_TRANS 0x01 /* Start a new transaction */ |
| 134 | #define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */ |
| 135 | #define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */ |
| 136 | #define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */ |
| 137 | #define XLOG_END_TRANS 0x10 /* End a continued transaction */ |
| 138 | #define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */ |
| 139 | |
| 140 | |
| 141 | typedef struct xlog_op_header { |
| 142 | __be32 oh_tid; /* transaction id of operation : 4 b */ |
| 143 | __be32 oh_len; /* bytes in data region : 4 b */ |
| 144 | __u8 oh_clientid; /* who sent me this : 1 b */ |
| 145 | __u8 oh_flags; /* : 1 b */ |
| 146 | __u16 oh_res2; /* 32 bit align : 2 b */ |
| 147 | } xlog_op_header_t; |
| 148 | |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 149 | /* valid values for h_fmt */ |
| 150 | #define XLOG_FMT_UNKNOWN 0 |
| 151 | #define XLOG_FMT_LINUX_LE 1 |
| 152 | #define XLOG_FMT_LINUX_BE 2 |
| 153 | #define XLOG_FMT_IRIX_BE 3 |
| 154 | |
| 155 | /* our fmt */ |
| 156 | #ifdef XFS_NATIVE_HOST |
| 157 | #define XLOG_FMT XLOG_FMT_LINUX_BE |
| 158 | #else |
| 159 | #define XLOG_FMT XLOG_FMT_LINUX_LE |
| 160 | #endif |
| 161 | |
| 162 | typedef struct xlog_rec_header { |
| 163 | __be32 h_magicno; /* log record (LR) identifier : 4 */ |
| 164 | __be32 h_cycle; /* write cycle of log : 4 */ |
| 165 | __be32 h_version; /* LR version : 4 */ |
| 166 | __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */ |
| 167 | __be64 h_lsn; /* lsn of this LR : 8 */ |
| 168 | __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ |
| 169 | __le32 h_crc; /* crc of log record : 4 */ |
| 170 | __be32 h_prev_block; /* block number to previous LR : 4 */ |
| 171 | __be32 h_num_logops; /* number of log operations in this LR : 4 */ |
| 172 | __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; |
| 173 | /* new fields */ |
| 174 | __be32 h_fmt; /* format of log record : 4 */ |
| 175 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ |
| 176 | __be32 h_size; /* iclog size : 4 */ |
| 177 | } xlog_rec_header_t; |
| 178 | |
| 179 | typedef struct xlog_rec_ext_header { |
| 180 | __be32 xh_cycle; /* write cycle of log : 4 */ |
| 181 | __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ |
| 182 | } xlog_rec_ext_header_t; |
| 183 | |
| 184 | /* |
| 185 | * Quite misnamed, because this union lays out the actual on-disk log buffer. |
| 186 | */ |
| 187 | typedef union xlog_in_core2 { |
| 188 | xlog_rec_header_t hic_header; |
| 189 | xlog_rec_ext_header_t hic_xheader; |
| 190 | char hic_sector[XLOG_HEADER_SIZE]; |
| 191 | } xlog_in_core_2_t; |
| 192 | |
| 193 | /* not an on-disk structure, but needed by log recovery in userspace */ |
| 194 | typedef struct xfs_log_iovec { |
| 195 | void *i_addr; /* beginning address of region */ |
| 196 | int i_len; /* length in bytes of region */ |
| 197 | uint i_type; /* type of region */ |
| 198 | } xfs_log_iovec_t; |
| 199 | |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 200 | |
| 201 | /* |
Dave Chinner | 2a3c0ac | 2013-08-12 20:49:28 +1000 | [diff] [blame] | 202 | * Transaction Header definitions. |
| 203 | * |
| 204 | * This is the structure written in the log at the head of every transaction. It |
| 205 | * identifies the type and id of the transaction, and contains the number of |
| 206 | * items logged by the transaction so we know how many to expect during |
| 207 | * recovery. |
| 208 | * |
| 209 | * Do not change the below structure without redoing the code in |
| 210 | * xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans(). |
| 211 | */ |
| 212 | typedef struct xfs_trans_header { |
| 213 | uint th_magic; /* magic number */ |
| 214 | uint th_type; /* transaction type */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 215 | int32_t th_tid; /* transaction id (unused) */ |
Dave Chinner | 2a3c0ac | 2013-08-12 20:49:28 +1000 | [diff] [blame] | 216 | uint th_num_items; /* num items logged by trans */ |
| 217 | } xfs_trans_header_t; |
| 218 | |
| 219 | #define XFS_TRANS_HEADER_MAGIC 0x5452414e /* TRAN */ |
| 220 | |
| 221 | /* |
Christoph Hellwig | 710b1e2c | 2016-04-06 09:20:36 +1000 | [diff] [blame] | 222 | * The only type valid for th_type in CIL-enabled file system logs: |
| 223 | */ |
| 224 | #define XFS_TRANS_CHECKPOINT 40 |
| 225 | |
| 226 | /* |
Dave Chinner | 2a3c0ac | 2013-08-12 20:49:28 +1000 | [diff] [blame] | 227 | * Log item types. |
| 228 | */ |
| 229 | #define XFS_LI_EFI 0x1236 |
| 230 | #define XFS_LI_EFD 0x1237 |
| 231 | #define XFS_LI_IUNLINK 0x1238 |
| 232 | #define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */ |
| 233 | #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */ |
| 234 | #define XFS_LI_DQUOT 0x123d |
| 235 | #define XFS_LI_QUOTAOFF 0x123e |
| 236 | #define XFS_LI_ICREATE 0x123f |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 237 | #define XFS_LI_RUI 0x1240 /* rmap update intent */ |
| 238 | #define XFS_LI_RUD 0x1241 |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 239 | #define XFS_LI_CUI 0x1242 /* refcount update intent */ |
| 240 | #define XFS_LI_CUD 0x1243 |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 241 | #define XFS_LI_BUI 0x1244 /* bmbt update intent */ |
| 242 | #define XFS_LI_BUD 0x1245 |
Dave Chinner | 2a3c0ac | 2013-08-12 20:49:28 +1000 | [diff] [blame] | 243 | |
| 244 | #define XFS_LI_TYPE_DESC \ |
| 245 | { XFS_LI_EFI, "XFS_LI_EFI" }, \ |
| 246 | { XFS_LI_EFD, "XFS_LI_EFD" }, \ |
| 247 | { XFS_LI_IUNLINK, "XFS_LI_IUNLINK" }, \ |
| 248 | { XFS_LI_INODE, "XFS_LI_INODE" }, \ |
| 249 | { XFS_LI_BUF, "XFS_LI_BUF" }, \ |
| 250 | { XFS_LI_DQUOT, "XFS_LI_DQUOT" }, \ |
| 251 | { XFS_LI_QUOTAOFF, "XFS_LI_QUOTAOFF" }, \ |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 252 | { XFS_LI_ICREATE, "XFS_LI_ICREATE" }, \ |
| 253 | { XFS_LI_RUI, "XFS_LI_RUI" }, \ |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 254 | { XFS_LI_RUD, "XFS_LI_RUD" }, \ |
| 255 | { XFS_LI_CUI, "XFS_LI_CUI" }, \ |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 256 | { XFS_LI_CUD, "XFS_LI_CUD" }, \ |
| 257 | { XFS_LI_BUI, "XFS_LI_BUI" }, \ |
| 258 | { XFS_LI_BUD, "XFS_LI_BUD" } |
Dave Chinner | 2a3c0ac | 2013-08-12 20:49:28 +1000 | [diff] [blame] | 259 | |
| 260 | /* |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 261 | * Inode Log Item Format definitions. |
| 262 | * |
| 263 | * This is the structure used to lay out an inode log item in the |
| 264 | * log. The size of the inline data/extents/b-tree root to be logged |
| 265 | * (if any) is indicated in the ilf_dsize field. Changes to this structure |
| 266 | * must be added on to the end. |
| 267 | */ |
Darrick J. Wong | 06b1132 | 2017-10-31 12:04:24 -0700 | [diff] [blame] | 268 | struct xfs_inode_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 269 | uint16_t ilf_type; /* inode log item type */ |
| 270 | uint16_t ilf_size; /* size of this item */ |
| 271 | uint32_t ilf_fields; /* flags for fields logged */ |
| 272 | uint16_t ilf_asize; /* size of attr d/ext/root */ |
| 273 | uint16_t ilf_dsize; /* size of data/ext/root */ |
Dave Chinner | 20413e37 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 274 | uint32_t ilf_pad; /* pad for 64 bit boundary */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 275 | uint64_t ilf_ino; /* inode number */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 276 | union { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 277 | uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
Darrick J. Wong | 2015a63 | 2017-11-16 09:20:17 -0800 | [diff] [blame] | 278 | uint8_t __pad[16]; /* unused */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 279 | } ilf_u; |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 280 | int64_t ilf_blkno; /* blkno of inode buffer */ |
| 281 | int32_t ilf_len; /* len of inode buffer */ |
| 282 | int32_t ilf_boffset; /* off of inode in buffer */ |
Darrick J. Wong | 06b1132 | 2017-10-31 12:04:24 -0700 | [diff] [blame] | 283 | }; |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 284 | |
Dave Chinner | 20413e37 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 285 | /* |
| 286 | * Old 32 bit systems will log in this format without the 64 bit |
| 287 | * alignment padding. Recovery will detect this and convert it to the |
| 288 | * correct format. |
| 289 | */ |
| 290 | struct xfs_inode_log_format_32 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 291 | uint16_t ilf_type; /* inode log item type */ |
| 292 | uint16_t ilf_size; /* size of this item */ |
| 293 | uint32_t ilf_fields; /* flags for fields logged */ |
| 294 | uint16_t ilf_asize; /* size of attr d/ext/root */ |
| 295 | uint16_t ilf_dsize; /* size of data/ext/root */ |
| 296 | uint64_t ilf_ino; /* inode number */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 297 | union { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 298 | uint32_t ilfu_rdev; /* rdev value for dev inode*/ |
Darrick J. Wong | 2015a63 | 2017-11-16 09:20:17 -0800 | [diff] [blame] | 299 | uint8_t __pad[16]; /* unused */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 300 | } ilf_u; |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 301 | int64_t ilf_blkno; /* blkno of inode buffer */ |
| 302 | int32_t ilf_len; /* len of inode buffer */ |
| 303 | int32_t ilf_boffset; /* off of inode in buffer */ |
Dave Chinner | 20413e37 | 2017-10-09 11:37:22 -0700 | [diff] [blame] | 304 | } __attribute__((packed)); |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 305 | |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 306 | |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 307 | /* |
| 308 | * Flags for xfs_trans_log_inode flags field. |
| 309 | */ |
| 310 | #define XFS_ILOG_CORE 0x001 /* log standard inode fields */ |
| 311 | #define XFS_ILOG_DDATA 0x002 /* log i_df.if_data */ |
| 312 | #define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */ |
| 313 | #define XFS_ILOG_DBROOT 0x008 /* log i_df.i_broot */ |
| 314 | #define XFS_ILOG_DEV 0x010 /* log the dev field */ |
Christoph Hellwig | 42b67dc | 2017-10-19 11:07:09 -0700 | [diff] [blame] | 315 | #define XFS_ILOG_UUID 0x020 /* added long ago, but never used */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 316 | #define XFS_ILOG_ADATA 0x040 /* log i_af.if_data */ |
| 317 | #define XFS_ILOG_AEXT 0x080 /* log i_af.if_extents */ |
| 318 | #define XFS_ILOG_ABROOT 0x100 /* log i_af.i_broot */ |
Dave Chinner | 638f4416 | 2013-08-30 10:23:45 +1000 | [diff] [blame] | 319 | #define XFS_ILOG_DOWNER 0x200 /* change the data fork owner on replay */ |
| 320 | #define XFS_ILOG_AOWNER 0x400 /* change the attr fork owner on replay */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 321 | |
| 322 | |
| 323 | /* |
| 324 | * The timestamps are dirty, but not necessarily anything else in the inode |
| 325 | * core. Unlike the other fields above this one must never make it to disk |
| 326 | * in the ilf_fields of the inode_log_format, but is purely store in-memory in |
| 327 | * ili_fields in the inode_log_item. |
| 328 | */ |
| 329 | #define XFS_ILOG_TIMESTAMP 0x4000 |
| 330 | |
| 331 | #define XFS_ILOG_NONCORE (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ |
| 332 | XFS_ILOG_DBROOT | XFS_ILOG_DEV | \ |
Christoph Hellwig | 42b67dc | 2017-10-19 11:07:09 -0700 | [diff] [blame] | 333 | XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ |
| 334 | XFS_ILOG_ABROOT | XFS_ILOG_DOWNER | \ |
| 335 | XFS_ILOG_AOWNER) |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 336 | |
| 337 | #define XFS_ILOG_DFORK (XFS_ILOG_DDATA | XFS_ILOG_DEXT | \ |
| 338 | XFS_ILOG_DBROOT) |
| 339 | |
| 340 | #define XFS_ILOG_AFORK (XFS_ILOG_ADATA | XFS_ILOG_AEXT | \ |
| 341 | XFS_ILOG_ABROOT) |
| 342 | |
| 343 | #define XFS_ILOG_ALL (XFS_ILOG_CORE | XFS_ILOG_DDATA | \ |
| 344 | XFS_ILOG_DEXT | XFS_ILOG_DBROOT | \ |
Christoph Hellwig | 42b67dc | 2017-10-19 11:07:09 -0700 | [diff] [blame] | 345 | XFS_ILOG_DEV | XFS_ILOG_ADATA | \ |
| 346 | XFS_ILOG_AEXT | XFS_ILOG_ABROOT | \ |
| 347 | XFS_ILOG_TIMESTAMP | XFS_ILOG_DOWNER | \ |
| 348 | XFS_ILOG_AOWNER) |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 349 | |
| 350 | static inline int xfs_ilog_fbroot(int w) |
| 351 | { |
| 352 | return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT); |
| 353 | } |
| 354 | |
| 355 | static inline int xfs_ilog_fext(int w) |
| 356 | { |
| 357 | return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT); |
| 358 | } |
| 359 | |
| 360 | static inline int xfs_ilog_fdata(int w) |
| 361 | { |
| 362 | return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA); |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | * Incore version of the on-disk inode core structures. We log this directly |
| 367 | * into the journal in host CPU format (for better or worse) and as such |
| 368 | * directly mirrors the xfs_dinode structure as it must contain all the same |
| 369 | * information. |
| 370 | */ |
| 371 | typedef struct xfs_ictimestamp { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 372 | int32_t t_sec; /* timestamp seconds */ |
| 373 | int32_t t_nsec; /* timestamp nanoseconds */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 374 | } xfs_ictimestamp_t; |
| 375 | |
| 376 | /* |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 377 | * Define the format of the inode core that is logged. This structure must be |
| 378 | * kept identical to struct xfs_dinode except for the endianness annotations. |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 379 | */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 380 | struct xfs_log_dinode { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 381 | uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ |
| 382 | uint16_t di_mode; /* mode and type of file */ |
| 383 | int8_t di_version; /* inode version */ |
| 384 | int8_t di_format; /* format of di_c data */ |
| 385 | uint8_t di_pad3[2]; /* unused in v2/3 inodes */ |
| 386 | uint32_t di_uid; /* owner's user id */ |
| 387 | uint32_t di_gid; /* owner's group id */ |
| 388 | uint32_t di_nlink; /* number of links to file */ |
| 389 | uint16_t di_projid_lo; /* lower part of owner's project id */ |
| 390 | uint16_t di_projid_hi; /* higher part of owner's project id */ |
| 391 | uint8_t di_pad[6]; /* unused, zeroed space */ |
| 392 | uint16_t di_flushiter; /* incremented on flush */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 393 | xfs_ictimestamp_t di_atime; /* time last accessed */ |
| 394 | xfs_ictimestamp_t di_mtime; /* time last modified */ |
| 395 | xfs_ictimestamp_t di_ctime; /* time created/inode modified */ |
| 396 | xfs_fsize_t di_size; /* number of bytes in file */ |
Christoph Hellwig | d5cf09b | 2014-07-30 09:12:05 +1000 | [diff] [blame] | 397 | xfs_rfsblock_t di_nblocks; /* # of direct & btree blocks used */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 398 | xfs_extlen_t di_extsize; /* basic/minimum extent size for file */ |
| 399 | xfs_extnum_t di_nextents; /* number of extents in data fork */ |
| 400 | xfs_aextnum_t di_anextents; /* number of extents in attribute fork*/ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 401 | uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ |
| 402 | int8_t di_aformat; /* format of attr fork's data */ |
| 403 | uint32_t di_dmevmask; /* DMIG event mask */ |
| 404 | uint16_t di_dmstate; /* DMIG state info */ |
| 405 | uint16_t di_flags; /* random flags, XFS_DIFLAG_... */ |
| 406 | uint32_t di_gen; /* generation number */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 407 | |
| 408 | /* di_next_unlinked is the only non-core field in the old dinode */ |
| 409 | xfs_agino_t di_next_unlinked;/* agi unlinked list ptr */ |
| 410 | |
| 411 | /* start of the extended dinode, writable fields */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 412 | uint32_t di_crc; /* CRC of the inode */ |
| 413 | uint64_t di_changecount; /* number of attribute changes */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 414 | xfs_lsn_t di_lsn; /* flush sequence */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 415 | uint64_t di_flags2; /* more random flags */ |
| 416 | uint32_t di_cowextsize; /* basic cow extent size for file */ |
| 417 | uint8_t di_pad2[12]; /* more padding for future expansion */ |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 418 | |
| 419 | /* fields only written to during inode creation */ |
| 420 | xfs_ictimestamp_t di_crtime; /* time created */ |
| 421 | xfs_ino_t di_ino; /* inode number */ |
| 422 | uuid_t di_uuid; /* UUID of the filesystem */ |
| 423 | |
| 424 | /* structure must be padded to 64 bit alignment */ |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 425 | }; |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 426 | |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 427 | static inline uint xfs_log_dinode_size(int version) |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 428 | { |
| 429 | if (version == 3) |
Dave Chinner | f8d55aa052 | 2016-02-09 16:54:58 +1100 | [diff] [blame] | 430 | return sizeof(struct xfs_log_dinode); |
| 431 | return offsetof(struct xfs_log_dinode, di_next_unlinked); |
Dave Chinner | 6943283 | 2013-08-12 20:49:23 +1000 | [diff] [blame] | 432 | } |
Dave Chinner | a8da0da | 2013-08-12 20:49:24 +1000 | [diff] [blame] | 433 | |
| 434 | /* |
| 435 | * Buffer Log Format defintions |
| 436 | * |
| 437 | * These are the physical dirty bitmap defintions for the log format structure. |
| 438 | */ |
| 439 | #define XFS_BLF_CHUNK 128 |
| 440 | #define XFS_BLF_SHIFT 7 |
| 441 | #define BIT_TO_WORD_SHIFT 5 |
| 442 | #define NBWORD (NBBY * sizeof(unsigned int)) |
| 443 | |
| 444 | /* |
| 445 | * This flag indicates that the buffer contains on disk inodes |
| 446 | * and requires special recovery handling. |
| 447 | */ |
| 448 | #define XFS_BLF_INODE_BUF (1<<0) |
| 449 | |
| 450 | /* |
| 451 | * This flag indicates that the buffer should not be replayed |
| 452 | * during recovery because its blocks are being freed. |
| 453 | */ |
| 454 | #define XFS_BLF_CANCEL (1<<1) |
| 455 | |
| 456 | /* |
| 457 | * This flag indicates that the buffer contains on disk |
| 458 | * user or group dquots and may require special recovery handling. |
| 459 | */ |
| 460 | #define XFS_BLF_UDQUOT_BUF (1<<2) |
| 461 | #define XFS_BLF_PDQUOT_BUF (1<<3) |
| 462 | #define XFS_BLF_GDQUOT_BUF (1<<4) |
| 463 | |
| 464 | /* |
| 465 | * This is the structure used to lay out a buf log item in the |
| 466 | * log. The data map describes which 128 byte chunks of the buffer |
| 467 | * have been logged. |
| 468 | */ |
| 469 | #define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD) |
| 470 | |
| 471 | typedef struct xfs_buf_log_format { |
| 472 | unsigned short blf_type; /* buf log item type indicator */ |
| 473 | unsigned short blf_size; /* size of this item */ |
Darrick J. Wong | 755c7bf | 2016-11-08 11:55:48 +1100 | [diff] [blame] | 474 | unsigned short blf_flags; /* misc state */ |
| 475 | unsigned short blf_len; /* number of blocks in this buf */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 476 | int64_t blf_blkno; /* starting blkno of this buf */ |
Dave Chinner | a8da0da | 2013-08-12 20:49:24 +1000 | [diff] [blame] | 477 | unsigned int blf_map_size; /* used size of data bitmap in words */ |
| 478 | unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */ |
| 479 | } xfs_buf_log_format_t; |
| 480 | |
| 481 | /* |
| 482 | * All buffers now need to tell recovery where the magic number |
| 483 | * is so that it can verify and calculate the CRCs on the buffer correctly |
| 484 | * once the changes have been replayed into the buffer. |
| 485 | * |
| 486 | * The type value is held in the upper 5 bits of the blf_flags field, which is |
| 487 | * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down. |
| 488 | */ |
| 489 | #define XFS_BLFT_BITS 5 |
| 490 | #define XFS_BLFT_SHIFT 11 |
| 491 | #define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT) |
| 492 | |
| 493 | enum xfs_blft { |
| 494 | XFS_BLFT_UNKNOWN_BUF = 0, |
| 495 | XFS_BLFT_UDQUOT_BUF, |
| 496 | XFS_BLFT_PDQUOT_BUF, |
| 497 | XFS_BLFT_GDQUOT_BUF, |
| 498 | XFS_BLFT_BTREE_BUF, |
| 499 | XFS_BLFT_AGF_BUF, |
| 500 | XFS_BLFT_AGFL_BUF, |
| 501 | XFS_BLFT_AGI_BUF, |
| 502 | XFS_BLFT_DINO_BUF, |
| 503 | XFS_BLFT_SYMLINK_BUF, |
| 504 | XFS_BLFT_DIR_BLOCK_BUF, |
| 505 | XFS_BLFT_DIR_DATA_BUF, |
| 506 | XFS_BLFT_DIR_FREE_BUF, |
| 507 | XFS_BLFT_DIR_LEAF1_BUF, |
| 508 | XFS_BLFT_DIR_LEAFN_BUF, |
| 509 | XFS_BLFT_DA_NODE_BUF, |
| 510 | XFS_BLFT_ATTR_LEAF_BUF, |
| 511 | XFS_BLFT_ATTR_RMT_BUF, |
| 512 | XFS_BLFT_SB_BUF, |
Dave Chinner | f67ca6e | 2016-02-09 16:41:31 +1100 | [diff] [blame] | 513 | XFS_BLFT_RTBITMAP_BUF, |
| 514 | XFS_BLFT_RTSUMMARY_BUF, |
Dave Chinner | a8da0da | 2013-08-12 20:49:24 +1000 | [diff] [blame] | 515 | XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS), |
| 516 | }; |
| 517 | |
| 518 | static inline void |
| 519 | xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type) |
| 520 | { |
| 521 | ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF); |
| 522 | blf->blf_flags &= ~XFS_BLFT_MASK; |
| 523 | blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK); |
| 524 | } |
| 525 | |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 526 | static inline uint16_t |
Dave Chinner | a8da0da | 2013-08-12 20:49:24 +1000 | [diff] [blame] | 527 | xfs_blft_from_flags(struct xfs_buf_log_format *blf) |
| 528 | { |
| 529 | return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT; |
| 530 | } |
| 531 | |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 532 | /* |
| 533 | * EFI/EFD log format definitions |
| 534 | */ |
| 535 | typedef struct xfs_extent { |
Christoph Hellwig | d5cf09b | 2014-07-30 09:12:05 +1000 | [diff] [blame] | 536 | xfs_fsblock_t ext_start; |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 537 | xfs_extlen_t ext_len; |
| 538 | } xfs_extent_t; |
| 539 | |
| 540 | /* |
| 541 | * Since an xfs_extent_t has types (start:64, len: 32) |
| 542 | * there are different alignments on 32 bit and 64 bit kernels. |
| 543 | * So we provide the different variants for use by a |
| 544 | * conversion routine. |
| 545 | */ |
| 546 | typedef struct xfs_extent_32 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 547 | uint64_t ext_start; |
| 548 | uint32_t ext_len; |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 549 | } __attribute__((packed)) xfs_extent_32_t; |
| 550 | |
| 551 | typedef struct xfs_extent_64 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 552 | uint64_t ext_start; |
| 553 | uint32_t ext_len; |
| 554 | uint32_t ext_pad; |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 555 | } xfs_extent_64_t; |
| 556 | |
| 557 | /* |
| 558 | * This is the structure used to lay out an efi log item in the |
| 559 | * log. The efi_extents field is a variable size array whose |
| 560 | * size is given by efi_nextents. |
| 561 | */ |
| 562 | typedef struct xfs_efi_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 563 | uint16_t efi_type; /* efi log item type */ |
| 564 | uint16_t efi_size; /* size of this item */ |
| 565 | uint32_t efi_nextents; /* # extents to free */ |
| 566 | uint64_t efi_id; /* efi identifier */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 567 | xfs_extent_t efi_extents[1]; /* array of extents to free */ |
| 568 | } xfs_efi_log_format_t; |
| 569 | |
| 570 | typedef struct xfs_efi_log_format_32 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 571 | uint16_t efi_type; /* efi log item type */ |
| 572 | uint16_t efi_size; /* size of this item */ |
| 573 | uint32_t efi_nextents; /* # extents to free */ |
| 574 | uint64_t efi_id; /* efi identifier */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 575 | xfs_extent_32_t efi_extents[1]; /* array of extents to free */ |
| 576 | } __attribute__((packed)) xfs_efi_log_format_32_t; |
| 577 | |
| 578 | typedef struct xfs_efi_log_format_64 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 579 | uint16_t efi_type; /* efi log item type */ |
| 580 | uint16_t efi_size; /* size of this item */ |
| 581 | uint32_t efi_nextents; /* # extents to free */ |
| 582 | uint64_t efi_id; /* efi identifier */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 583 | xfs_extent_64_t efi_extents[1]; /* array of extents to free */ |
| 584 | } xfs_efi_log_format_64_t; |
| 585 | |
| 586 | /* |
| 587 | * This is the structure used to lay out an efd log item in the |
| 588 | * log. The efd_extents array is a variable size array whose |
| 589 | * size is given by efd_nextents; |
| 590 | */ |
| 591 | typedef struct xfs_efd_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 592 | uint16_t efd_type; /* efd log item type */ |
| 593 | uint16_t efd_size; /* size of this item */ |
| 594 | uint32_t efd_nextents; /* # of extents freed */ |
| 595 | uint64_t efd_efi_id; /* id of corresponding efi */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 596 | xfs_extent_t efd_extents[1]; /* array of extents freed */ |
| 597 | } xfs_efd_log_format_t; |
| 598 | |
| 599 | typedef struct xfs_efd_log_format_32 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 600 | uint16_t efd_type; /* efd log item type */ |
| 601 | uint16_t efd_size; /* size of this item */ |
| 602 | uint32_t efd_nextents; /* # of extents freed */ |
| 603 | uint64_t efd_efi_id; /* id of corresponding efi */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 604 | xfs_extent_32_t efd_extents[1]; /* array of extents freed */ |
| 605 | } __attribute__((packed)) xfs_efd_log_format_32_t; |
| 606 | |
| 607 | typedef struct xfs_efd_log_format_64 { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 608 | uint16_t efd_type; /* efd log item type */ |
| 609 | uint16_t efd_size; /* size of this item */ |
| 610 | uint32_t efd_nextents; /* # of extents freed */ |
| 611 | uint64_t efd_efi_id; /* id of corresponding efi */ |
Dave Chinner | 9fbe24d | 2013-08-12 20:49:25 +1000 | [diff] [blame] | 612 | xfs_extent_64_t efd_extents[1]; /* array of extents freed */ |
| 613 | } xfs_efd_log_format_64_t; |
| 614 | |
Dave Chinner | 6ca1c90 | 2013-08-12 20:49:26 +1000 | [diff] [blame] | 615 | /* |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 616 | * RUI/RUD (reverse mapping) log format definitions |
| 617 | */ |
| 618 | struct xfs_map_extent { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 619 | uint64_t me_owner; |
| 620 | uint64_t me_startblock; |
| 621 | uint64_t me_startoff; |
| 622 | uint32_t me_len; |
| 623 | uint32_t me_flags; |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 624 | }; |
| 625 | |
| 626 | /* rmap me_flags: upper bits are flags, lower byte is type code */ |
| 627 | #define XFS_RMAP_EXTENT_MAP 1 |
Darrick J. Wong | 0e07c03 | 2016-10-03 09:11:47 -0700 | [diff] [blame] | 628 | #define XFS_RMAP_EXTENT_MAP_SHARED 2 |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 629 | #define XFS_RMAP_EXTENT_UNMAP 3 |
Darrick J. Wong | 0e07c03 | 2016-10-03 09:11:47 -0700 | [diff] [blame] | 630 | #define XFS_RMAP_EXTENT_UNMAP_SHARED 4 |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 631 | #define XFS_RMAP_EXTENT_CONVERT 5 |
Darrick J. Wong | 0e07c03 | 2016-10-03 09:11:47 -0700 | [diff] [blame] | 632 | #define XFS_RMAP_EXTENT_CONVERT_SHARED 6 |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 633 | #define XFS_RMAP_EXTENT_ALLOC 7 |
| 634 | #define XFS_RMAP_EXTENT_FREE 8 |
| 635 | #define XFS_RMAP_EXTENT_TYPE_MASK 0xFF |
| 636 | |
| 637 | #define XFS_RMAP_EXTENT_ATTR_FORK (1U << 31) |
| 638 | #define XFS_RMAP_EXTENT_BMBT_BLOCK (1U << 30) |
| 639 | #define XFS_RMAP_EXTENT_UNWRITTEN (1U << 29) |
| 640 | |
| 641 | #define XFS_RMAP_EXTENT_FLAGS (XFS_RMAP_EXTENT_TYPE_MASK | \ |
| 642 | XFS_RMAP_EXTENT_ATTR_FORK | \ |
| 643 | XFS_RMAP_EXTENT_BMBT_BLOCK | \ |
| 644 | XFS_RMAP_EXTENT_UNWRITTEN) |
| 645 | |
| 646 | /* |
| 647 | * This is the structure used to lay out an rui log item in the |
| 648 | * log. The rui_extents field is a variable size array whose |
| 649 | * size is given by rui_nextents. |
| 650 | */ |
| 651 | struct xfs_rui_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 652 | uint16_t rui_type; /* rui log item type */ |
| 653 | uint16_t rui_size; /* size of this item */ |
| 654 | uint32_t rui_nextents; /* # extents to free */ |
| 655 | uint64_t rui_id; /* rui identifier */ |
Darrick J. Wong | cd00158 | 2016-09-19 10:24:27 +1000 | [diff] [blame] | 656 | struct xfs_map_extent rui_extents[]; /* array of extents to rmap */ |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 657 | }; |
| 658 | |
Darrick J. Wong | cd00158 | 2016-09-19 10:24:27 +1000 | [diff] [blame] | 659 | static inline size_t |
| 660 | xfs_rui_log_format_sizeof( |
| 661 | unsigned int nr) |
| 662 | { |
| 663 | return sizeof(struct xfs_rui_log_format) + |
| 664 | nr * sizeof(struct xfs_map_extent); |
| 665 | } |
| 666 | |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 667 | /* |
| 668 | * This is the structure used to lay out an rud log item in the |
| 669 | * log. The rud_extents array is a variable size array whose |
| 670 | * size is given by rud_nextents; |
| 671 | */ |
| 672 | struct xfs_rud_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 673 | uint16_t rud_type; /* rud log item type */ |
| 674 | uint16_t rud_size; /* size of this item */ |
| 675 | uint32_t __pad; |
| 676 | uint64_t rud_rui_id; /* id of corresponding rui */ |
Darrick J. Wong | 5880f2d7 | 2016-08-03 12:04:45 +1000 | [diff] [blame] | 677 | }; |
| 678 | |
| 679 | /* |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 680 | * CUI/CUD (refcount update) log format definitions |
| 681 | */ |
| 682 | struct xfs_phys_extent { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 683 | uint64_t pe_startblock; |
| 684 | uint32_t pe_len; |
| 685 | uint32_t pe_flags; |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 686 | }; |
| 687 | |
| 688 | /* refcount pe_flags: upper bits are flags, lower byte is type code */ |
| 689 | /* Type codes are taken directly from enum xfs_refcount_intent_type. */ |
| 690 | #define XFS_REFCOUNT_EXTENT_TYPE_MASK 0xFF |
| 691 | |
| 692 | #define XFS_REFCOUNT_EXTENT_FLAGS (XFS_REFCOUNT_EXTENT_TYPE_MASK) |
| 693 | |
| 694 | /* |
| 695 | * This is the structure used to lay out a cui log item in the |
| 696 | * log. The cui_extents field is a variable size array whose |
| 697 | * size is given by cui_nextents. |
| 698 | */ |
| 699 | struct xfs_cui_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 700 | uint16_t cui_type; /* cui log item type */ |
| 701 | uint16_t cui_size; /* size of this item */ |
| 702 | uint32_t cui_nextents; /* # extents to free */ |
| 703 | uint64_t cui_id; /* cui identifier */ |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 704 | struct xfs_phys_extent cui_extents[]; /* array of extents */ |
| 705 | }; |
| 706 | |
| 707 | static inline size_t |
| 708 | xfs_cui_log_format_sizeof( |
| 709 | unsigned int nr) |
| 710 | { |
| 711 | return sizeof(struct xfs_cui_log_format) + |
| 712 | nr * sizeof(struct xfs_phys_extent); |
| 713 | } |
| 714 | |
| 715 | /* |
| 716 | * This is the structure used to lay out a cud log item in the |
| 717 | * log. The cud_extents array is a variable size array whose |
| 718 | * size is given by cud_nextents; |
| 719 | */ |
| 720 | struct xfs_cud_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 721 | uint16_t cud_type; /* cud log item type */ |
| 722 | uint16_t cud_size; /* size of this item */ |
| 723 | uint32_t __pad; |
| 724 | uint64_t cud_cui_id; /* id of corresponding cui */ |
Darrick J. Wong | baf4bcac | 2016-10-03 09:11:20 -0700 | [diff] [blame] | 725 | }; |
| 726 | |
| 727 | /* |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 728 | * BUI/BUD (inode block mapping) log format definitions |
| 729 | */ |
| 730 | |
| 731 | /* bmbt me_flags: upper bits are flags, lower byte is type code */ |
| 732 | /* Type codes are taken directly from enum xfs_bmap_intent_type. */ |
| 733 | #define XFS_BMAP_EXTENT_TYPE_MASK 0xFF |
| 734 | |
| 735 | #define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31) |
| 736 | #define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30) |
| 737 | |
| 738 | #define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \ |
| 739 | XFS_BMAP_EXTENT_ATTR_FORK | \ |
| 740 | XFS_BMAP_EXTENT_UNWRITTEN) |
| 741 | |
| 742 | /* |
| 743 | * This is the structure used to lay out an bui log item in the |
| 744 | * log. The bui_extents field is a variable size array whose |
| 745 | * size is given by bui_nextents. |
| 746 | */ |
| 747 | struct xfs_bui_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 748 | uint16_t bui_type; /* bui log item type */ |
| 749 | uint16_t bui_size; /* size of this item */ |
| 750 | uint32_t bui_nextents; /* # extents to free */ |
| 751 | uint64_t bui_id; /* bui identifier */ |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 752 | struct xfs_map_extent bui_extents[]; /* array of extents to bmap */ |
| 753 | }; |
| 754 | |
| 755 | static inline size_t |
| 756 | xfs_bui_log_format_sizeof( |
| 757 | unsigned int nr) |
| 758 | { |
| 759 | return sizeof(struct xfs_bui_log_format) + |
| 760 | nr * sizeof(struct xfs_map_extent); |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | * This is the structure used to lay out an bud log item in the |
| 765 | * log. The bud_extents array is a variable size array whose |
| 766 | * size is given by bud_nextents; |
| 767 | */ |
| 768 | struct xfs_bud_log_format { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 769 | uint16_t bud_type; /* bud log item type */ |
| 770 | uint16_t bud_size; /* size of this item */ |
| 771 | uint32_t __pad; |
| 772 | uint64_t bud_bui_id; /* id of corresponding bui */ |
Darrick J. Wong | 6413a01 | 2016-10-03 09:11:25 -0700 | [diff] [blame] | 773 | }; |
| 774 | |
| 775 | /* |
Dave Chinner | 6ca1c90 | 2013-08-12 20:49:26 +1000 | [diff] [blame] | 776 | * Dquot Log format definitions. |
| 777 | * |
| 778 | * The first two fields must be the type and size fitting into |
| 779 | * 32 bits : log_recovery code assumes that. |
| 780 | */ |
| 781 | typedef struct xfs_dq_logformat { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 782 | uint16_t qlf_type; /* dquot log item type */ |
| 783 | uint16_t qlf_size; /* size of this item */ |
Dave Chinner | 6ca1c90 | 2013-08-12 20:49:26 +1000 | [diff] [blame] | 784 | xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 785 | int64_t qlf_blkno; /* blkno of dquot buffer */ |
| 786 | int32_t qlf_len; /* len of dquot buffer */ |
| 787 | uint32_t qlf_boffset; /* off of dquot in buffer */ |
Dave Chinner | 6ca1c90 | 2013-08-12 20:49:26 +1000 | [diff] [blame] | 788 | } xfs_dq_logformat_t; |
| 789 | |
| 790 | /* |
| 791 | * log format struct for QUOTAOFF records. |
| 792 | * The first two fields must be the type and size fitting into |
| 793 | * 32 bits : log_recovery code assumes that. |
| 794 | * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer |
| 795 | * to the first and ensures that the first logitem is taken out of the AIL |
| 796 | * only when the last one is securely committed. |
| 797 | */ |
| 798 | typedef struct xfs_qoff_logformat { |
| 799 | unsigned short qf_type; /* quotaoff log item type */ |
| 800 | unsigned short qf_size; /* size of this item */ |
| 801 | unsigned int qf_flags; /* USR and/or GRP */ |
| 802 | char qf_pad[12]; /* padding for future */ |
| 803 | } xfs_qoff_logformat_t; |
| 804 | |
Dave Chinner | 6ca1c90 | 2013-08-12 20:49:26 +1000 | [diff] [blame] | 805 | /* |
| 806 | * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. |
| 807 | */ |
| 808 | #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ |
| 809 | #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ |
| 810 | #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ |
| 811 | #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */ |
| 812 | #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */ |
| 813 | #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */ |
| 814 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ |
| 815 | |
| 816 | /* |
| 817 | * Conversion to and from the combined OQUOTA flag (if necessary) |
| 818 | * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk() |
| 819 | */ |
| 820 | #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */ |
| 821 | #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */ |
| 822 | #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */ |
| 823 | #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */ |
| 824 | |
| 825 | #define XFS_ALL_QUOTA_ACCT \ |
| 826 | (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) |
| 827 | #define XFS_ALL_QUOTA_ENFD \ |
| 828 | (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) |
| 829 | #define XFS_ALL_QUOTA_CHKD \ |
| 830 | (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD) |
| 831 | |
Dave Chinner | 1d03c6f | 2013-08-30 16:21:21 +1000 | [diff] [blame] | 832 | #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ |
| 833 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ |
| 834 | XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\ |
| 835 | XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\ |
| 836 | XFS_PQUOTA_CHKD) |
| 837 | |
Dave Chinner | 9cd047f3 | 2013-08-12 20:49:27 +1000 | [diff] [blame] | 838 | /* |
| 839 | * Inode create log item structure |
| 840 | * |
| 841 | * Log recovery assumes the first two entries are the type and size and they fit |
| 842 | * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so |
| 843 | * decoding can be done correctly. |
| 844 | */ |
| 845 | struct xfs_icreate_log { |
Darrick J. Wong | c8ce540 | 2017-06-16 11:00:05 -0700 | [diff] [blame] | 846 | uint16_t icl_type; /* type of log format structure */ |
| 847 | uint16_t icl_size; /* size of log format structure */ |
Dave Chinner | 9cd047f3 | 2013-08-12 20:49:27 +1000 | [diff] [blame] | 848 | __be32 icl_ag; /* ag being allocated in */ |
| 849 | __be32 icl_agbno; /* start block of inode range */ |
| 850 | __be32 icl_count; /* number of inodes to initialise */ |
| 851 | __be32 icl_isize; /* size of inodes */ |
| 852 | __be32 icl_length; /* length of extent to initialise */ |
| 853 | __be32 icl_gen; /* inode generation number to use */ |
| 854 | }; |
| 855 | |
Dave Chinner | fc06c6d | 2013-08-12 20:49:22 +1000 | [diff] [blame] | 856 | #endif /* __XFS_LOG_FORMAT_H__ */ |