fs/ocfs2/refcounttree.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/refcounttree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/refcounttree.c- Extension
.c- Size
- 123515 bytes
- Lines
- 4812
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sort.hcluster/masklog.hocfs2.hinode.halloc.hsuballoc.hjournal.huptodate.hsuper.hbuffer_head_io.hblockcheck.hrefcounttree.hsysfile.hdlmglue.hextent_map.haops.hxattr.hnamei.hocfs2_trace.hfile.hsymlink.hlinux/bio.hlinux/blkdev.hlinux/slab.hlinux/writeback.hlinux/swap.hlinux/security.hlinux/string.hlinux/fsnotify.hlinux/quotaops.hlinux/namei.hlinux/mount.h
Detected Declarations
struct ocfs2_cow_contextenum ocfs2_ref_rec_contigfunction cache_info_to_refcountfunction ocfs2_validate_refcount_blockfunction ocfs2_read_refcount_blockfunction ocfs2_refcount_cache_ownerfunction ocfs2_refcount_cache_get_superfunction ocfs2_refcount_cache_lockfunction ocfs2_refcount_cache_unlockfunction ocfs2_refcount_cache_io_lockfunction ocfs2_refcount_cache_io_unlockfunction ocfs2_find_refcount_treefunction ocfs2_insert_refcount_treefunction ocfs2_free_refcount_treefunction ocfs2_erase_refcount_tree_from_list_no_lockfunction ocfs2_erase_refcount_tree_from_listfunction ocfs2_kref_remove_refcount_treefunction ocfs2_refcount_tree_getfunction ocfs2_refcount_tree_putfunction ocfs2_init_refcount_tree_cifunction ocfs2_init_refcount_tree_lockfunction ocfs2_allocate_refcount_treefunction ocfs2_get_refcount_treefunction ocfs2_get_refcount_blockfunction __ocfs2_lock_refcount_treefunction ocfs2_lock_refcount_treefunction ocfs2_unlock_refcount_treefunction ocfs2_purge_refcount_treesfunction ocfs2_create_refcount_treefunction ocfs2_set_refcount_treefunction ocfs2_remove_refcount_treefunction ocfs2_find_refcount_rec_in_rlfunction ocfs2_try_remove_refcount_treefunction ocfs2_get_refcount_cpos_endfunction ocfs2_get_refcount_recfunction ocfs2_refcount_rec_adjacentfunction ocfs2_refcount_rec_contigfunction ocfs2_rotate_refcount_rec_leftfunction ocfs2_refcount_rec_mergefunction ocfs2_change_refcount_recfunction ocfs2_expand_inline_ref_rootfunction ocfs2_refcount_rec_no_intersectfunction cmp_refcount_rec_by_low_cposfunction cmp_refcount_rec_by_cposfunction ocfs2_find_refcount_split_posfunction ocfs2_divide_leaf_refcount_blockfunction ocfs2_new_leaf_refcount_blockfunction ocfs2_expand_refcount_tree
Annotated Snippet
struct ocfs2_cow_context {
struct inode *inode;
u32 cow_start;
u32 cow_len;
struct ocfs2_extent_tree data_et;
struct ocfs2_refcount_tree *ref_tree;
struct buffer_head *ref_root_bh;
struct ocfs2_alloc_context *meta_ac;
struct ocfs2_alloc_context *data_ac;
struct ocfs2_cached_dealloc_ctxt dealloc;
void *cow_object;
struct ocfs2_post_refcount *post_refcount;
int extra_credits;
int (*get_clusters)(struct ocfs2_cow_context *context,
u32 v_cluster, u32 *p_cluster,
u32 *num_clusters,
unsigned int *extent_flags);
int (*cow_duplicate_clusters)(handle_t *handle,
struct inode *inode,
u32 cpos, u32 old_cluster,
u32 new_cluster, u32 new_len);
};
static inline struct ocfs2_refcount_tree *
cache_info_to_refcount(struct ocfs2_caching_info *ci)
{
return container_of(ci, struct ocfs2_refcount_tree, rf_ci);
}
static int ocfs2_validate_refcount_block(struct super_block *sb,
struct buffer_head *bh)
{
int rc;
struct ocfs2_refcount_block *rb =
(struct ocfs2_refcount_block *)bh->b_data;
trace_ocfs2_validate_refcount_block((unsigned long long)bh->b_blocknr);
BUG_ON(!buffer_uptodate(bh));
/*
* If the ecc fails, we return the error but otherwise
* leave the filesystem running. We know any error is
* local to this block.
*/
rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &rb->rf_check);
if (rc) {
mlog(ML_ERROR, "Checksum failed for refcount block %llu\n",
(unsigned long long)bh->b_blocknr);
return rc;
}
if (!OCFS2_IS_VALID_REFCOUNT_BLOCK(rb)) {
rc = ocfs2_error(sb,
"Refcount block #%llu has bad signature %.*s\n",
(unsigned long long)bh->b_blocknr, 7,
rb->rf_signature);
goto out;
}
if (le64_to_cpu(rb->rf_blkno) != bh->b_blocknr) {
rc = ocfs2_error(sb,
"Refcount block #%llu has an invalid rf_blkno of %llu\n",
(unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(rb->rf_blkno));
goto out;
}
if (le32_to_cpu(rb->rf_fs_generation) != OCFS2_SB(sb)->fs_generation) {
rc = ocfs2_error(sb,
"Refcount block #%llu has an invalid rf_fs_generation of #%u\n",
(unsigned long long)bh->b_blocknr,
le32_to_cpu(rb->rf_fs_generation));
goto out;
}
out:
return rc;
}
static int ocfs2_read_refcount_block(struct ocfs2_caching_info *ci,
u64 rb_blkno,
struct buffer_head **bh)
{
int rc;
struct buffer_head *tmp = *bh;
rc = ocfs2_read_block(ci, rb_blkno, &tmp,
ocfs2_validate_refcount_block);
Annotation
- Immediate include surface: `linux/sort.h`, `cluster/masklog.h`, `ocfs2.h`, `inode.h`, `alloc.h`, `suballoc.h`, `journal.h`, `uptodate.h`.
- Detected declarations: `struct ocfs2_cow_context`, `enum ocfs2_ref_rec_contig`, `function cache_info_to_refcount`, `function ocfs2_validate_refcount_block`, `function ocfs2_read_refcount_block`, `function ocfs2_refcount_cache_owner`, `function ocfs2_refcount_cache_get_super`, `function ocfs2_refcount_cache_lock`, `function ocfs2_refcount_cache_unlock`, `function ocfs2_refcount_cache_io_lock`.
- 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.