fs/ocfs2/suballoc.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/suballoc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/suballoc.c- Extension
.c- Size
- 90729 bytes
- Lines
- 3326
- 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/fs.hlinux/types.hlinux/slab.hlinux/string.hlinux/highmem.hcluster/masklog.hocfs2.halloc.hblockcheck.hdlmglue.hinode.hjournal.hlocalalloc.hsuballoc.hsuper.hsysfile.huptodate.hocfs2_trace.hbuffer_head_io.h
Detected Declarations
struct ocfs2_suballoc_resultfunction ocfs2_group_from_resfunction ocfs2_free_ac_resourcefunction ocfs2_free_alloc_contextfunction ocfs2_bits_per_groupfunction ocfs2_validate_gd_selffunction ocfs2_validate_gd_parentfunction le16_to_cpufunction ocfs2_check_group_descriptorfunction ocfs2_validate_group_descriptorfunction descriptorfunction ocfs2_read_group_descriptorfunction ocfs2_bg_discontig_add_extentfunction ocfs2_block_group_fillfunction ocfs2_find_smallest_chainfunction ocfs2_block_group_alloc_contigfunction ocfs2_block_group_claim_bitsfunction ocfs2_block_group_grow_discontigfunction ocfs2_bg_alloc_cleanupfunction ocfs2_block_group_alloc_discontigfunction ocfs2_block_group_allocfunction ocfs2_reserve_suballoc_bitsfunction ocfs2_init_inode_steal_slotfunction ocfs2_init_meta_steal_slotfunction ocfs2_init_steal_slotsfunction __ocfs2_set_steal_slotfunction __ocfs2_get_steal_slotfunction ocfs2_get_inode_steal_slotfunction ocfs2_get_meta_steal_slotfunction ocfs2_steal_resourcefunction ocfs2_steal_inodefunction ocfs2_steal_metafunction ocfs2_reserve_new_metadata_blocksfunction ocfs2_reserve_new_metadatafunction ocfs2_reserve_new_inodefunction ocfs2_reserve_cluster_bitmap_bitsfunction ocfs2_reserve_clusters_with_limitfunction ocfs2_alloc_should_use_localfunction ocfs2_reserve_clustersfunction committedfunction ocfs2_find_max_contig_free_bitsfunction ocfs2_block_group_find_clear_bitsfunction ocfs2_block_group_set_bitsfunction ocfs2_find_victim_chainfunction ocfs2_relink_block_groupfunction ocfs2_block_group_reasonably_emptyfunction ocfs2_cluster_group_searchfunction ocfs2_block_group_search
Annotated Snippet
struct ocfs2_suballoc_result {
u64 sr_bg_blkno; /* The bg we allocated from. Set
to 0 when a block group is
contiguous. */
u64 sr_bg_stable_blkno; /*
* Doesn't change, always
* set to target block
* group descriptor
* block.
*/
u64 sr_blkno; /* The first allocated block */
unsigned int sr_bit_offset; /* The bit in the bg */
unsigned int sr_bits; /* How many bits we claimed */
unsigned int sr_max_contig_bits; /* The length for contiguous
* free bits, only available
* for cluster group
*/
};
static u64 ocfs2_group_from_res(struct ocfs2_suballoc_result *res)
{
if (res->sr_blkno == 0)
return 0;
if (res->sr_bg_blkno)
return res->sr_bg_blkno;
return ocfs2_which_suballoc_group(res->sr_blkno, res->sr_bit_offset);
}
static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
static int ocfs2_block_group_fill(handle_t *handle,
struct inode *alloc_inode,
struct buffer_head *bg_bh,
u64 group_blkno,
unsigned int group_clusters,
u16 my_chain,
struct ocfs2_chain_list *cl);
static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
struct inode *alloc_inode,
struct buffer_head *bh,
u64 max_block,
u64 *last_alloc_group,
int flags);
static int ocfs2_cluster_group_search(struct inode *inode,
struct buffer_head *group_bh,
u32 bits_wanted, u32 min_bits,
u64 max_block,
struct ocfs2_suballoc_result *res);
static int ocfs2_block_group_search(struct inode *inode,
struct buffer_head *group_bh,
u32 bits_wanted, u32 min_bits,
u64 max_block,
struct ocfs2_suballoc_result *res);
static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
handle_t *handle,
u32 bits_wanted,
u32 min_bits,
struct ocfs2_suballoc_result *res);
static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
int nr);
static int ocfs2_relink_block_group(handle_t *handle,
struct inode *alloc_inode,
struct buffer_head *fe_bh,
struct buffer_head *bg_bh,
struct buffer_head *prev_bg_bh,
u16 chain);
static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
u32 wanted);
static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode,
u64 bg_blkno,
u16 bg_bit_off);
static inline void ocfs2_block_to_cluster_group(struct inode *inode,
u64 data_blkno,
u64 *bg_blkno,
u16 *bg_bit_off);
static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
u32 bits_wanted, u64 max_block,
int flags,
struct ocfs2_alloc_context **ac);
void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
{
struct inode *inode = ac->ac_inode;
if (inode) {
if (ac->ac_which != OCFS2_AC_USE_LOCAL)
ocfs2_inode_unlock(inode, 1);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/types.h`, `linux/slab.h`, `linux/string.h`, `linux/highmem.h`, `cluster/masklog.h`, `ocfs2.h`, `alloc.h`.
- Detected declarations: `struct ocfs2_suballoc_result`, `function ocfs2_group_from_res`, `function ocfs2_free_ac_resource`, `function ocfs2_free_alloc_context`, `function ocfs2_bits_per_group`, `function ocfs2_validate_gd_self`, `function ocfs2_validate_gd_parent`, `function le16_to_cpu`, `function ocfs2_check_group_descriptor`, `function ocfs2_validate_group_descriptor`.
- 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.