drivers/md/dm-vdo/recovery-journal.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/recovery-journal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/recovery-journal.c- Extension
.c- Size
- 59025 bytes
- Lines
- 1762
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
recovery-journal.hlinux/atomic.hlinux/bio.hlogger.hmemory-alloc.hpermassert.hblock-map.hcompletion.hconstants.hdata-vio.hencodings.hio-submitter.hslab-depot.htypes.hvdo.hvio.hwait-queue.h
Detected Declarations
enum lock_counter_statefunction get_zone_count_ptrfunction get_counterfunction is_journal_zone_lockedfunction vdo_release_recovery_journal_block_referencefunction get_journal_blockfunction pop_free_listfunction is_block_dirtyfunction is_block_emptyfunction is_block_fullfunction assert_on_journal_threadfunction continue_waiterfunction has_block_waitersfunction suspend_lock_counterfunction is_read_onlyfunction check_for_drain_completefunction notify_recovery_journal_of_read_only_modefunction enter_journal_read_only_modefunction vdo_get_recovery_journal_current_sequence_numberfunction get_recovery_journal_headfunction compute_recovery_count_bytefunction check_slab_journal_commit_thresholdfunction finish_reapingfunction complete_reapingfunction handle_flush_errorfunction flush_endiofunction initialize_journal_statefunction vdo_get_recovery_journal_lengthfunction reap_recovery_journal_callbackfunction initialize_lock_counterfunction set_journal_tailfunction initialize_recovery_blockfunction vdo_decode_recovery_journalfunction vdo_free_recovery_journalfunction vdo_initialize_recovery_journal_post_repairfunction vdo_get_journal_block_map_data_blocks_usedfunction vdo_get_recovery_journal_thread_idfunction vdo_open_recovery_journalfunction vdo_record_recovery_journalfunction get_block_headerfunction set_active_sectorfunction advance_tailfunction initialize_lock_countfunction prepare_to_assign_entryfunction schedule_block_writefunction release_journal_block_referencefunction update_usagesfunction assign_entry
Annotated Snippet
if (journal->active_block != NULL) {
VDO_ASSERT_LOG_ONLY(((result == VDO_READ_ONLY) ||
!is_block_dirty(journal->active_block)),
"journal being saved has clean active block");
recycle_journal_block(journal->active_block);
}
VDO_ASSERT_LOG_ONLY(list_empty(&journal->active_tail_blocks),
"all blocks in a journal being saved must be inactive");
}
vdo_finish_draining_with_result(&journal->state, result);
}
/**
* notify_recovery_journal_of_read_only_mode() - Notify a recovery journal that the VDO has gone
* read-only.
* @listener: The journal.
* @parent: The completion to notify in order to acknowledge the notification.
*
* Implements vdo_read_only_notification_fn.
*/
static void notify_recovery_journal_of_read_only_mode(void *listener,
struct vdo_completion *parent)
{
check_for_drain_complete(listener);
vdo_finish_completion(parent);
}
/**
* enter_journal_read_only_mode() - Put the journal in read-only mode.
* @journal: The journal which has failed.
* @error_code: The error result triggering this call.
*
* All attempts to add entries after this function is called will fail. All VIOs waiting for
* commits will be awakened with an error.
*/
static void enter_journal_read_only_mode(struct recovery_journal *journal,
int error_code)
{
vdo_enter_read_only_mode(journal->flush_vio->completion.vdo, error_code);
check_for_drain_complete(journal);
}
/**
* vdo_get_recovery_journal_current_sequence_number() - Obtain the recovery journal's current
* sequence number.
* @journal: The journal in question.
*
* Exposed only so the block map can be initialized therefrom.
*
* Return: The sequence number of the tail block.
*/
sequence_number_t vdo_get_recovery_journal_current_sequence_number(struct recovery_journal *journal)
{
return journal->tail;
}
/**
* get_recovery_journal_head() - Get the head of the recovery journal.
* @journal: The journal.
*
* The head is the lowest sequence number of the block map head and the slab journal head.
*
* Return: The head of the journal.
*/
static inline sequence_number_t get_recovery_journal_head(const struct recovery_journal *journal)
{
return min(journal->block_map_head, journal->slab_journal_head);
}
/**
* compute_recovery_count_byte() - Compute the recovery count byte for a given recovery count.
* @recovery_count: The recovery count.
*
* Return: The byte corresponding to the recovery count.
*/
static inline u8 __must_check compute_recovery_count_byte(u64 recovery_count)
{
return (u8)(recovery_count & RECOVERY_COUNT_MASK);
}
/**
* check_slab_journal_commit_threshold() - Check whether the journal is over the threshold, and if
* so, force the oldest slab journal tail block to commit.
* @journal: The journal.
*/
static void check_slab_journal_commit_threshold(struct recovery_journal *journal)
{
block_count_t current_length = journal->tail - journal->slab_journal_head;
Annotation
- Immediate include surface: `recovery-journal.h`, `linux/atomic.h`, `linux/bio.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `block-map.h`, `completion.h`.
- Detected declarations: `enum lock_counter_state`, `function get_zone_count_ptr`, `function get_counter`, `function is_journal_zone_locked`, `function vdo_release_recovery_journal_block_reference`, `function get_journal_block`, `function pop_free_list`, `function is_block_dirty`, `function is_block_empty`, `function is_block_full`.
- Atlas domain: Driver Families / drivers/md.
- 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.