drivers/md/dm-vdo/dedupe.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/dedupe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/dedupe.c- Extension
.c- Size
- 102021 bytes
- Lines
- 2996
- 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
dedupe.hlinux/atomic.hlinux/jiffies.hlinux/kernel.hlinux/list.hlinux/ratelimit.hlinux/spinlock.hlinux/timer.hlogger.hmemory-alloc.hnumeric.hpermassert.hstring-utils.hindexer.haction-manager.hadmin-state.hcompletion.hconstants.hdata-vio.hint-map.hio-submitter.hpacker.hphysical-zone.hslab-depot.hstatistics.htypes.hvdo.hwait-queue.h
Detected Declarations
struct hash_lockstruct hash_zonesenum dedupe_context_stateenum index_stateenum hash_lock_statefunction assert_in_hash_zonefunction change_context_statefunction change_timer_statefunction return_hash_lock_to_poolfunction vdo_get_duplicate_lockfunction hash_lock_keyfunction get_hash_lock_state_namefunction assert_hash_lock_agentfunction set_duplicate_lockfunction dequeue_lock_waiterfunction set_hash_lockfunction exit_hash_lockfunction set_duplicate_locationfunction retire_lock_agentfunction wait_on_hash_lockfunction abort_waiterfunction start_bypassingfunction vdo_clean_failed_hash_lockfunction finish_unlockingfunction unlock_duplicate_pbnfunction start_unlockingfunction release_contextfunction process_update_resultfunction finish_updatingfunction start_updatingfunction finish_dedupingfunction acquire_lockfunction enter_forked_lockfunction fork_hash_lockfunction launch_dedupefunction start_dedupingfunction agentfunction increment_statfunction finish_verifyingfunction blocks_equalfunction verify_callbackfunction uncompress_and_verifyfunction verify_endiofunction start_verifyingfunction finish_lockingfunction acquire_provisional_referencefunction lock_duplicate_pbnfunction start_locking
Annotated Snippet
struct hash_lock {
/* The block hash covered by this lock */
struct uds_record_name hash;
/* When the lock is unused, this list entry allows the lock to be pooled */
struct list_head pool_node;
/*
* A list containing the data VIOs sharing this lock, all having the same record name and
* data block contents, linked by their hash_lock_node fields.
*/
struct list_head duplicate_vios;
/* The number of data_vios sharing this lock instance */
data_vio_count_t reference_count;
/* The maximum value of reference_count in the lifetime of this lock */
data_vio_count_t max_references;
/* The current state of this lock */
enum hash_lock_state state;
/* True if the UDS index should be updated with new advice */
bool update_advice;
/* True if the advice has been verified to be a true duplicate */
bool verified;
/* True if the lock has already accounted for an initial verification */
bool verify_counted;
/* True if this lock is registered in the lock map (cleared on rollover) */
bool registered;
/*
* If verified is false, this is the location of a possible duplicate. If verified is true,
* it is the verified location of a true duplicate.
*/
struct zoned_pbn duplicate;
/* The PBN lock on the block containing the duplicate data */
struct pbn_lock *duplicate_lock;
/* The data_vio designated to act on behalf of the lock */
struct data_vio *agent;
/*
* Other data_vios with data identical to the agent who are currently waiting for the agent
* to get the information they all need to deduplicate--either against each other, or
* against an existing duplicate on disk.
*/
struct vdo_wait_queue waiters;
};
#define LOCK_POOL_CAPACITY MAXIMUM_VDO_USER_VIOS
struct hash_zones {
struct action_manager *manager;
struct uds_parameters parameters;
struct uds_index_session *index_session;
struct ratelimit_state ratelimiter;
atomic64_t timeouts;
atomic64_t dedupe_context_busy;
/* This spinlock protects the state fields and the starting of dedupe requests. */
spinlock_t lock;
/* The fields in the next block are all protected by the lock */
struct vdo_completion completion;
enum index_state index_state;
enum index_state index_target;
struct admin_state state;
bool changing;
bool create_flag;
bool dedupe_flag;
bool error_flag;
u64 reported_timeouts;
/* The number of zones */
zone_count_t zone_count;
/* The hash zones themselves */
struct hash_zone zones[] __counted_by(zone_count);
};
/* These are in milliseconds. */
unsigned int vdo_dedupe_index_timeout_interval = 5000;
unsigned int vdo_dedupe_index_min_timer_interval = 100;
/* Same two variables, in jiffies for easier consumption. */
static u64 vdo_dedupe_index_timeout_jiffies;
static u64 vdo_dedupe_index_min_timer_jiffies;
Annotation
- Immediate include surface: `dedupe.h`, `linux/atomic.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/list.h`, `linux/ratelimit.h`, `linux/spinlock.h`, `linux/timer.h`.
- Detected declarations: `struct hash_lock`, `struct hash_zones`, `enum dedupe_context_state`, `enum index_state`, `enum hash_lock_state`, `function assert_in_hash_zone`, `function change_context_state`, `function change_timer_state`, `function return_hash_lock_to_pool`, `function vdo_get_duplicate_lock`.
- 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.