fs/jbd2/recovery.c
Source file repositories/reference/linux-study-clean/fs/jbd2/recovery.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jbd2/recovery.c- Extension
.c- Size
- 26216 bytes
- Lines
- 997
- 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
jfs_user.hlinux/time.hlinux/fs.hlinux/jbd2.hlinux/errno.hlinux/crc32.hlinux/blkdev.hlinux/string_choices.h
Detected Declarations
struct recovery_infofunction journal_brelse_arrayfunction do_readaheadfunction jreadfunction jbd2_descriptor_block_csum_verifyfunction count_tagsfunction fc_do_one_passfunction jbd2_journal_recoverfunction jbd2_journal_wipefunction itfunction read_tag_blockfunction calc_chksumsfunction jbd2_commit_block_csum_verifyfunction jbd2_commit_block_csum_verify_partialfunction jbd2_block_tag_csum_verifyfunction jbd2_do_replayfunction do_one_passfunction placesfunction scan_revoke_records
Annotated Snippet
if (err) {
printk(KERN_ERR "JBD2: bad block at offset %u\n",
next);
goto failed;
}
bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
if (!bh)
goto failed;
if (!buffer_uptodate(bh) && !buffer_locked(bh)) {
bufs[nbufs++] = bh;
if (nbufs == MAXBUF) {
bh_readahead_batch(nbufs, bufs, 0);
journal_brelse_array(bufs, nbufs);
nbufs = 0;
}
} else
brelse(bh);
}
if (nbufs)
bh_readahead_batch(nbufs, bufs, 0);
failed:
if (nbufs)
journal_brelse_array(bufs, nbufs);
}
#endif /* __KERNEL__ */
/*
* Read a block from the journal
*/
static int jread(struct buffer_head **bhp, journal_t *journal,
unsigned int offset)
{
int err;
unsigned long long blocknr;
struct buffer_head *bh;
*bhp = NULL;
if (offset >= journal->j_total_len) {
printk(KERN_ERR "JBD2: corrupted journal superblock\n");
return -EFSCORRUPTED;
}
err = jbd2_journal_bmap(journal, offset, &blocknr);
if (err) {
printk(KERN_ERR "JBD2: bad block at offset %u\n",
offset);
return err;
}
bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
if (!bh)
return -ENOMEM;
if (!buffer_uptodate(bh)) {
/*
* If this is a brand new buffer, start readahead.
* Otherwise, we assume we are already reading it.
*/
bool need_readahead = !buffer_req(bh);
bh_read_nowait(bh, 0);
if (need_readahead)
do_readahead(journal, offset);
wait_on_buffer(bh);
}
if (!buffer_uptodate(bh)) {
printk(KERN_ERR "JBD2: Failed to read block at offset %u\n",
offset);
brelse(bh);
return -EIO;
}
*bhp = bh;
return 0;
}
static int jbd2_descriptor_block_csum_verify(journal_t *j, void *buf)
{
struct jbd2_journal_block_tail *tail;
__be32 provided;
Annotation
- Immediate include surface: `jfs_user.h`, `linux/time.h`, `linux/fs.h`, `linux/jbd2.h`, `linux/errno.h`, `linux/crc32.h`, `linux/blkdev.h`, `linux/string_choices.h`.
- Detected declarations: `struct recovery_info`, `function journal_brelse_array`, `function do_readahead`, `function jread`, `function jbd2_descriptor_block_csum_verify`, `function count_tags`, `function fc_do_one_pass`, `function jbd2_journal_recover`, `function jbd2_journal_wipe`, `function it`.
- 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.