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