fs/xfs/xfs_fsops.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_fsops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_fsops.c- Extension
.c- Size
- 15523 bytes
- Lines
- 591
- 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_sb.hxfs_mount.hxfs_trans.hxfs_error.hxfs_alloc.hxfs_fsops.hxfs_trans_space.hxfs_log.hxfs_log_priv.hxfs_ag.hxfs_ag_resv.hxfs_trace.hxfs_rtalloc.hxfs_rtrmap_btree.hxfs_rtrefcount_btree.hxfs_metafile.hxfs_healthmon.hlinux/fserror.h
Detected Declarations
function Copyrightfunction xfs_growfs_imaxpctfunction xfs_growfs_datafunction xfs_growfs_logfunction xfs_reserve_blocksfunction xfs_fs_goingdownfunction xfs_do_force_shutdownfunction xfs_fs_reserve_ag_blocksfunction xfs_fs_unreserve_ag_blocks
Annotated Snippet
if (error) {
xfs_buf_delwri_cancel(&id->buffer_list);
return error;
}
}
error = xfs_buf_delwri_submit(&id->buffer_list);
if (error)
return error;
if (delta) {
*lastag_extended = true;
error = xfs_ag_extend_space(last_pag, tp, delta);
}
return error;
}
/*
* growfs operations
*/
static int
xfs_growfs_data_private(
struct xfs_mount *mp, /* mount point for filesystem */
struct xfs_growfs_data *in) /* growfs data input struct */
{
xfs_agnumber_t oagcount = mp->m_sb.sb_agcount;
xfs_rfsblock_t nb = in->newblocks;
struct xfs_buf *bp;
int error;
xfs_agnumber_t nagcount;
xfs_agnumber_t nagimax = 0;
int64_t delta;
bool lastag_extended = false;
struct xfs_trans *tp;
struct aghdr_init_data id = {};
struct xfs_perag *last_pag;
error = xfs_sb_validate_fsb_count(&mp->m_sb, nb);
if (error)
return error;
if (nb > mp->m_sb.sb_dblocks) {
error = xfs_buf_read_uncached(mp->m_ddev_targp,
XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
XFS_FSS_TO_BB(mp, 1), &bp, NULL);
if (error)
return error;
xfs_buf_relse(bp);
}
/* Make sure the new fs size won't cause problems with the log. */
error = xfs_growfs_check_rtgeom(mp, nb, mp->m_sb.sb_rblocks,
mp->m_sb.sb_rextsize);
if (error)
return error;
nagcount = xfs_growfs_compute_agcount(mp, &nb);
delta = nb - mp->m_sb.sb_dblocks;
/*
* Reject filesystems with a single AG because they are not
* supported, and reject a shrink operation that would cause a
* filesystem to become unsupported.
*/
if (delta < 0 && nagcount < 2)
return -EINVAL;
/* No work to do */
if (delta == 0)
return 0;
/* TODO: shrinking the entire AGs hasn't yet completed */
if (nagcount < oagcount)
return -EINVAL;
/* allocate the new per-ag structures */
error = xfs_initialize_perag(mp, oagcount, nagcount, nb, &nagimax);
if (error)
return error;
if (delta > 0)
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata,
XFS_GROWFS_SPACE_RES(mp), 0, XFS_TRANS_RESERVE,
&tp);
else
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_growdata, -delta, 0,
0, &tp);
if (error)
goto out_free_unused_perag;
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_sb.h`, `xfs_mount.h`.
- Detected declarations: `function Copyright`, `function xfs_growfs_imaxpct`, `function xfs_growfs_data`, `function xfs_growfs_log`, `function xfs_reserve_blocks`, `function xfs_fs_goingdown`, `function xfs_do_force_shutdown`, `function xfs_fs_reserve_ag_blocks`, `function xfs_fs_unreserve_ag_blocks`.
- 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.