fs/xfs/xfs_mount.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_mount.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_mount.c- Extension
.c- Size
- 46831 bytes
- Lines
- 1700
- 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_inode.hxfs_dir2.hxfs_ialloc.hxfs_alloc.hxfs_rtalloc.hxfs_bmap.hxfs_trans.hxfs_trans_priv.hxfs_log.hxfs_log_priv.hxfs_error.hxfs_quota.hxfs_fsops.hxfs_icache.hxfs_sysfs.hxfs_rmap_btree.hxfs_refcount_btree.hxfs_reflink.hxfs_extent_busy.hxfs_health.hxfs_trace.hxfs_ag.hxfs_rtbitmap.h
Detected Declarations
function xfs_uuid_searchfunction xa_for_eachfunction xfs_uuid_deletefunction xfs_uuid_table_freefunction xfs_uuid_mountfunction xfs_uuid_unmountfunction thefunction xfs_readsbfunction xfs_check_new_dalignfunction unitsfunction xfs_update_alignmentfunction xfs_set_low_space_thresholdsfunction datafunction xfs_mount_reset_sbqflagsfunction xfs_default_resblksfunction xfs_check_summary_countsfunction xfs_fs_has_sicknessfunction xfs_unmount_checkfunction xfs_unmount_flush_inodesfunction xfs_mount_setup_inode_geomfunction xfs_mount_setup_metadirfunction xfs_agbtree_compute_maxlevelsfunction xfs_calc_atomic_write_maxfunction xfs_calc_group_awu_maxfunction xfs_calc_atomic_write_unit_maxfunction xfs_set_max_atomic_write_optfunction xfs_rtbtree_compute_maxlevelsfunction xfs_mountfsfunction XFS_B_TO_FSBTfunction xfs_unmountfsfunction xfs_fs_writablefunction xfs_freecounter_unavailablefunction xfs_add_freecounterfunction xfs_dec_freecounterfunction xfs_freecounter_unavailablefunction xfs_freesbfunction underlyingfunction xfs_force_summary_recalcfunction xfs_add_incompat_log_featurefunction xfs_clear_incompat_log_featuresfunction update
Annotated Snippet
xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS)) {
error = xfs_initialize_perag_data(mp, mp->m_sb.sb_agcount);
if (error)
return error;
}
/*
* Older kernels misused sb_frextents to reflect both incore
* reservations made by running transactions and the actual count of
* free rt extents in the ondisk metadata. Transactions committed
* during runtime can therefore contain a superblock update that
* undercounts the number of free rt extents tracked in the rt bitmap.
* A clean unmount record will have the correct frextents value since
* there can be no other transactions running at that point.
*
* If we're mounting the rt volume after recovering the log, recompute
* frextents from the rtbitmap file to fix the inconsistency.
*/
if (xfs_has_realtime(mp) && !xfs_has_zoned(mp) && !xfs_is_clean(mp)) {
error = xfs_rtalloc_reinit_frextents(mp);
if (error)
return error;
}
return 0;
}
static void
xfs_unmount_check(
struct xfs_mount *mp)
{
if (xfs_is_shutdown(mp))
return;
if (percpu_counter_sum(&mp->m_ifree) >
percpu_counter_sum(&mp->m_icount)) {
xfs_alert(mp, "ifree/icount mismatch at unmount");
xfs_fs_mark_sick(mp, XFS_SICK_FS_COUNTERS);
}
}
/*
* Flush and reclaim dirty inodes in preparation for unmount. Inodes and
* internal inode structures can be sitting in the CIL and AIL at this point,
* so we need to unpin them, write them back and/or reclaim them before unmount
* can proceed. In other words, callers are required to have inactivated all
* inodes.
*
* An inode cluster that has been freed can have its buffer still pinned in
* memory because the transaction is still sitting in a iclog. The stale inodes
* on that buffer will be pinned to the buffer until the transaction hits the
* disk and the callbacks run. Pushing the AIL will skip the stale inodes and
* may never see the pinned buffer, so nothing will push out the iclog and
* unpin the buffer.
*
* Hence we need to force the log to unpin everything first. However, log
* forces don't wait for the discards they issue to complete, so we have to
* explicitly wait for them to complete here as well.
*
* Then we can tell the world we are unmounting so that error handling knows
* that the filesystem is going away and we should error out anything that we
* have been retrying in the background. This will prevent never-ending
* retries in AIL pushing from hanging the unmount.
*
* Stop inodegc and background reclaim before pushing the AIL so that they
* are not running while the AIL is being flushed. Then push the AIL to
* clean all the remaining dirty objects and reclaim the remaining inodes.
*/
static void
xfs_unmount_flush_inodes(
struct xfs_mount *mp)
{
xfs_log_force(mp, XFS_LOG_SYNC);
xfs_extent_busy_wait_all(mp);
flush_workqueue(xfs_discard_wq);
xfs_set_unmounting(mp);
xfs_inodegc_stop(mp);
cancel_delayed_work_sync(&mp->m_reclaim_work);
xfs_ail_push_all_sync(mp->m_ail);
xfs_reclaim_inodes(mp);
xfs_health_unmount(mp);
xfs_healthmon_unmount(mp);
}
static void
xfs_mount_setup_inode_geom(
struct xfs_mount *mp)
{
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 xfs_uuid_search`, `function xa_for_each`, `function xfs_uuid_delete`, `function xfs_uuid_table_free`, `function xfs_uuid_mount`, `function xfs_uuid_unmount`, `function the`, `function xfs_readsb`, `function xfs_check_new_dalign`, `function units`.
- 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.