fs/jffs2/wbuf.c
Source file repositories/reference/linux-study-clean/fs/jffs2/wbuf.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jffs2/wbuf.c- Extension
.c- Size
- 37798 bytes
- Lines
- 1351
- 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/crc32.hlinux/mtd/rawnand.hlinux/jiffies.hlinux/sched.hlinux/writeback.hnodelist.h
Detected Declarations
struct jffs2_inodirtyfunction jffs2_wbuf_pending_for_inofunction jffs2_clear_wbuf_ino_listfunction jffs2_wbuf_dirties_inodefunction jffs2_refile_wbuf_blocksfunction list_for_each_safefunction jffs2_block_refilefunction jffs2_verify_writefunction jffs2_wbuf_recoverfunction __jffs2_flush_wbuffunction jffs2_flush_wbuf_gcfunction jffs2_flush_wbuf_padfunction jffs2_fill_wbuffunction jffs2_flash_writevfunction PADfunction jffs2_flash_writefunction jffs2_flash_readfunction jffs2_check_oob_emptyfunction jffs2_check_nand_cleanmarkerfunction jffs2_write_nand_cleanmarkerfunction jffs2_write_nand_badblockfunction delayed_wbuf_syncfunction jffs2_dirty_triggerfunction jffs2_nand_flash_setupfunction jffs2_nand_flash_cleanupfunction jffs2_dataflash_setupfunction jffs2_dataflash_cleanupfunction jffs2_nor_wbuf_flash_setupfunction jffs2_nor_wbuf_flash_cleanupfunction jffs2_ubivol_setupfunction jffs2_ubivol_cleanup
Annotated Snippet
struct jffs2_inodirty {
uint32_t ino;
struct jffs2_inodirty *next;
};
static struct jffs2_inodirty inodirty_nomem;
static int jffs2_wbuf_pending_for_ino(struct jffs2_sb_info *c, uint32_t ino)
{
struct jffs2_inodirty *this = c->wbuf_inodes;
/* If a malloc failed, consider _everything_ dirty */
if (this == &inodirty_nomem)
return 1;
/* If ino == 0, _any_ non-GC writes mean 'yes' */
if (this && !ino)
return 1;
/* Look to see if the inode in question is pending in the wbuf */
while (this) {
if (this->ino == ino)
return 1;
this = this->next;
}
return 0;
}
static void jffs2_clear_wbuf_ino_list(struct jffs2_sb_info *c)
{
struct jffs2_inodirty *this;
this = c->wbuf_inodes;
if (this != &inodirty_nomem) {
while (this) {
struct jffs2_inodirty *next = this->next;
kfree(this);
this = next;
}
}
c->wbuf_inodes = NULL;
}
static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino)
{
struct jffs2_inodirty *new;
/* Schedule delayed write-buffer write-out */
jffs2_dirty_trigger(c);
if (jffs2_wbuf_pending_for_ino(c, ino))
return;
new = kmalloc_obj(*new);
if (!new) {
jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n");
jffs2_clear_wbuf_ino_list(c);
c->wbuf_inodes = &inodirty_nomem;
return;
}
new->ino = ino;
new->next = c->wbuf_inodes;
c->wbuf_inodes = new;
return;
}
static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c)
{
struct list_head *this, *next;
static int n;
if (list_empty(&c->erasable_pending_wbuf_list))
return;
list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) {
struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list);
jffs2_dbg(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n",
jeb->offset);
list_del(this);
if ((jiffies + (n++)) & 127) {
/* Most of the time, we just erase it immediately. Otherwise we
spend ages scanning it on mount, etc. */
jffs2_dbg(1, "...and adding to erase_pending_list\n");
list_add_tail(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
jffs2_garbage_collect_trigger(c);
} else {
/* Sometimes, however, we leave it elsewhere so it doesn't get
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/mtd/mtd.h`, `linux/crc32.h`, `linux/mtd/rawnand.h`, `linux/jiffies.h`, `linux/sched.h`, `linux/writeback.h`.
- Detected declarations: `struct jffs2_inodirty`, `function jffs2_wbuf_pending_for_ino`, `function jffs2_clear_wbuf_ino_list`, `function jffs2_wbuf_dirties_inode`, `function jffs2_refile_wbuf_blocks`, `function list_for_each_safe`, `function jffs2_block_refile`, `function jffs2_verify_write`, `function jffs2_wbuf_recover`, `function __jffs2_flush_wbuf`.
- 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.