drivers/md/dm-snap-persistent.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-snap-persistent.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-snap-persistent.c- Extension
.c- Size
- 23122 bytes
- Lines
- 981
- 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.
- 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
dm-exception-store.hlinux/ctype.hlinux/mm.hlinux/pagemap.hlinux/vmalloc.hlinux/export.hlinux/slab.hlinux/dm-io.hlinux/dm-bufio.h
Detected Declarations
struct disk_headerstruct disk_exceptionstruct core_exceptionstruct commit_callbackstruct pstorestruct mdata_reqfunction alloc_areafunction free_areafunction do_metadatafunction chunk_iofunction area_locationfunction skip_metadatafunction area_iofunction zero_memory_areafunction zero_disk_areafunction read_headerfunction sizefunction write_headerfunction read_exceptionfunction write_exceptionfunction clear_exceptionfunction insert_exceptionsfunction read_exceptionsfunction persistent_usagefunction persistent_dtrfunction persistent_read_metadatafunction persistent_prepare_exceptionfunction persistent_commit_exceptionfunction persistent_prepare_mergefunction persistent_commit_mergefunction persistent_drop_snapshotfunction persistent_ctrfunction persistent_statusfunction dm_persistent_snapshot_initfunction dm_persistent_snapshot_exit
Annotated Snippet
struct disk_header {
__le32 magic;
/*
* Is this snapshot valid. There is no way of recovering
* an invalid snapshot.
*/
__le32 valid;
/*
* Simple, incrementing version. no backward
* compatibility.
*/
__le32 version;
/* In sectors */
__le32 chunk_size;
} __packed;
struct disk_exception {
__le64 old_chunk;
__le64 new_chunk;
} __packed;
struct core_exception {
uint64_t old_chunk;
uint64_t new_chunk;
};
struct commit_callback {
void (*callback)(void *ref, int success);
void *context;
};
/*
* The top level structure for a persistent exception store.
*/
struct pstore {
struct dm_exception_store *store;
int version;
int valid;
uint32_t exceptions_per_area;
/*
* Now that we have an asynchronous kcopyd there is no
* need for large chunk sizes, so it wont hurt to have a
* whole chunks worth of metadata in memory at once.
*/
void *area;
/*
* An area of zeros used to clear the next area.
*/
void *zero_area;
/*
* An area used for header. The header can be written
* concurrently with metadata (when invalidating the snapshot),
* so it needs a separate buffer.
*/
void *header_area;
/*
* Used to keep track of which metadata area the data in
* 'chunk' refers to.
*/
chunk_t current_area;
/*
* The next free chunk for an exception.
*
* When creating exceptions, all the chunks here and above are
* free. It holds the next chunk to be allocated. On rare
* occasions (e.g. after a system crash) holes can be left in
* the exception store because chunks can be committed out of
* order.
*
* When merging exceptions, it does not necessarily mean all the
* chunks here and above are free. It holds the value it would
* have held if all chunks had been committed in order of
* allocation. Consequently the value may occasionally be
* slightly too low, but since it's only used for 'status' and
* it can never reach its minimum value too early this doesn't
* matter.
*/
chunk_t next_free;
/*
* The index of next free exception in the current
Annotation
- Immediate include surface: `dm-exception-store.h`, `linux/ctype.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/vmalloc.h`, `linux/export.h`, `linux/slab.h`, `linux/dm-io.h`.
- Detected declarations: `struct disk_header`, `struct disk_exception`, `struct core_exception`, `struct commit_callback`, `struct pstore`, `struct mdata_req`, `function alloc_area`, `function free_area`, `function do_metadata`, `function chunk_io`.
- 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.