fs/xfs/scrub/tempfile.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/tempfile.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/tempfile.c- Extension
.c- Size
- 25940 bytes
- Lines
- 981
- 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.
- 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_trans_resv.hxfs_mount.hxfs_log_format.hxfs_trans.hxfs_inode.hxfs_ialloc.hxfs_quota.hxfs_bmap.hxfs_bmap_btree.hxfs_trans_space.hxfs_dir2.hxfs_exchrange.hxfs_exchmaps.hxfs_defer.hxfs_symlink_remote.hxfs_metafile.hscrub/scrub.hscrub/common.hscrub/repair.hscrub/trace.hscrub/tempfile.hscrub/tempexch.hscrub/xfile.h
Detected Declarations
function Copyrightfunction xrep_tempfile_adjust_directory_treefunction xrep_tempfile_remove_metadirfunction xrep_tempfile_iolock_nowaitfunction xrep_tempfile_iolock_polledfunction xrep_tempfile_iounlockfunction xrep_tempfile_ilockfunction xrep_tempfile_ilock_nowaitfunction xrep_tempfile_iunlockfunction xrep_tempfile_ilock_bothfunction xrep_tempfile_iunlock_bothfunction xrep_tempfile_relefunction xrep_tempfile_preallocfunction xrep_tempfile_copyinfunction xrep_tempfile_set_isizefunction xrep_tempfile_roll_transfunction xrep_tempexch_prep_requestfunction xrep_tempexch_estimatefunction xrep_tempexch_reserve_quotafunction xrep_tempexch_trans_reservefunction xrep_tempexch_trans_allocfunction mappingsfunction xrep_tempfile_copyout_localfunction xrep_is_tempfile
Annotated Snippet
if (nmaps == 0) {
ASSERT(nmaps != 0);
return -EFSCORRUPTED;
}
if (xfs_bmap_is_written_extent(&map))
continue;
/*
* If we find a delalloc reservation then something is very
* very wrong. Bail out.
*/
if (map.br_startblock == DELAYSTARTBLOCK)
return -EFSCORRUPTED;
/*
* Make sure this block has a real zeroed extent allocated to
* it.
*/
nmaps = 1;
error = xfs_bmapi_write(sc->tp, sc->tempip, off, end - off,
XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO, 0, &map,
&nmaps);
if (error)
return error;
if (nmaps != 1)
return -EFSCORRUPTED;
trace_xrep_tempfile_prealloc(sc, XFS_DATA_FORK, &map);
/* Commit new extent and all deferred work. */
error = xfs_defer_finish(&sc->tp);
if (error)
return error;
}
return 0;
}
/*
* Write data to each block of a file. The given range of the tempfile's data
* fork must already be populated with written extents.
*/
int
xrep_tempfile_copyin(
struct xfs_scrub *sc,
xfs_fileoff_t off,
xfs_filblks_t len,
xrep_tempfile_copyin_fn prep_fn,
void *data)
{
LIST_HEAD(buffers_list);
struct xfs_mount *mp = sc->mp;
struct xfs_buf *bp;
xfs_fileoff_t flush_mask;
xfs_fileoff_t end = off + len;
loff_t pos = XFS_FSB_TO_B(mp, off);
int error = 0;
ASSERT(S_ISREG(VFS_I(sc->tempip)->i_mode));
/* Flush buffers to disk every 512K */
flush_mask = XFS_B_TO_FSBT(mp, (1U << 19)) - 1;
for (; off < end; off++, pos += mp->m_sb.sb_blocksize) {
struct xfs_bmbt_irec map;
int nmaps = 1;
/* Read block mapping for this file block. */
error = xfs_bmapi_read(sc->tempip, off, 1, &map, &nmaps, 0);
if (error)
goto out_err;
if (nmaps == 0 || !xfs_bmap_is_written_extent(&map)) {
error = -EFSCORRUPTED;
goto out_err;
}
/* Get the metadata buffer for this offset in the file. */
error = xfs_trans_get_buf(sc->tp, mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, map.br_startblock),
mp->m_bsize, 0, &bp);
if (error)
goto out_err;
trace_xrep_tempfile_copyin(sc, XFS_DATA_FORK, &map);
/* Read in a block's worth of data from the xfile. */
error = prep_fn(sc, bp, data);
if (error) {
xfs_trans_brelse(sc->tp, bp);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_log_format.h`, `xfs_trans.h`.
- Detected declarations: `function Copyright`, `function xrep_tempfile_adjust_directory_tree`, `function xrep_tempfile_remove_metadir`, `function xrep_tempfile_iolock_nowait`, `function xrep_tempfile_iolock_polled`, `function xrep_tempfile_iounlock`, `function xrep_tempfile_ilock`, `function xrep_tempfile_ilock_nowait`, `function xrep_tempfile_iunlock`, `function xrep_tempfile_ilock_both`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.