fs/jffs2/summary.c
Source file repositories/reference/linux-study-clean/fs/jffs2/summary.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/summary.c- Extension
.c- Size
- 24208 bytes
- Lines
- 883
- 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/kernel.hlinux/slab.hlinux/mtd/mtd.hlinux/pagemap.hlinux/crc32.hlinux/compiler.hlinux/vmalloc.hnodelist.hdebug.h
Detected Declarations
function jffs2_sum_initfunction jffs2_sum_exitfunction jffs2_sum_add_memfunction jffs2_sum_add_padding_memfunction jffs2_sum_add_inode_memfunction jffs2_sum_add_dirent_memfunction jffs2_sum_add_xattr_memfunction jffs2_sum_add_xref_memfunction jffs2_sum_clean_collectedfunction jffs2_sum_reset_collectedfunction jffs2_sum_disable_collectingfunction jffs2_sum_is_disabledfunction jffs2_sum_move_collectedfunction jffs2_sum_add_kvecfunction jffs2_sum_process_sum_datafunction jffs2_sum_scan_sumnodefunction jffs2_sum_write_datafunction jffs2_sum_write_sumnode
Annotated Snippet
switch (count) {
case 1:
memcpy(temp->name,node->d.name,node->d.nsize);
break;
case 2:
memcpy(temp->name,invecs[1].iov_base,node->d.nsize);
break;
default:
BUG(); /* impossible count value */
break;
}
return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
}
#ifdef CONFIG_JFFS2_FS_XATTR
case JFFS2_NODETYPE_XATTR: {
struct jffs2_sum_xattr_mem *temp;
temp = kmalloc_obj(struct jffs2_sum_xattr_mem);
if (!temp)
goto no_mem;
temp->nodetype = node->x.nodetype;
temp->xid = node->x.xid;
temp->version = node->x.version;
temp->totlen = node->x.totlen;
temp->offset = cpu_to_je32(ofs);
temp->next = NULL;
return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
}
case JFFS2_NODETYPE_XREF: {
struct jffs2_sum_xref_mem *temp;
temp = kmalloc_obj(struct jffs2_sum_xref_mem);
if (!temp)
goto no_mem;
temp->nodetype = node->r.nodetype;
temp->offset = cpu_to_je32(ofs);
temp->next = NULL;
return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
}
#endif
case JFFS2_NODETYPE_PADDING:
dbg_summary("node PADDING\n");
c->summary->sum_padded += je32_to_cpu(node->u.totlen);
break;
case JFFS2_NODETYPE_CLEANMARKER:
dbg_summary("node CLEANMARKER\n");
break;
case JFFS2_NODETYPE_SUMMARY:
dbg_summary("node SUMMARY\n");
break;
default:
/* If you implement a new node type you should also implement
summary support for it or disable summary.
*/
BUG();
break;
}
return 0;
no_mem:
JFFS2_WARNING("MEMORY ALLOCATION ERROR!");
return -ENOMEM;
}
static struct jffs2_raw_node_ref *sum_link_node_ref(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb,
uint32_t ofs, uint32_t len,
struct jffs2_inode_cache *ic)
{
/* If there was a gap, mark it dirty */
if ((ofs & ~3) > c->sector_size - jeb->free_size) {
/* Ew. Summary doesn't actually tell us explicitly about dirty space */
jffs2_scan_dirty_space(c, jeb, (ofs & ~3) - (c->sector_size - jeb->free_size));
}
return jffs2_link_node_ref(c, jeb, jeb->offset + ofs, len, ic);
}
/* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */
static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
struct jffs2_raw_summary *summary, uint32_t *pseudo_random)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/mtd/mtd.h`, `linux/pagemap.h`, `linux/crc32.h`, `linux/compiler.h`, `linux/vmalloc.h`, `nodelist.h`.
- Detected declarations: `function jffs2_sum_init`, `function jffs2_sum_exit`, `function jffs2_sum_add_mem`, `function jffs2_sum_add_padding_mem`, `function jffs2_sum_add_inode_mem`, `function jffs2_sum_add_dirent_mem`, `function jffs2_sum_add_xattr_mem`, `function jffs2_sum_add_xref_mem`, `function jffs2_sum_clean_collected`, `function jffs2_sum_reset_collected`.
- 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.