fs/jffs2/malloc.c
Source file repositories/reference/linux-study-clean/fs/jffs2/malloc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/malloc.c- Extension
.c- Size
- 6967 bytes
- Lines
- 300
- 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.
- 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/kernel.hlinux/slab.hlinux/init.hlinux/jffs2.hnodelist.h
Detected Declarations
function jffs2_create_slab_cachesfunction jffs2_destroy_slab_cachesfunction jffs2_free_full_direntfunction jffs2_free_full_dnodefunction jffs2_free_raw_direntfunction jffs2_free_raw_inodefunction jffs2_free_tmp_dnode_infofunction jffs2_prealloc_raw_node_refsfunction jffs2_free_refblockfunction jffs2_free_node_fragfunction jffs2_free_inode_cachefunction jffs2_free_xattr_datumfunction jffs2_free_xattr_ref
Annotated Snippet
if (!ref) {
dbg_memalloc("Allocating new refblock linked from %p\n", p);
ref = *p = jffs2_alloc_refblock();
if (!ref)
return -ENOMEM;
}
if (ref->flash_offset == REF_LINK_NODE) {
p = &ref->next_in_ino;
ref = *p;
continue;
}
i--;
ref++;
}
jeb->allocated_refs = nr;
dbg_memalloc("Reserved %d refs for block @0x%08x, last_node is %p (%08x,%p)\n",
nr, jeb->offset, jeb->last_node, jeb->last_node->flash_offset,
jeb->last_node->next_in_ino);
return 0;
}
void jffs2_free_refblock(struct jffs2_raw_node_ref *x)
{
dbg_memalloc("%p\n", x);
kmem_cache_free(raw_node_ref_slab, x);
}
struct jffs2_node_frag *jffs2_alloc_node_frag(void)
{
struct jffs2_node_frag *ret;
ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL);
dbg_memalloc("%p\n", ret);
return ret;
}
void jffs2_free_node_frag(struct jffs2_node_frag *x)
{
dbg_memalloc("%p\n", x);
kmem_cache_free(node_frag_slab, x);
}
struct jffs2_inode_cache *jffs2_alloc_inode_cache(void)
{
struct jffs2_inode_cache *ret;
ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL);
dbg_memalloc("%p\n", ret);
return ret;
}
void jffs2_free_inode_cache(struct jffs2_inode_cache *x)
{
dbg_memalloc("%p\n", x);
kmem_cache_free(inode_cache_slab, x);
}
#ifdef CONFIG_JFFS2_FS_XATTR
struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void)
{
struct jffs2_xattr_datum *xd;
xd = kmem_cache_zalloc(xattr_datum_cache, GFP_KERNEL);
dbg_memalloc("%p\n", xd);
if (!xd)
return NULL;
xd->class = RAWNODE_CLASS_XATTR_DATUM;
xd->node = (void *)xd;
INIT_LIST_HEAD(&xd->xindex);
return xd;
}
void jffs2_free_xattr_datum(struct jffs2_xattr_datum *xd)
{
dbg_memalloc("%p\n", xd);
kmem_cache_free(xattr_datum_cache, xd);
}
struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void)
{
struct jffs2_xattr_ref *ref;
ref = kmem_cache_zalloc(xattr_ref_cache, GFP_KERNEL);
dbg_memalloc("%p\n", ref);
if (!ref)
return NULL;
ref->class = RAWNODE_CLASS_XATTR_REF;
ref->node = (void *)ref;
return ref;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/init.h`, `linux/jffs2.h`, `nodelist.h`.
- Detected declarations: `function jffs2_create_slab_caches`, `function jffs2_destroy_slab_caches`, `function jffs2_free_full_dirent`, `function jffs2_free_full_dnode`, `function jffs2_free_raw_dirent`, `function jffs2_free_raw_inode`, `function jffs2_free_tmp_dnode_info`, `function jffs2_prealloc_raw_node_refs`, `function jffs2_free_refblock`, `function jffs2_free_node_frag`.
- 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.