fs/xfs/libxfs/xfs_sb.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_sb.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_sb.c- Extension
.c- Size
- 52997 bytes
- Lines
- 1756
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_sb.hxfs_mount.hxfs_ialloc.hxfs_alloc.hxfs_error.hxfs_trans.hxfs_buf_item.hxfs_bmap_btree.hxfs_alloc_btree.hxfs_log.hxfs_rmap_btree.hxfs_refcount_btree.hxfs_da_format.hxfs_health.hxfs_ag.hxfs_rtbitmap.hxfs_exchrange.hxfs_rtgroup.hxfs_rtrmap_btree.hxfs_rtrefcount_btree.h
Detected Declarations
function Copyrightfunction xfs_sb_good_versionfunction xfs_sb_version_to_featuresfunction xfs_validate_sb_readfunction xfs_extents_per_rbmfunction blockfunction xfs_expected_rbmblocksfunction xfs_validate_rt_geometryfunction xfs_validate_sb_writefunction xfs_sb_has_ro_compat_featurefunction xfs_compute_rgblklogfunction xfs_validate_sb_rtgroupsfunction xfs_validate_sb_zonedfunction xfs_validate_sb_commonfunction XFS_FSB_TO_Bfunction xfs_sb_quota_from_diskfunction __xfs_sb_from_diskfunction xfs_sb_from_diskfunction xfs_sb_quota_to_diskfunction xfs_sb_to_diskfunction xfs_sb_read_verifyfunction xfs_sb_quiet_read_verifyfunction xfs_sb_write_verifyfunction xfs_sb_mount_rextsizefunction xfs_mount_sb_set_rextsizefunction xfs_sb_mount_commonfunction xfs_log_sbfunction xfs_sync_sbfunction xfs_update_secondary_sbsfunction xfs_sync_sb_buffunction xfs_fs_geometryfunction xfs_sb_read_secondaryfunction xfs_sb_get_secondaryfunction xfs_validate_stripe_geometryfunction xfs_compute_rextslog
Annotated Snippet
if (!xfs_is_readonly(mp)) {
xfs_warn(mp,
"Attempted to mount read-only compatible filesystem read-write.");
xfs_warn(mp,
"Filesystem can only be safely mounted read only.");
return -EINVAL;
}
}
if (xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_UNKNOWN)) {
xfs_warn(mp,
"Superblock has unknown incompatible features (0x%x) enabled.",
(sbp->sb_features_incompat &
XFS_SB_FEAT_INCOMPAT_UNKNOWN));
xfs_warn(mp,
"Filesystem cannot be safely mounted by this kernel.");
return -EINVAL;
}
return 0;
}
/* Return the number of extents covered by a single rt bitmap file */
static xfs_rtbxlen_t
xfs_extents_per_rbm(
struct xfs_sb *sbp)
{
if (xfs_sb_is_v5(sbp) &&
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR))
return sbp->sb_rgextents;
return sbp->sb_rextents;
}
/*
* Return the payload size of a single rt bitmap block (without the metadata
* header if any).
*/
static inline unsigned int
xfs_rtbmblock_size(
struct xfs_sb *sbp)
{
if (xfs_sb_is_v5(sbp) &&
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR))
return sbp->sb_blocksize - sizeof(struct xfs_rtbuf_blkinfo);
return sbp->sb_blocksize;
}
static uint64_t
xfs_expected_rbmblocks(
struct xfs_sb *sbp)
{
if (xfs_sb_is_v5(sbp) &&
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED))
return 0;
return howmany_64(xfs_extents_per_rbm(sbp),
NBBY * xfs_rtbmblock_size(sbp));
}
/* Validate the realtime geometry */
bool
xfs_validate_rt_geometry(
struct xfs_sb *sbp)
{
if (xfs_sb_is_v5(sbp) &&
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) {
if (sbp->sb_rextsize != 1)
return false;
} else {
if (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE ||
sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE)
return false;
}
if (sbp->sb_rblocks == 0) {
if (sbp->sb_rextents != 0 || sbp->sb_rbmblocks != 0 ||
sbp->sb_rextslog != 0 || sbp->sb_frextents != 0)
return false;
return true;
}
if (sbp->sb_rextents == 0 ||
sbp->sb_rextents != div_u64(sbp->sb_rblocks, sbp->sb_rextsize) ||
sbp->sb_rextslog != xfs_compute_rextslog(sbp->sb_rextents) ||
sbp->sb_rbmblocks != xfs_expected_rbmblocks(sbp))
return false;
if (xfs_sb_is_v5(sbp) &&
(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) {
uint32_t mod;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_bit.h`, `xfs_sb.h`.
- Detected declarations: `function Copyright`, `function xfs_sb_good_version`, `function xfs_sb_version_to_features`, `function xfs_validate_sb_read`, `function xfs_extents_per_rbm`, `function block`, `function xfs_expected_rbmblocks`, `function xfs_validate_rt_geometry`, `function xfs_validate_sb_write`, `function xfs_sb_has_ro_compat_feature`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.