fs/xfs/libxfs/xfs_rtbitmap.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_rtbitmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_rtbitmap.c- Extension
.c- Size
- 35805 bytes
- Lines
- 1505
- 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_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_inode.hxfs_bmap.hxfs_bmap_btree.hxfs_trans_space.hxfs_trans.hxfs_rtalloc.hxfs_error.hxfs_rtbitmap.hxfs_health.hxfs_sb.hxfs_errortag.hxfs_log.hxfs_buf_item.hxfs_extent_busy.h
Detected Declarations
function Copyrightfunction xfs_rtbuf_verify_readfunction xfs_rtbuf_verify_writefunction xfs_rtbuf_cache_relsefunction xfs_rtbuf_getfunction xfs_rtbitmap_read_buffunction xfs_rtsummary_read_buffunction xfs_trans_log_rtsummaryfunction xfs_trans_log_rtbitmapfunction xfs_rtfree_blocksfunction xfs_rtalloc_query_rangefunction xfs_rtalloc_query_allfunction xfs_rtalloc_extent_is_freefunction xfs_rtbitmap_rtx_per_rbmblockfunction xfs_rtbitmap_blockcount_lenfunction xfs_rtbitmap_bitcountfunction xfs_rtbitmap_blockcountfunction xfs_rtsummary_blockcountfunction xfs_rtfile_alloc_blocksfunction xfs_rtfile_initialize_blockfunction xfs_rtbitmap_createfunction xfs_rtsummary_create
Annotated Snippet
if (hdr->rt_owner != cpu_to_be64(I_INO(ip))) {
xfs_buf_mark_corrupt(bp);
xfs_trans_brelse(args->tp, bp);
xfs_rtginode_mark_sick(args->rtg, type);
return -EFSCORRUPTED;
}
}
xfs_trans_buf_set_type(args->tp, bp, buf_type);
*cbpp = bp;
*coffp = block;
return 0;
}
int
xfs_rtbitmap_read_buf(
struct xfs_rtalloc_args *args,
xfs_fileoff_t block)
{
struct xfs_mount *mp = args->mp;
if (XFS_IS_CORRUPT(mp, block >= mp->m_sb.sb_rbmblocks)) {
xfs_rtginode_mark_sick(args->rtg, XFS_RTGI_BITMAP);
return -EFSCORRUPTED;
}
return xfs_rtbuf_get(args, block, XFS_RTGI_BITMAP);
}
int
xfs_rtsummary_read_buf(
struct xfs_rtalloc_args *args,
xfs_fileoff_t block)
{
struct xfs_mount *mp = args->mp;
if (XFS_IS_CORRUPT(mp, block >= mp->m_rsumblocks)) {
xfs_rtginode_mark_sick(args->rtg, XFS_RTGI_SUMMARY);
return -EFSCORRUPTED;
}
return xfs_rtbuf_get(args, block, XFS_RTGI_SUMMARY);
}
/*
* Searching backward from start find the first block whose allocated/free state
* is different from start's.
*/
int
xfs_rtfind_back(
struct xfs_rtalloc_args *args,
xfs_rtxnum_t start, /* starting rtext to look at */
xfs_rtxnum_t *rtx) /* out: start rtext found */
{
struct xfs_mount *mp = args->mp;
int bit; /* bit number in the word */
xfs_fileoff_t block; /* bitmap block number */
int error; /* error value */
xfs_rtxnum_t firstbit; /* first useful bit in the word */
xfs_rtxnum_t i; /* current bit number rel. to start */
xfs_rtxnum_t len; /* length of inspected area */
xfs_rtword_t mask; /* mask of relevant bits for value */
xfs_rtword_t want; /* mask for "good" values */
xfs_rtword_t wdiff; /* difference from wanted value */
xfs_rtword_t incore;
unsigned int word; /* word number in the buffer */
/*
* Compute and read in starting bitmap block for starting block.
*/
block = xfs_rtx_to_rbmblock(mp, start);
error = xfs_rtbitmap_read_buf(args, block);
if (error)
return error;
/*
* Get the first word's index & point to it.
*/
word = xfs_rtx_to_rbmword(mp, start);
bit = (int)(start & (XFS_NBWORD - 1));
len = start + 1;
/*
* Compute match value, based on the bit at start: if 1 (free)
* then all-ones, else all-zeroes.
*/
incore = xfs_rtbitmap_getword(args, word);
want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
/*
* If the starting position is not word-aligned, deal with the
* partial word.
*/
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_mount.h`.
- Detected declarations: `function Copyright`, `function xfs_rtbuf_verify_read`, `function xfs_rtbuf_verify_write`, `function xfs_rtbuf_cache_relse`, `function xfs_rtbuf_get`, `function xfs_rtbitmap_read_buf`, `function xfs_rtsummary_read_buf`, `function xfs_trans_log_rtsummary`, `function xfs_trans_log_rtbitmap`, `function xfs_rtfree_blocks`.
- 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.