drivers/md/dm-snap-transient.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-snap-transient.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-snap-transient.c- Extension
.c- Size
- 3829 bytes
- Lines
- 159
- 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.
- 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/mm.hlinux/pagemap.hlinux/vmalloc.hlinux/export.hlinux/slab.hlinux/dm-io.h
Detected Declarations
struct transient_cfunction transient_dtrfunction transient_read_metadatafunction transient_prepare_exceptionfunction transient_commit_exceptionfunction transient_usagefunction transient_ctrfunction transient_statusfunction dm_transient_snapshot_initfunction dm_transient_snapshot_exit
Annotated Snippet
struct transient_c {
sector_t next_free;
};
static void transient_dtr(struct dm_exception_store *store)
{
kfree(store->context);
}
static int transient_read_metadata(struct dm_exception_store *store,
int (*callback)(void *callback_context,
chunk_t old, chunk_t new),
void *callback_context)
{
return 0;
}
static int transient_prepare_exception(struct dm_exception_store *store,
struct dm_exception *e)
{
struct transient_c *tc = store->context;
sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev);
if (size < (tc->next_free + store->chunk_size))
return -1;
e->new_chunk = sector_to_chunk(store, tc->next_free);
tc->next_free += store->chunk_size;
return 0;
}
static void transient_commit_exception(struct dm_exception_store *store,
struct dm_exception *e, int valid,
void (*callback)(void *, int success),
void *callback_context)
{
/* Just succeed */
callback(callback_context, valid);
}
static void transient_usage(struct dm_exception_store *store,
sector_t *total_sectors,
sector_t *sectors_allocated,
sector_t *metadata_sectors)
{
*sectors_allocated = ((struct transient_c *) store->context)->next_free;
*total_sectors = get_dev_size(dm_snap_cow(store->snap)->bdev);
*metadata_sectors = 0;
}
static int transient_ctr(struct dm_exception_store *store, char *options)
{
struct transient_c *tc;
tc = kmalloc_obj(struct transient_c);
if (!tc)
return -ENOMEM;
tc->next_free = 0;
store->context = tc;
return 0;
}
static unsigned int transient_status(struct dm_exception_store *store,
status_type_t status, char *result,
unsigned int maxlen)
{
unsigned int sz = 0;
switch (status) {
case STATUSTYPE_INFO:
break;
case STATUSTYPE_TABLE:
DMEMIT(" N %llu", (unsigned long long)store->chunk_size);
break;
case STATUSTYPE_IMA:
*result = '\0';
break;
}
return sz;
}
static struct dm_exception_store_type _transient_type = {
.name = "transient",
.module = THIS_MODULE,
.ctr = transient_ctr,
.dtr = transient_dtr,
Annotation
- Immediate include surface: `dm-exception-store.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/vmalloc.h`, `linux/export.h`, `linux/slab.h`, `linux/dm-io.h`.
- Detected declarations: `struct transient_c`, `function transient_dtr`, `function transient_read_metadata`, `function transient_prepare_exception`, `function transient_commit_exception`, `function transient_usage`, `function transient_ctr`, `function transient_status`, `function dm_transient_snapshot_init`, `function dm_transient_snapshot_exit`.
- Atlas domain: Driver Families / drivers/md.
- 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.