/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2000-2005 Silicon Graphics, Inc. * All Rights Reserved. */ #ifndef __XFS_FORMAT_H__ #define __XFS_FORMAT_H__ /* * XFS On Disk Format Definitions * * This header file defines all the on-disk format definitions for * general XFS objects. Directory and attribute related objects are defined in * xfs_da_format.h, which log and log item formats are defined in * xfs_log_format.h. Everything else goes here. */ struct xfs_mount; struct xfs_trans; struct xfs_inode; struct xfs_buf; struct xfs_ifork; /* * Super block * Fits into a sector-sized buffer at address 0 of each allocation group. * Only the first of these is ever updated except during growfs. */ #define XFS_SB_MAGIC … #define XFS_SB_VERSION_1 … #define XFS_SB_VERSION_2 … #define XFS_SB_VERSION_3 … #define XFS_SB_VERSION_4 … #define XFS_SB_VERSION_5 … #define XFS_SB_VERSION_NUMBITS … #define XFS_SB_VERSION_ALLFBITS … #define XFS_SB_VERSION_ATTRBIT … #define XFS_SB_VERSION_NLINKBIT … #define XFS_SB_VERSION_QUOTABIT … #define XFS_SB_VERSION_ALIGNBIT … #define XFS_SB_VERSION_DALIGNBIT … #define XFS_SB_VERSION_SHAREDBIT … #define XFS_SB_VERSION_LOGV2BIT … #define XFS_SB_VERSION_SECTORBIT … #define XFS_SB_VERSION_EXTFLGBIT … #define XFS_SB_VERSION_DIRV2BIT … #define XFS_SB_VERSION_BORGBIT … #define XFS_SB_VERSION_MOREBITSBIT … /* * The size of a single extended attribute on disk is limited by * the size of index values within the attribute entries themselves. * These are be16 fields, so we can only support attribute data * sizes up to 2^16 bytes in length. */ #define XFS_XATTR_SIZE_MAX … /* * Supported feature bit list is just all bits in the versionnum field because * we've used them all up and understand them all. Except, of course, for the * shared superblock bit, which nobody knows what it does and so is unsupported. */ #define XFS_SB_VERSION_OKBITS … /* * There are two words to hold XFS "feature" bits: the original * word, sb_versionnum, and sb_features2. Whenever a bit is set in * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. * * These defines represent bits in sb_features2. */ #define XFS_SB_VERSION2_RESERVED1BIT … #define XFS_SB_VERSION2_LAZYSBCOUNTBIT … #define XFS_SB_VERSION2_RESERVED4BIT … #define XFS_SB_VERSION2_ATTR2BIT … #define XFS_SB_VERSION2_PARENTBIT … #define XFS_SB_VERSION2_PROJID32BIT … #define XFS_SB_VERSION2_CRCBIT … #define XFS_SB_VERSION2_FTYPE … #define XFS_SB_VERSION2_OKBITS … /* Maximum size of the xfs filesystem label, no terminating NULL */ #define XFSLABEL_MAX … /* * Superblock - in core version. Must be padded to 64 bit alignment. */ xfs_sb_t; /* * Superblock - on disk version. * Must be padded to 64 bit alignment. */ struct xfs_dsb { … }; #define XFS_SB_CRC_OFF … /* * Misc. Flags - warning - these will be cleared by xfs_repair unless * a feature bit is set when the flag is used. */ #define XFS_SBF_NOFLAGS … #define XFS_SBF_READONLY … /* * define max. shared version we can interoperate with */ #define XFS_SB_MAX_SHARED_VN … #define XFS_SB_VERSION_NUM(sbp) … static inline bool xfs_sb_is_v5(struct xfs_sb *sbp) { … } /* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. */ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) { … } static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) { … } static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) { … } static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) { … } static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) { … } static inline void xfs_sb_version_addprojid32(struct xfs_sb *sbp) { … } /* * Extended v5 superblock feature masks. These are to be used for new v5 * superblock features only. * * Compat features are new features that old kernels will not notice or affect * and so can mount read-write without issues. * * RO-Compat (read only) are features that old kernels can read but will break * if they write. Hence only read-only mounts of such filesystems are allowed on * kernels that don't support the feature bit. * * InCompat features are features which old kernels will not understand and so * must not mount. * * Log-InCompat features are for changes to log formats or new transactions that * can't be replayed on older kernels. The fields are set when the filesystem is * mounted, and a clean unmount clears the fields. */ #define XFS_SB_FEAT_COMPAT_ALL … #define XFS_SB_FEAT_COMPAT_UNKNOWN … static inline bool xfs_sb_has_compat_feature( struct xfs_sb *sbp, uint32_t feature) { … } #define XFS_SB_FEAT_RO_COMPAT_FINOBT … #define XFS_SB_FEAT_RO_COMPAT_RMAPBT … #define XFS_SB_FEAT_RO_COMPAT_REFLINK … #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT … #define XFS_SB_FEAT_RO_COMPAT_ALL … #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN … static inline bool xfs_sb_has_ro_compat_feature( struct xfs_sb *sbp, uint32_t feature) { … } #define XFS_SB_FEAT_INCOMPAT_FTYPE … #define XFS_SB_FEAT_INCOMPAT_SPINODES … #define XFS_SB_FEAT_INCOMPAT_META_UUID … #define XFS_SB_FEAT_INCOMPAT_BIGTIME … #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR … #define XFS_SB_FEAT_INCOMPAT_NREXT64 … #define XFS_SB_FEAT_INCOMPAT_EXCHRANGE … #define XFS_SB_FEAT_INCOMPAT_PARENT … #define XFS_SB_FEAT_INCOMPAT_ALL … #define XFS_SB_FEAT_INCOMPAT_UNKNOWN … static inline bool xfs_sb_has_incompat_feature( struct xfs_sb *sbp, uint32_t feature) { … } #define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS … #define XFS_SB_FEAT_INCOMPAT_LOG_ALL … #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN … static inline bool xfs_sb_has_incompat_log_feature( struct xfs_sb *sbp, uint32_t feature) { … } static inline void xfs_sb_remove_incompat_log_features( struct xfs_sb *sbp) { … } static inline void xfs_sb_add_incompat_log_features( struct xfs_sb *sbp, unsigned int features) { … } static inline bool xfs_sb_version_haslogxattrs(struct xfs_sb *sbp) { … } static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) { … } #define XFS_SB_DADDR … #define XFS_SB_BLOCK(mp) … #define XFS_HDR_BLOCK(mp,d) … #define XFS_DADDR_TO_FSB(mp,d) … #define XFS_FSB_TO_DADDR(mp,fsbno) … /* * File system sector to basic block conversions. */ #define XFS_FSS_TO_BB(mp,sec) … /* * File system block to basic block conversions. */ #define XFS_FSB_TO_BB(mp,fsbno) … #define XFS_BB_TO_FSB(mp,bb) … #define XFS_BB_TO_FSBT(mp,bb) … /* * File system block to byte conversions. */ #define XFS_FSB_TO_B(mp,fsbno) … #define XFS_B_TO_FSB(mp,b) … #define XFS_B_TO_FSBT(mp,b) … /* * Allocation group header * * This is divided into three structures, placed in sequential 512-byte * buffers after a copy of the superblock (also in a 512-byte buffer). */ #define XFS_AGF_MAGIC … #define XFS_AGI_MAGIC … #define XFS_AGFL_MAGIC … #define XFS_AGF_VERSION … #define XFS_AGI_VERSION … #define XFS_AGF_GOOD_VERSION(v) … #define XFS_AGI_GOOD_VERSION(v) … /* * agf_cnt_level in the first AGF overlaps the EFS superblock's magic number. * Since the magic numbers valid for EFS are > 64k, our value cannot be confused * for an EFS superblock. */ xfs_agf_t; #define XFS_AGF_CRC_OFF … #define XFS_AGF_MAGICNUM … #define XFS_AGF_VERSIONNUM … #define XFS_AGF_SEQNO … #define XFS_AGF_LENGTH … #define XFS_AGF_ROOTS … #define XFS_AGF_LEVELS … #define XFS_AGF_FLFIRST … #define XFS_AGF_FLLAST … #define XFS_AGF_FLCOUNT … #define XFS_AGF_FREEBLKS … #define XFS_AGF_LONGEST … #define XFS_AGF_BTREEBLKS … #define XFS_AGF_UUID … #define XFS_AGF_RMAP_BLOCKS … #define XFS_AGF_REFCOUNT_BLOCKS … #define XFS_AGF_REFCOUNT_ROOT … #define XFS_AGF_REFCOUNT_LEVEL … #define XFS_AGF_SPARE64 … #define XFS_AGF_NUM_BITS … #define XFS_AGF_ALL_BITS … #define XFS_AGF_FLAGS … /* disk block (xfs_daddr_t) in the AG */ #define XFS_AGF_DADDR(mp) … #define XFS_AGF_BLOCK(mp) … /* * Size of the unlinked inode hash table in the agi. */ #define XFS_AGI_UNLINKED_BUCKETS … xfs_agi_t; #define XFS_AGI_CRC_OFF … #define XFS_AGI_MAGICNUM … #define XFS_AGI_VERSIONNUM … #define XFS_AGI_SEQNO … #define XFS_AGI_LENGTH … #define XFS_AGI_COUNT … #define XFS_AGI_ROOT … #define XFS_AGI_LEVEL … #define XFS_AGI_FREECOUNT … #define XFS_AGI_NEWINO … #define XFS_AGI_DIRINO … #define XFS_AGI_UNLINKED … #define XFS_AGI_NUM_BITS_R1 … #define XFS_AGI_ALL_BITS_R1 … #define XFS_AGI_FREE_ROOT … #define XFS_AGI_FREE_LEVEL … #define XFS_AGI_IBLOCKS … #define XFS_AGI_NUM_BITS_R2 … /* disk block (xfs_daddr_t) in the AG */ #define XFS_AGI_DADDR(mp) … #define XFS_AGI_BLOCK(mp) … /* * The third a.g. block contains the a.g. freelist, an array * of block pointers to blocks owned by the allocation btree code. */ #define XFS_AGFL_DADDR(mp) … #define XFS_AGFL_BLOCK(mp) … #define XFS_BUF_TO_AGFL(bp) … struct xfs_agfl { … } __attribute__((packed)); #define XFS_AGFL_CRC_OFF … #define XFS_AGB_TO_FSB(mp,agno,agbno) … #define XFS_FSB_TO_AGNO(mp,fsbno) … #define XFS_FSB_TO_AGBNO(mp,fsbno) … #define XFS_AGB_TO_DADDR(mp,agno,agbno) … #define XFS_AG_DADDR(mp,agno,d) … /* * For checking for bad ranges of xfs_daddr_t's, covering multiple * allocation groups or a single xfs_daddr_t that's a superblock copy. */ #define XFS_AG_CHECK_DADDR(mp,d,len) … /* * Realtime bitmap information is accessed by the word, which is currently * stored in host-endian format. */ xfs_rtword_raw; /* * Realtime summary counts are accessed by the word, which is currently * stored in host-endian format. */ xfs_suminfo_raw; /* * XFS Timestamps * ============== * * Traditional ondisk inode timestamps consist of signed 32-bit counters for * seconds and nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC * 1970, which means that the timestamp epoch is the same as the Unix epoch. * Therefore, the ondisk min and max defined here can be used directly to * constrain the incore timestamps on a Unix system. Note that we actually * encode a __be64 value on disk. * * When the bigtime feature is enabled, ondisk inode timestamps become an * unsigned 64-bit nanoseconds counter. This means that the bigtime inode * timestamp epoch is the start of the classic timestamp range, which is * Dec 13 20:45:52 UTC 1901. Because the epochs are not the same, callers * /must/ use the bigtime conversion functions when encoding and decoding raw * timestamps. */ xfs_timestamp_t; /* Legacy timestamp encoding format. */ struct xfs_legacy_timestamp { … }; /* * Smallest possible ondisk seconds value with traditional timestamps. This * corresponds exactly with the incore timestamp Dec 13 20:45:52 UTC 1901. */ #define XFS_LEGACY_TIME_MIN … /* * Largest possible ondisk seconds value with traditional timestamps. This * corresponds exactly with the incore timestamp Jan 19 03:14:07 UTC 2038. */ #define XFS_LEGACY_TIME_MAX … /* * Smallest possible ondisk seconds value with bigtime timestamps. This * corresponds (after conversion to a Unix timestamp) with the traditional * minimum timestamp of Dec 13 20:45:52 UTC 1901. */ #define XFS_BIGTIME_TIME_MIN … /* * Largest supported ondisk seconds value with bigtime timestamps. This * corresponds (after conversion to a Unix timestamp) with an incore timestamp * of Jul 2 20:20:24 UTC 2486. * * We round down the ondisk limit so that the bigtime quota and inode max * timestamps will be the same. */ #define XFS_BIGTIME_TIME_MAX … /* * Bigtime epoch is set exactly to the minimum time value that a traditional * 32-bit timestamp can represent when using the Unix epoch as a reference. * Hence the Unix epoch is at a fixed offset into the supported bigtime * timestamp range. * * The bigtime epoch also matches the minimum value an on-disk 32-bit XFS * timestamp can represent so we will not lose any fidelity in converting * to/from unix and bigtime timestamps. * * The following conversion factor converts a seconds counter from the Unix * epoch to the bigtime epoch. */ #define XFS_BIGTIME_EPOCH_OFFSET … /* Convert a timestamp from the Unix epoch to the bigtime epoch. */ static inline uint64_t xfs_unix_to_bigtime(time64_t unix_seconds) { … } /* Convert a timestamp from the bigtime epoch to the Unix epoch. */ static inline time64_t xfs_bigtime_to_unix(uint64_t ondisk_seconds) { … } /* * On-disk inode structure. * * This is just the header or "dinode core", the inode is expanded to fill a * variable size the leftover area split into a data and an attribute fork. * The format of the data and attribute fork depends on the format of the * inode as indicated by di_format and di_aformat. To access the data and * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros * below. * * There is a very similar struct xfs_log_dinode which matches the layout of * this structure, but is kept in native format instead of big endian. * * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed * padding field for v3 inodes. */ #define XFS_DINODE_MAGIC … struct xfs_dinode { … }; #define XFS_DINODE_CRC_OFF … #define DI_MAX_FLUSH … /* * Size of the core inode on disk. Version 1 and 2 inodes have * the same size, but version 3 has grown a few additional fields. */ static inline uint xfs_dinode_size(int version) { … } /* * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. * Since the pathconf interface is signed, we use 2^31 - 1 instead. */ #define XFS_MAXLINK … /* * Any file that hits the maximum ondisk link count should be pinned to avoid * a use-after-free situation. */ #define XFS_NLINK_PINNED … /* * Values for di_format * * This enum is used in string mapping in xfs_trace.h; please keep the * TRACE_DEFINE_ENUMs for it up to date. */ enum xfs_dinode_fmt { … }; #define XFS_INODE_FORMAT_STR … /* * Max values for extnum and aextnum. * * The original on-disk extent counts were held in signed fields, resulting in * maximum extent counts of 2^31 and 2^15 for the data and attr forks * respectively. Similarly the maximum extent length is limited to 2^21 blocks * by the 21-bit wide blockcount field of a BMBT extent record. * * The newly introduced data fork extent counter can hold a 64-bit value, * however the maximum number of extents in a file is also limited to 2^54 * extents by the 54-bit wide startoff field of a BMBT extent record. * * It is further limited by the maximum supported file size of 2^63 * *bytes*. This leads to a maximum extent count for maximally sized filesystem * blocks (64kB) of: * * 2^63 bytes / 2^16 bytes per block = 2^47 blocks * * Rounding up 47 to the nearest multiple of bits-per-byte results in 48. Hence * 2^48 was chosen as the maximum data fork extent count. * * The maximum file size that can be represented by the data fork extent counter * in the worst case occurs when all extents are 1 block in length and each * block is 1KB in size. * * With XFS_MAX_EXTCNT_DATA_FORK_SMALL representing maximum extent count and * with 1KB sized blocks, a file can reach upto, * 1KB * (2^31) = 2TB * * This is much larger than the theoretical maximum size of a directory * i.e. XFS_DIR2_SPACE_SIZE * XFS_DIR2_MAX_SPACES = ~96GB. * * Hence, a directory inode can never overflow its data fork extent counter. */ #define XFS_MAX_EXTCNT_DATA_FORK_LARGE … #define XFS_MAX_EXTCNT_ATTR_FORK_LARGE … #define XFS_MAX_EXTCNT_DATA_FORK_SMALL … #define XFS_MAX_EXTCNT_ATTR_FORK_SMALL … /* * When we upgrade an inode to the large extent counts, the maximum value by * which the extent count can increase is bound by the change in size of the * on-disk field. No upgrade operation should ever be adding more than a few * tens of extents, so if we get a really large value it is a sign of a code bug * or corruption. */ #define XFS_MAX_EXTCNT_UPGRADE_NR … /* * Inode minimum and maximum sizes. */ #define XFS_DINODE_MIN_LOG … #define XFS_DINODE_MAX_LOG … #define XFS_DINODE_MIN_SIZE … #define XFS_DINODE_MAX_SIZE … /* * Inode size for given fs. */ #define XFS_DINODE_SIZE(mp) … #define XFS_LITINO(mp) … /* * Inode data & attribute fork sizes, per inode. */ #define XFS_DFORK_BOFF(dip) … #define XFS_DFORK_DSIZE(dip,mp) … #define XFS_DFORK_ASIZE(dip,mp) … #define XFS_DFORK_SIZE(dip,mp,w) … #define XFS_DFORK_MAXEXT(dip, mp, w) … /* * Return pointers to the data or attribute forks. */ #define XFS_DFORK_DPTR(dip) … #define XFS_DFORK_APTR(dip) … #define XFS_DFORK_PTR(dip,w) … #define XFS_DFORK_FORMAT(dip,w) … /* * For block and character special files the 32bit dev_t is stored at the * beginning of the data fork. */ static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) { … } static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) { … } /* * Values for di_flags */ #define XFS_DIFLAG_REALTIME_BIT … #define XFS_DIFLAG_PREALLOC_BIT … #define XFS_DIFLAG_NEWRTBM_BIT … #define XFS_DIFLAG_IMMUTABLE_BIT … #define XFS_DIFLAG_APPEND_BIT … #define XFS_DIFLAG_SYNC_BIT … #define XFS_DIFLAG_NOATIME_BIT … #define XFS_DIFLAG_NODUMP_BIT … #define XFS_DIFLAG_RTINHERIT_BIT … #define XFS_DIFLAG_PROJINHERIT_BIT … #define XFS_DIFLAG_NOSYMLINKS_BIT … #define XFS_DIFLAG_EXTSIZE_BIT … #define XFS_DIFLAG_EXTSZINHERIT_BIT … #define XFS_DIFLAG_NODEFRAG_BIT … #define XFS_DIFLAG_FILESTREAM_BIT … /* Do not use bit 15, di_flags is legacy and unchanging now */ #define XFS_DIFLAG_REALTIME … #define XFS_DIFLAG_PREALLOC … #define XFS_DIFLAG_NEWRTBM … #define XFS_DIFLAG_IMMUTABLE … #define XFS_DIFLAG_APPEND … #define XFS_DIFLAG_SYNC … #define XFS_DIFLAG_NOATIME … #define XFS_DIFLAG_NODUMP … #define XFS_DIFLAG_RTINHERIT … #define XFS_DIFLAG_PROJINHERIT … #define XFS_DIFLAG_NOSYMLINKS … #define XFS_DIFLAG_EXTSIZE … #define XFS_DIFLAG_EXTSZINHERIT … #define XFS_DIFLAG_NODEFRAG … #define XFS_DIFLAG_FILESTREAM … #define XFS_DIFLAG_ANY … /* * Values for di_flags2 These start by being exposed to userspace in the upper * 16 bits of the XFS_XFLAG_s range. */ #define XFS_DIFLAG2_DAX_BIT … #define XFS_DIFLAG2_REFLINK_BIT … #define XFS_DIFLAG2_COWEXTSIZE_BIT … #define XFS_DIFLAG2_BIGTIME_BIT … #define XFS_DIFLAG2_NREXT64_BIT … #define XFS_DIFLAG2_DAX … #define XFS_DIFLAG2_REFLINK … #define XFS_DIFLAG2_COWEXTSIZE … #define XFS_DIFLAG2_BIGTIME … #define XFS_DIFLAG2_NREXT64 … #define XFS_DIFLAG2_ANY … static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { … } static inline bool xfs_dinode_has_large_extent_counts( const struct xfs_dinode *dip) { … } /* * Inode number format: * low inopblog bits - offset in block * next agblklog bits - block number in ag * next agno_log bits - ag number * high agno_log-agblklog-inopblog bits - 0 */ #define XFS_INO_MASK(k) … #define XFS_INO_OFFSET_BITS(mp) … #define XFS_INO_AGBNO_BITS(mp) … #define XFS_INO_AGINO_BITS(mp) … #define XFS_INO_AGNO_BITS(mp) … #define XFS_INO_BITS(mp) … #define XFS_INO_TO_AGNO(mp,i) … #define XFS_INO_TO_AGINO(mp,i) … #define XFS_INO_TO_AGBNO(mp,i) … #define XFS_INO_TO_OFFSET(mp,i) … #define XFS_INO_TO_FSB(mp,i) … #define XFS_AGINO_TO_INO(mp,a,i) … #define XFS_AGINO_TO_AGBNO(mp,i) … #define XFS_AGINO_TO_OFFSET(mp,i) … #define XFS_OFFBNO_TO_AGINO(mp,b,o) … #define XFS_FSB_TO_INO(mp, b) … #define XFS_AGB_TO_AGINO(mp, b) … #define XFS_MAXINUMBER … #define XFS_MAXINUMBER_32 … /* * RealTime Device format definitions */ /* Min and max rt extent sizes, specified in bytes */ #define XFS_MAX_RTEXTSIZE … #define XFS_DFL_RTEXTSIZE … #define XFS_MIN_RTEXTSIZE … /* * Dquot and dquot block format definitions */ #define XFS_DQUOT_MAGIC … #define XFS_DQUOT_VERSION … #define XFS_DQTYPE_USER … #define XFS_DQTYPE_PROJ … #define XFS_DQTYPE_GROUP … #define XFS_DQTYPE_BIGTIME … /* bitmask to determine if this is a user/group/project dquot */ #define XFS_DQTYPE_REC_MASK … #define XFS_DQTYPE_ANY … /* * XFS Quota Timers * ================ * * Traditional quota grace period expiration timers are an unsigned 32-bit * seconds counter; time zero is the Unix epoch, Jan 1 00:00:01 UTC 1970. * Note that an expiration value of zero means that the quota limit has not * been reached, and therefore no expiration has been set. Therefore, the * ondisk min and max defined here can be used directly to constrain the incore * quota expiration timestamps on a Unix system. * * When bigtime is enabled, we trade two bits of precision to expand the * expiration timeout range to match that of big inode timestamps. The min and * max recorded here are the on-disk limits, not a Unix timestamp. * * The grace period for each quota type is stored in the root dquot (id = 0) * and is applied to a non-root dquot when it exceeds the soft or hard limits. * The length of quota grace periods are unsigned 32-bit quantities measured in * units of seconds. A value of zero means to use the default period. */ /* * Smallest possible ondisk quota expiration value with traditional timestamps. * This corresponds exactly with the incore expiration Jan 1 00:00:01 UTC 1970. */ #define XFS_DQ_LEGACY_EXPIRY_MIN … /* * Largest possible ondisk quota expiration value with traditional timestamps. * This corresponds exactly with the incore expiration Feb 7 06:28:15 UTC 2106. */ #define XFS_DQ_LEGACY_EXPIRY_MAX … /* * Smallest possible ondisk quota expiration value with bigtime timestamps. * This corresponds (after conversion to a Unix timestamp) with the incore * expiration of Jan 1 00:00:04 UTC 1970. */ #define XFS_DQ_BIGTIME_EXPIRY_MIN … /* * Largest supported ondisk quota expiration value with bigtime timestamps. * This corresponds (after conversion to a Unix timestamp) with an incore * expiration of Jul 2 20:20:24 UTC 2486. * * The ondisk field supports values up to -1U, which corresponds to an incore * expiration in 2514. This is beyond the maximum the bigtime inode timestamp, * so we cap the maximum bigtime quota expiration to the max inode timestamp. */ #define XFS_DQ_BIGTIME_EXPIRY_MAX … /* * The following conversion factors assist in converting a quota expiration * timestamp between the incore and ondisk formats. */ #define XFS_DQ_BIGTIME_SHIFT … #define XFS_DQ_BIGTIME_SLACK … /* Convert an incore quota expiration timestamp to an ondisk bigtime value. */ static inline uint32_t xfs_dq_unix_to_bigtime(time64_t unix_seconds) { … } /* Convert an ondisk bigtime quota expiration value to an incore timestamp. */ static inline time64_t xfs_dq_bigtime_to_unix(uint32_t ondisk_seconds) { … } /* * Default quota grace periods, ranging from zero (use the compiled defaults) * to ~136 years. These are applied to a non-root dquot that has exceeded * either limit. */ #define XFS_DQ_GRACE_MIN … #define XFS_DQ_GRACE_MAX … /* Maximum id value for a quota record */ #define XFS_DQ_ID_MAX … /* * This is the main portion of the on-disk representation of quota information * for a user. We pad this with some more expansion room to construct the on * disk structure. */ struct xfs_disk_dquot { … }; /* * This is what goes on disk. This is separated from the xfs_disk_dquot because * carrying the unnecessary padding would be a waste of memory. */ struct xfs_dqblk { … }; #define XFS_DQUOT_CRC_OFF … /* * This defines the unit of allocation of dquots. * * Currently, it is just one file system block, and a 4K blk contains 30 * (136 * 30 = 4080) dquots. It's probably not worth trying to make * this more dynamic. * * However, if this number is changed, we have to make sure that we don't * implicitly assume that we do allocations in chunks of a single filesystem * block in the dquot/xqm code. * * This is part of the ondisk format because the structure size is not a power * of two, which leaves slack at the end of the disk block. */ #define XFS_DQUOT_CLUSTER_SIZE_FSB … /* * Remote symlink format and access functions. */ #define XFS_SYMLINK_MAGIC … struct xfs_dsymlink_hdr { … }; #define XFS_SYMLINK_CRC_OFF … #define XFS_SYMLINK_MAXLEN … /* * The maximum pathlen is 1024 bytes. Since the minimum file system * blocksize is 512 bytes, we can get a max of 3 extents back from * bmapi when crc headers are taken into account. */ #define XFS_SYMLINK_MAPS … #define XFS_SYMLINK_BUF_SPACE(mp, bufsize) … /* * Allocation Btree format definitions * * There are two on-disk btrees, one sorted by blockno and one sorted * by blockcount and blockno. All blocks look the same to make the code * simpler; if we have time later, we'll make the optimizations. */ #define XFS_ABTB_MAGIC … #define XFS_ABTB_CRC_MAGIC … #define XFS_ABTC_MAGIC … #define XFS_ABTC_CRC_MAGIC … /* * Data record/key structure */ xfs_alloc_key_t; xfs_alloc_rec_incore_t; /* btree pointer type */ xfs_alloc_ptr_t; /* * Block numbers in the AG: * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. */ #define XFS_BNO_BLOCK(mp) … #define XFS_CNT_BLOCK(mp) … /* * Inode Allocation Btree format definitions * * There is a btree for the inode map per allocation group. */ #define XFS_IBT_MAGIC … #define XFS_IBT_CRC_MAGIC … #define XFS_FIBT_MAGIC … #define XFS_FIBT_CRC_MAGIC … xfs_inofree_t; #define XFS_INODES_PER_CHUNK … #define XFS_INODES_PER_CHUNK_LOG … #define XFS_INOBT_ALL_FREE … #define XFS_INOBT_MASK(i) … #define XFS_INOBT_HOLEMASK_FULL … #define XFS_INOBT_HOLEMASK_BITS … #define XFS_INODES_PER_HOLEMASK_BIT … static inline xfs_inofree_t xfs_inobt_maskn(int i, int n) { … } /* * The on-disk inode record structure has two formats. The original "full" * format uses a 4-byte freecount. The "sparse" format uses a 1-byte freecount * and replaces the 3 high-order freecount bytes wth the holemask and inode * count. * * The holemask of the sparse record format allows an inode chunk to have holes * that refer to blocks not owned by the inode record. This facilitates inode * allocation in the event of severe free space fragmentation. */ xfs_inobt_rec_t; xfs_inobt_rec_incore_t; static inline bool xfs_inobt_issparse(uint16_t holemask) { … } /* * Key structure */ xfs_inobt_key_t; /* btree pointer type */ xfs_inobt_ptr_t; /* * block numbers in the AG. */ #define XFS_IBT_BLOCK(mp) … #define XFS_FIBT_BLOCK(mp) … /* * Reverse mapping btree format definitions * * There is a btree for the reverse map per allocation group */ #define XFS_RMAP_CRC_MAGIC … /* * Ownership info for an extent. This is used to create reverse-mapping * entries. */ #define XFS_OWNER_INFO_ATTR_FORK … #define XFS_OWNER_INFO_BMBT_BLOCK … struct xfs_owner_info { … }; /* * Special owner types. * * Seeing as we only support up to 8EB, we have the upper bit of the owner field * to tell us we have a special owner value. We use these for static metadata * allocated at mkfs/growfs time, as well as for freespace management metadata. */ #define XFS_RMAP_OWN_NULL … #define XFS_RMAP_OWN_UNKNOWN … #define XFS_RMAP_OWN_FS … #define XFS_RMAP_OWN_LOG … #define XFS_RMAP_OWN_AG … #define XFS_RMAP_OWN_INOBT … #define XFS_RMAP_OWN_INODES … #define XFS_RMAP_OWN_REFC … #define XFS_RMAP_OWN_COW … #define XFS_RMAP_OWN_MIN … #define XFS_RMAP_NON_INODE_OWNER(owner) … /* * Data record structure */ struct xfs_rmap_rec { … }; /* * rmap btree record * rm_offset:63 is the attribute fork flag * rm_offset:62 is the bmbt block flag * rm_offset:61 is the unwritten extent flag (same as l0:63 in bmbt) * rm_offset:54-60 aren't used and should be zero * rm_offset:0-53 is the block offset within the inode */ #define XFS_RMAP_OFF_ATTR_FORK … #define XFS_RMAP_OFF_BMBT_BLOCK … #define XFS_RMAP_OFF_UNWRITTEN … #define XFS_RMAP_LEN_MAX … #define XFS_RMAP_OFF_FLAGS … #define XFS_RMAP_OFF_MASK … #define XFS_RMAP_OFF(off) … #define XFS_RMAP_IS_BMBT_BLOCK(off) … #define XFS_RMAP_IS_ATTR_FORK(off) … #define XFS_RMAP_IS_UNWRITTEN(len) … #define RMAPBT_STARTBLOCK_BITLEN … #define RMAPBT_BLOCKCOUNT_BITLEN … #define RMAPBT_OWNER_BITLEN … #define RMAPBT_ATTRFLAG_BITLEN … #define RMAPBT_BMBTFLAG_BITLEN … #define RMAPBT_EXNTFLAG_BITLEN … #define RMAPBT_UNUSED_OFFSET_BITLEN … #define RMAPBT_OFFSET_BITLEN … /* * Key structure * * We don't use the length for lookups */ struct xfs_rmap_key { … } __attribute__((packed)); /* btree pointer type */ xfs_rmap_ptr_t; #define XFS_RMAP_BLOCK(mp) … /* * Reference Count Btree format definitions * */ #define XFS_REFC_CRC_MAGIC … unsigned int xfs_refc_block(struct xfs_mount *mp); /* * Data record/key structure * * Each record associates a range of physical blocks (starting at * rc_startblock and ending rc_blockcount blocks later) with a reference * count (rc_refcount). Extents that are being used to stage a copy on * write (CoW) operation are recorded in the refcount btree with a * refcount of 1. All other records must have a refcount > 1 and must * track an extent mapped only by file data forks. * * Extents with a single owner (attributes, metadata, non-shared file * data) are not tracked here. Free space is also not tracked here. * This is consistent with pre-reflink XFS. */ /* * Extents that are being used to stage a copy on write are stored * in the refcount btree with a refcount of 1 and the upper bit set * on the startblock. This speeds up mount time deletion of stale * staging extents because they're all at the right side of the tree. */ #define XFS_REFC_COWFLAG … #define REFCNTBT_COWFLAG_BITLEN … #define REFCNTBT_AGBLOCK_BITLEN … struct xfs_refcount_rec { … }; struct xfs_refcount_key { … }; #define MAXREFCOUNT … #define MAXREFCEXTLEN … /* btree pointer type */ xfs_refcount_ptr_t; /* * BMAP Btree format definitions * * This includes both the root block definition that sits inside an inode fork * and the record/pointer formats for the leaf/node in the blocks. */ #define XFS_BMAP_MAGIC … #define XFS_BMAP_CRC_MAGIC … /* * Bmap root header, on-disk form only. */ xfs_bmdr_block_t; /* * Bmap btree record and extent descriptor. * l0:63 is an extent flag (value 1 indicates non-normal). * l0:9-62 are startoff. * l0:0-8 and l1:21-63 are startblock. * l1:0-20 are blockcount. */ #define BMBT_EXNTFLAG_BITLEN … #define BMBT_STARTOFF_BITLEN … #define BMBT_STARTBLOCK_BITLEN … #define BMBT_BLOCKCOUNT_BITLEN … #define BMBT_STARTOFF_MASK … #define BMBT_BLOCKCOUNT_MASK … #define XFS_MAX_BMBT_EXTLEN … /* * bmbt records have a file offset (block) field that is 54 bits wide, so this * is the largest xfs_fileoff_t that we ever expect to see. */ #define XFS_MAX_FILEOFF … xfs_bmbt_rec_t; xfs_bmbt_rec_base_t; /* use this for casts */ xfs_bmdr_rec_t; /* * Values and macros for delayed-allocation startblock fields. */ #define STARTBLOCKVALBITS … #define STARTBLOCKMASKBITS … #define STARTBLOCKMASK … static inline int isnullstartblock(xfs_fsblock_t x) { … } static inline xfs_fsblock_t nullstartblock(int k) { … } static inline xfs_filblks_t startblockval(xfs_fsblock_t x) { … } /* * Key structure for non-leaf levels of the tree. */ xfs_bmdr_key_t; /* btree pointer type */ xfs_bmdr_ptr_t; /* * Generic Btree block format definitions * * This is a combination of the actual format used on disk for short and long * format btrees. The first three fields are shared by both format, but the * pointers are different and should be used with care. * * To get the size of the actual short or long form headers please use the size * macros below. Never use sizeof(xfs_btree_block). * * The blkno, crc, lsn, owner and uuid fields are only available in filesystems * with the crc feature bit, and all accesses to them must be conditional on * that flag. */ /* short form block header */ struct xfs_btree_block_shdr { … }; /* long form block header */ struct xfs_btree_block_lhdr { … }; struct xfs_btree_block { … }; /* size of a short form block */ #define XFS_BTREE_SBLOCK_LEN … /* size of a long form block */ #define XFS_BTREE_LBLOCK_LEN … /* sizes of CRC enabled btree blocks */ #define XFS_BTREE_SBLOCK_CRC_LEN … #define XFS_BTREE_LBLOCK_CRC_LEN … #define XFS_BTREE_SBLOCK_CRC_OFF … #define XFS_BTREE_LBLOCK_CRC_OFF … /* * On-disk XFS access control list structure. */ struct xfs_acl_entry { … }; struct xfs_acl { … }; /* * The number of ACL entries allowed is defined by the on-disk format. * For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is * limited only by the maximum size of the xattr that stores the information. */ #define XFS_ACL_MAX_ENTRIES(mp) … #define XFS_ACL_SIZE(cnt) … #define XFS_ACL_MAX_SIZE(mp) … /* On-disk XFS extended attribute names */ #define SGI_ACL_FILE … #define SGI_ACL_DEFAULT … #define SGI_ACL_FILE_SIZE … #define SGI_ACL_DEFAULT_SIZE … #endif /* __XFS_FORMAT_H__ */