// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. * All Rights Reserved. */ #ifndef __XFS_LOG_FORMAT_H__ #define __XFS_LOG_FORMAT_H__ struct xfs_mount; struct xfs_trans_res; /* * On-disk Log Format definitions. * * This file contains all the on-disk format definitions used within the log. It * includes the physical log structure itself, as well as all the log item * format structures that are written into the log and intepreted by log * recovery. We start with the physical log format definitions, and then work * through all the log items definitions and everything they encode into the * log. */ xlog_tid_t; #define XLOG_MIN_ICLOGS … #define XLOG_MAX_ICLOGS … #define XLOG_HEADER_MAGIC_NUM … #define XLOG_VERSION_1 … #define XLOG_VERSION_2 … #define XLOG_VERSION_OKBITS … #define XLOG_MIN_RECORD_BSIZE … #define XLOG_BIG_RECORD_BSIZE … #define XLOG_MAX_RECORD_BSIZE … #define XLOG_HEADER_CYCLE_SIZE … #define XLOG_MIN_RECORD_BSHIFT … #define XLOG_BIG_RECORD_BSHIFT … #define XLOG_MAX_RECORD_BSHIFT … #define XLOG_HEADER_SIZE … /* Minimum number of transactions that must fit in the log (defined by mkfs) */ #define XFS_MIN_LOG_FACTOR … #define XLOG_REC_SHIFT(log) … #define XLOG_TOTAL_REC_SHIFT(log) … /* get lsn fields */ #define CYCLE_LSN(lsn) … #define BLOCK_LSN(lsn) … /* this is used in a spot where we might otherwise double-endian-flip */ #define CYCLE_LSN_DISK(lsn) … static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block) { … } static inline uint xlog_get_cycle(char *ptr) { … } /* Log Clients */ #define XFS_TRANSACTION … #define XFS_LOG … #define XLOG_UNMOUNT_TYPE … /* * Log item for unmount records. * * The unmount record used to have a string "Unmount filesystem--" in the * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE). * We just write the magic number now; see xfs_log_unmount_write. */ struct xfs_unmount_log_format { … }; /* Region types for iovec's i_type */ #define XLOG_REG_TYPE_BFORMAT … #define XLOG_REG_TYPE_BCHUNK … #define XLOG_REG_TYPE_EFI_FORMAT … #define XLOG_REG_TYPE_EFD_FORMAT … #define XLOG_REG_TYPE_IFORMAT … #define XLOG_REG_TYPE_ICORE … #define XLOG_REG_TYPE_IEXT … #define XLOG_REG_TYPE_IBROOT … #define XLOG_REG_TYPE_ILOCAL … #define XLOG_REG_TYPE_IATTR_EXT … #define XLOG_REG_TYPE_IATTR_BROOT … #define XLOG_REG_TYPE_IATTR_LOCAL … #define XLOG_REG_TYPE_QFORMAT … #define XLOG_REG_TYPE_DQUOT … #define XLOG_REG_TYPE_QUOTAOFF … #define XLOG_REG_TYPE_LRHEADER … #define XLOG_REG_TYPE_UNMOUNT … #define XLOG_REG_TYPE_COMMIT … #define XLOG_REG_TYPE_TRANSHDR … #define XLOG_REG_TYPE_ICREATE … #define XLOG_REG_TYPE_RUI_FORMAT … #define XLOG_REG_TYPE_RUD_FORMAT … #define XLOG_REG_TYPE_CUI_FORMAT … #define XLOG_REG_TYPE_CUD_FORMAT … #define XLOG_REG_TYPE_BUI_FORMAT … #define XLOG_REG_TYPE_BUD_FORMAT … #define XLOG_REG_TYPE_ATTRI_FORMAT … #define XLOG_REG_TYPE_ATTRD_FORMAT … #define XLOG_REG_TYPE_ATTR_NAME … #define XLOG_REG_TYPE_ATTR_VALUE … #define XLOG_REG_TYPE_XMI_FORMAT … #define XLOG_REG_TYPE_XMD_FORMAT … #define XLOG_REG_TYPE_ATTR_NEWNAME … #define XLOG_REG_TYPE_ATTR_NEWVALUE … #define XLOG_REG_TYPE_MAX … /* * Flags to log operation header * * The first write of a new transaction will be preceded with a start * record, XLOG_START_TRANS. Once a transaction is committed, a commit * record is written, XLOG_COMMIT_TRANS. If a single region can not fit into * the remainder of the current active in-core log, it is split up into * multiple regions. Each partial region will be marked with a * XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS. * */ #define XLOG_START_TRANS … #define XLOG_COMMIT_TRANS … #define XLOG_CONTINUE_TRANS … #define XLOG_WAS_CONT_TRANS … #define XLOG_END_TRANS … #define XLOG_UNMOUNT_TRANS … xlog_op_header_t; /* valid values for h_fmt */ #define XLOG_FMT_UNKNOWN … #define XLOG_FMT_LINUX_LE … #define XLOG_FMT_LINUX_BE … #define XLOG_FMT_IRIX_BE … /* our fmt */ #ifdef XFS_NATIVE_HOST #define XLOG_FMT … #else #define XLOG_FMT … #endif xlog_rec_header_t; xlog_rec_ext_header_t; /* * Quite misnamed, because this union lays out the actual on-disk log buffer. */ xlog_in_core_2_t; /* not an on-disk structure, but needed by log recovery in userspace */ xfs_log_iovec_t; /* * Transaction Header definitions. * * This is the structure written in the log at the head of every transaction. It * identifies the type and id of the transaction, and contains the number of * items logged by the transaction so we know how many to expect during * recovery. * * Do not change the below structure without redoing the code in * xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans(). */ xfs_trans_header_t; #define XFS_TRANS_HEADER_MAGIC … /* * The only type valid for th_type in CIL-enabled file system logs: */ #define XFS_TRANS_CHECKPOINT … /* * Log item types. */ #define XFS_LI_EFI … #define XFS_LI_EFD … #define XFS_LI_IUNLINK … #define XFS_LI_INODE … #define XFS_LI_BUF … #define XFS_LI_DQUOT … #define XFS_LI_QUOTAOFF … #define XFS_LI_ICREATE … #define XFS_LI_RUI … #define XFS_LI_RUD … #define XFS_LI_CUI … #define XFS_LI_CUD … #define XFS_LI_BUI … #define XFS_LI_BUD … #define XFS_LI_ATTRI … #define XFS_LI_ATTRD … #define XFS_LI_XMI … #define XFS_LI_XMD … #define XFS_LI_TYPE_DESC … /* * Inode Log Item Format definitions. * * This is the structure used to lay out an inode log item in the * log. The size of the inline data/extents/b-tree root to be logged * (if any) is indicated in the ilf_dsize field. Changes to this structure * must be added on to the end. */ struct xfs_inode_log_format { … }; /* * Old 32 bit systems will log in this format without the 64 bit * alignment padding. Recovery will detect this and convert it to the * correct format. */ struct xfs_inode_log_format_32 { … } __attribute__((packed)); /* * Flags for xfs_trans_log_inode flags field. */ #define XFS_ILOG_CORE … #define XFS_ILOG_DDATA … #define XFS_ILOG_DEXT … #define XFS_ILOG_DBROOT … #define XFS_ILOG_DEV … #define XFS_ILOG_UUID … #define XFS_ILOG_ADATA … #define XFS_ILOG_AEXT … #define XFS_ILOG_ABROOT … #define XFS_ILOG_DOWNER … #define XFS_ILOG_AOWNER … /* * The timestamps are dirty, but not necessarily anything else in the inode * core. Unlike the other fields above this one must never make it to disk * in the ilf_fields of the inode_log_format, but is purely store in-memory in * ili_fields in the inode_log_item. */ #define XFS_ILOG_TIMESTAMP … /* * The version field has been changed, but not necessarily anything else of * interest. This must never make it to disk - it is used purely to ensure that * the inode item ->precommit operation can update the fsync flag triggers * in the inode item correctly. */ #define XFS_ILOG_IVERSION … #define XFS_ILOG_NONCORE … #define XFS_ILOG_DFORK … #define XFS_ILOG_AFORK … #define XFS_ILOG_ALL … static inline int xfs_ilog_fbroot(int w) { … } static inline int xfs_ilog_fext(int w) { … } static inline int xfs_ilog_fdata(int w) { … } /* * Incore version of the on-disk inode core structures. We log this directly * into the journal in host CPU format (for better or worse) and as such * directly mirrors the xfs_dinode structure as it must contain all the same * information. */ xfs_log_timestamp_t; /* Legacy timestamp encoding format. */ struct xfs_log_legacy_timestamp { … }; /* * Define the format of the inode core that is logged. This structure must be * kept identical to struct xfs_dinode except for the endianness annotations. */ struct xfs_log_dinode { … }; #define xfs_log_dinode_size(mp) … /* * Buffer Log Format definitions * * These are the physical dirty bitmap definitions for the log format structure. */ #define XFS_BLF_CHUNK … #define XFS_BLF_SHIFT … #define BIT_TO_WORD_SHIFT … #define NBWORD … /* * This flag indicates that the buffer contains on disk inodes * and requires special recovery handling. */ #define XFS_BLF_INODE_BUF … /* * This flag indicates that the buffer should not be replayed * during recovery because its blocks are being freed. */ #define XFS_BLF_CANCEL … /* * This flag indicates that the buffer contains on disk * user or group dquots and may require special recovery handling. */ #define XFS_BLF_UDQUOT_BUF … #define XFS_BLF_PDQUOT_BUF … #define XFS_BLF_GDQUOT_BUF … /* * This is the structure used to lay out a buf log item in the log. The data * map describes which 128 byte chunks of the buffer have been logged. * * The placement of blf_map_size causes blf_data_map to start at an odd * multiple of sizeof(unsigned int) offset within the struct. Because the data * bitmap size will always be an even number, the end of the data_map (and * therefore the structure) will also be at an odd multiple of sizeof(unsigned * int). Some 64-bit compilers will insert padding at the end of the struct to * ensure 64-bit alignment of blf_blkno, but 32-bit ones will not. Therefore, * XFS_BLF_DATAMAP_SIZE must be an odd number to make the padding explicit and * keep the structure size consistent between 32-bit and 64-bit platforms. */ #define __XFS_BLF_DATAMAP_SIZE … #define XFS_BLF_DATAMAP_SIZE … xfs_buf_log_format_t; /* * All buffers now need to tell recovery where the magic number * is so that it can verify and calculate the CRCs on the buffer correctly * once the changes have been replayed into the buffer. * * The type value is held in the upper 5 bits of the blf_flags field, which is * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down. */ #define XFS_BLFT_BITS … #define XFS_BLFT_SHIFT … #define XFS_BLFT_MASK … enum xfs_blft { … }; static inline void xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type) { … } static inline uint16_t xfs_blft_from_flags(struct xfs_buf_log_format *blf) { … } /* * EFI/EFD log format definitions */ xfs_extent_t; /* * Since an xfs_extent_t has types (start:64, len: 32) * there are different alignments on 32 bit and 64 bit kernels. * So we provide the different variants for use by a * conversion routine. */ xfs_extent_32_t; xfs_extent_64_t; /* * This is the structure used to lay out an efi log item in the * log. The efi_extents field is a variable size array whose * size is given by efi_nextents. */ xfs_efi_log_format_t; static inline size_t xfs_efi_log_format_sizeof( unsigned int nr) { … } xfs_efi_log_format_32_t; static inline size_t xfs_efi_log_format32_sizeof( unsigned int nr) { … } xfs_efi_log_format_64_t; static inline size_t xfs_efi_log_format64_sizeof( unsigned int nr) { … } /* * This is the structure used to lay out an efd log item in the * log. The efd_extents array is a variable size array whose * size is given by efd_nextents; */ xfs_efd_log_format_t; static inline size_t xfs_efd_log_format_sizeof( unsigned int nr) { … } xfs_efd_log_format_32_t; static inline size_t xfs_efd_log_format32_sizeof( unsigned int nr) { … } xfs_efd_log_format_64_t; static inline size_t xfs_efd_log_format64_sizeof( unsigned int nr) { … } /* * RUI/RUD (reverse mapping) log format definitions */ struct xfs_map_extent { … }; /* rmap me_flags: upper bits are flags, lower byte is type code */ #define XFS_RMAP_EXTENT_MAP … #define XFS_RMAP_EXTENT_MAP_SHARED … #define XFS_RMAP_EXTENT_UNMAP … #define XFS_RMAP_EXTENT_UNMAP_SHARED … #define XFS_RMAP_EXTENT_CONVERT … #define XFS_RMAP_EXTENT_CONVERT_SHARED … #define XFS_RMAP_EXTENT_ALLOC … #define XFS_RMAP_EXTENT_FREE … #define XFS_RMAP_EXTENT_TYPE_MASK … #define XFS_RMAP_EXTENT_ATTR_FORK … #define XFS_RMAP_EXTENT_BMBT_BLOCK … #define XFS_RMAP_EXTENT_UNWRITTEN … #define XFS_RMAP_EXTENT_FLAGS … /* * This is the structure used to lay out an rui log item in the * log. The rui_extents field is a variable size array whose * size is given by rui_nextents. */ struct xfs_rui_log_format { … }; static inline size_t xfs_rui_log_format_sizeof( unsigned int nr) { … } /* * This is the structure used to lay out an rud log item in the * log. The rud_extents array is a variable size array whose * size is given by rud_nextents; */ struct xfs_rud_log_format { … }; /* * CUI/CUD (refcount update) log format definitions */ struct xfs_phys_extent { … }; /* refcount pe_flags: upper bits are flags, lower byte is type code */ /* Type codes are taken directly from enum xfs_refcount_intent_type. */ #define XFS_REFCOUNT_EXTENT_TYPE_MASK … #define XFS_REFCOUNT_EXTENT_FLAGS … /* * This is the structure used to lay out a cui log item in the * log. The cui_extents field is a variable size array whose * size is given by cui_nextents. */ struct xfs_cui_log_format { … }; static inline size_t xfs_cui_log_format_sizeof( unsigned int nr) { … } /* * This is the structure used to lay out a cud log item in the * log. The cud_extents array is a variable size array whose * size is given by cud_nextents; */ struct xfs_cud_log_format { … }; /* * BUI/BUD (inode block mapping) log format definitions */ /* bmbt me_flags: upper bits are flags, lower byte is type code */ /* Type codes are taken directly from enum xfs_bmap_intent_type. */ #define XFS_BMAP_EXTENT_TYPE_MASK … #define XFS_BMAP_EXTENT_ATTR_FORK … #define XFS_BMAP_EXTENT_UNWRITTEN … #define XFS_BMAP_EXTENT_REALTIME … #define XFS_BMAP_EXTENT_FLAGS … /* * This is the structure used to lay out an bui log item in the * log. The bui_extents field is a variable size array whose * size is given by bui_nextents. */ struct xfs_bui_log_format { … }; static inline size_t xfs_bui_log_format_sizeof( unsigned int nr) { … } /* * This is the structure used to lay out an bud log item in the * log. The bud_extents array is a variable size array whose * size is given by bud_nextents; */ struct xfs_bud_log_format { … }; /* * XMI/XMD (file mapping exchange) log format definitions */ /* This is the structure used to lay out an mapping exchange log item. */ struct xfs_xmi_log_format { … }; /* Exchange mappings between extended attribute forks instead of data forks. */ #define XFS_EXCHMAPS_ATTR_FORK … /* Set the file sizes when finished. */ #define XFS_EXCHMAPS_SET_SIZES … /* * Exchange the mappings of the two files only if the file allocation units * mapped to file1's range have been written. */ #define XFS_EXCHMAPS_INO1_WRITTEN … /* Clear the reflink flag from inode1 after the operation. */ #define XFS_EXCHMAPS_CLEAR_INO1_REFLINK … /* Clear the reflink flag from inode2 after the operation. */ #define XFS_EXCHMAPS_CLEAR_INO2_REFLINK … #define XFS_EXCHMAPS_LOGGED_FLAGS … /* This is the structure used to lay out an mapping exchange done log item. */ struct xfs_xmd_log_format { … }; /* * Dquot Log format definitions. * * The first two fields must be the type and size fitting into * 32 bits : log_recovery code assumes that. */ xfs_dq_logformat_t; /* * log format struct for QUOTAOFF records. * The first two fields must be the type and size fitting into * 32 bits : log_recovery code assumes that. * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer * to the first and ensures that the first logitem is taken out of the AIL * only when the last one is securely committed. */ xfs_qoff_logformat_t; /* * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. */ #define XFS_UQUOTA_ACCT … #define XFS_UQUOTA_ENFD … #define XFS_UQUOTA_CHKD … #define XFS_PQUOTA_ACCT … #define XFS_OQUOTA_ENFD … #define XFS_OQUOTA_CHKD … #define XFS_GQUOTA_ACCT … /* * Conversion to and from the combined OQUOTA flag (if necessary) * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk() */ #define XFS_GQUOTA_ENFD … #define XFS_GQUOTA_CHKD … #define XFS_PQUOTA_ENFD … #define XFS_PQUOTA_CHKD … #define XFS_ALL_QUOTA_ACCT … #define XFS_ALL_QUOTA_ENFD … #define XFS_ALL_QUOTA_CHKD … #define XFS_MOUNT_QUOTA_ALL … /* * Inode create log item structure * * Log recovery assumes the first two entries are the type and size and they fit * in 32 bits. Also in host order (ugh) so they have to be 32 bit aligned so * decoding can be done correctly. */ struct xfs_icreate_log { … }; /* * Flags for deferred attribute operations. * Upper bits are flags, lower byte is type code */ #define XFS_ATTRI_OP_FLAGS_SET … #define XFS_ATTRI_OP_FLAGS_REMOVE … #define XFS_ATTRI_OP_FLAGS_REPLACE … #define XFS_ATTRI_OP_FLAGS_PPTR_SET … #define XFS_ATTRI_OP_FLAGS_PPTR_REMOVE … #define XFS_ATTRI_OP_FLAGS_PPTR_REPLACE … #define XFS_ATTRI_OP_FLAGS_TYPE_MASK … /* * alfi_attr_filter captures the state of xfs_da_args.attr_filter, so it should * never have any other bits set. */ #define XFS_ATTRI_FILTER_MASK … /* * This is the structure used to lay out an attr log item in the * log. */ struct xfs_attri_log_format { … }; struct xfs_attrd_log_format { … }; #endif /* __XFS_LOG_FORMAT_H__ */