fs/jffs2/debug.c
Source file repositories/reference/linux-study-clean/fs/jffs2/debug.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/debug.c- Extension
.c- Size
- 26252 bytes
- Lines
- 867
- 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/types.hlinux/pagemap.hlinux/crc32.hlinux/jffs2.hlinux/mtd/mtd.hlinux/slab.hnodelist.hdebug.h
Detected Declarations
function __jffs2_dbg_acct_sanity_check_nolockfunction __jffs2_dbg_acct_sanity_checkfunction __jffs2_dbg_fragtree_paranoia_checkfunction __jffs2_dbg_fragtree_paranoia_check_nolockfunction __jffs2_dbg_prewrite_paranoia_checkfunction __jffs2_dbg_superblock_countsfunction list_for_each_entryfunction __jffs2_dbg_acct_paranoia_checkfunction __jffs2_dbg_acct_paranoia_check_nolockfunction __jffs2_dbg_dump_node_refsfunction __jffs2_dbg_dump_node_refs_nolockfunction __jffs2_dbg_dump_jebfunction __jffs2_dbg_dump_jeb_nolockfunction __jffs2_dbg_dump_block_listsfunction __jffs2_dbg_dump_block_lists_nolockfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction list_for_eachfunction __jffs2_dbg_dump_fragtreefunction __jffs2_dbg_dump_fragtree_nolockfunction __jffs2_dbg_dump_bufferfunction __jffs2_dbg_dump_node
Annotated Snippet
if (ref_flags(fn->raw) == REF_PRISTINE) {
if (fn->frags > 1) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x had %d frags. Tell dwmw2.\n",
ref_offset(fn->raw), fn->frags);
bitched = 1;
}
/* A hole node which isn't multi-page should be garbage-collected
and merged anyway, so we just check for the frag size here,
rather than mucking around with actually reading the node
and checking the compression type, which is the real way
to tell a hole node. */
if (frag->ofs & (PAGE_SIZE-1) && frag_prev(frag)
&& frag_prev(frag)->size < PAGE_SIZE && frag_prev(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a previous non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw));
bitched = 1;
}
if ((frag->ofs+frag->size) & (PAGE_SIZE-1) && frag_next(frag)
&& frag_next(frag)->size < PAGE_SIZE && frag_next(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x (%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw), frag->ofs, frag->ofs+frag->size);
bitched = 1;
}
}
}
if (bitched) {
JFFS2_ERROR("fragtree is corrupted.\n");
__jffs2_dbg_dump_fragtree_nolock(f);
BUG();
}
}
/*
* Check if the flash contains all 0xFF before we start writing.
*/
void
__jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
uint32_t ofs, int len)
{
size_t retlen;
int ret, i;
unsigned char *buf;
buf = kmalloc(len, GFP_KERNEL);
if (!buf)
return;
ret = jffs2_flash_read(c, ofs, len, &retlen, buf);
if (ret || (retlen != len)) {
JFFS2_WARNING("read %d bytes failed or short. ret %d, retlen %zd.\n",
len, ret, retlen);
kfree(buf);
return;
}
ret = 0;
for (i = 0; i < len; i++)
if (buf[i] != 0xff)
ret = 1;
if (ret) {
JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data already there. The first corrupted byte is at %#08x offset.\n",
ofs, ofs + i);
__jffs2_dbg_dump_buffer(buf, len, ofs);
kfree(buf);
BUG();
}
kfree(buf);
}
static void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
{
struct jffs2_eraseblock *jeb;
uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
erasing = 0, bad = 0, unchecked = 0;
int nr_counted = 0;
int dump = 0;
if (c->gcblock) {
nr_counted++;
free += c->gcblock->free_size;
dirty += c->gcblock->dirty_size;
used += c->gcblock->used_size;
wasted += c->gcblock->wasted_size;
unchecked += c->gcblock->unchecked_size;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/pagemap.h`, `linux/crc32.h`, `linux/jffs2.h`, `linux/mtd/mtd.h`, `linux/slab.h`, `nodelist.h`.
- Detected declarations: `function __jffs2_dbg_acct_sanity_check_nolock`, `function __jffs2_dbg_acct_sanity_check`, `function __jffs2_dbg_fragtree_paranoia_check`, `function __jffs2_dbg_fragtree_paranoia_check_nolock`, `function __jffs2_dbg_prewrite_paranoia_check`, `function __jffs2_dbg_superblock_counts`, `function list_for_each_entry`, `function __jffs2_dbg_acct_paranoia_check`, `function __jffs2_dbg_acct_paranoia_check_nolock`, `function __jffs2_dbg_dump_node_refs`.
- 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.