drivers/md/persistent-data/dm-transaction-manager.c
Source file repositories/reference/linux-study-clean/drivers/md/persistent-data/dm-transaction-manager.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/persistent-data/dm-transaction-manager.c- Extension
.c- Size
- 11449 bytes
- Lines
- 542
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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-transaction-manager.hdm-space-map.hdm-space-map-disk.hdm-space-map-metadata.hdm-persistent-data-internal.hlinux/export.hlinux/mutex.hlinux/hash.hlinux/rbtree.hlinux/slab.hlinux/device-mapper.h
Detected Declarations
struct prefetch_setstruct shadow_infostruct dm_transaction_managerfunction prefetch_hashfunction prefetch_wipefunction prefetch_initfunction prefetch_addfunction prefetch_issuefunction is_shadowfunction insert_shadowfunction wipe_shadow_tablefunction dm_tm_destroyfunction dm_tm_pre_commitfunction dm_tm_commitfunction dm_tm_new_blockfunction __shadow_blockfunction dm_tm_shadow_blockfunction dm_tm_read_lockfunction dm_tm_unlockfunction dm_tm_incfunction dm_tm_inc_rangefunction dm_tm_decfunction dm_tm_dec_rangefunction dm_tm_with_runsfunction dm_tm_reffunction dm_tm_block_is_sharedfunction dm_tm_issue_prefetchesfunction dm_tm_create_internalfunction dm_tm_create_with_smfunction dm_tm_open_with_smexport dm_tm_create_non_blocking_cloneexport dm_tm_destroyexport dm_tm_pre_commitexport dm_tm_commitexport dm_tm_shadow_blockexport dm_tm_read_lockexport dm_tm_unlockexport dm_tm_incexport dm_tm_inc_rangeexport dm_tm_decexport dm_tm_dec_rangeexport dm_tm_with_runsexport dm_tm_issue_prefetchesexport dm_tm_create_with_smexport dm_tm_open_with_sm
Annotated Snippet
struct prefetch_set {
struct mutex lock;
dm_block_t blocks[PREFETCH_SIZE];
};
static unsigned int prefetch_hash(dm_block_t b)
{
return hash_64(b, PREFETCH_BITS);
}
static void prefetch_wipe(struct prefetch_set *p)
{
unsigned int i;
for (i = 0; i < PREFETCH_SIZE; i++)
p->blocks[i] = PREFETCH_SENTINEL;
}
static void prefetch_init(struct prefetch_set *p)
{
mutex_init(&p->lock);
prefetch_wipe(p);
}
static void prefetch_add(struct prefetch_set *p, dm_block_t b)
{
unsigned int h = prefetch_hash(b);
mutex_lock(&p->lock);
if (p->blocks[h] == PREFETCH_SENTINEL)
p->blocks[h] = b;
mutex_unlock(&p->lock);
}
static void prefetch_issue(struct prefetch_set *p, struct dm_block_manager *bm)
{
unsigned int i;
mutex_lock(&p->lock);
for (i = 0; i < PREFETCH_SIZE; i++)
if (p->blocks[i] != PREFETCH_SENTINEL) {
dm_bm_prefetch(bm, p->blocks[i]);
p->blocks[i] = PREFETCH_SENTINEL;
}
mutex_unlock(&p->lock);
}
/*----------------------------------------------------------------*/
struct shadow_info {
struct rb_node node;
dm_block_t where;
};
/*
* It would be nice if we scaled with the size of transaction.
*/
#define DM_HASH_SIZE 256
#define DM_HASH_MASK (DM_HASH_SIZE - 1)
struct dm_transaction_manager {
int is_clone;
struct dm_transaction_manager *real;
struct dm_block_manager *bm;
struct dm_space_map *sm;
spinlock_t lock;
struct rb_root buckets[DM_HASH_SIZE];
struct prefetch_set prefetches;
};
/*----------------------------------------------------------------*/
static int is_shadow(struct dm_transaction_manager *tm, dm_block_t b)
{
int r = 0;
unsigned int bucket = dm_hash_block(b, DM_HASH_MASK);
struct rb_node **node;
spin_lock(&tm->lock);
node = &tm->buckets[bucket].rb_node;
while (*node) {
struct shadow_info *si =
rb_entry(*node, struct shadow_info, node);
if (b == si->where) {
Annotation
- Immediate include surface: `dm-transaction-manager.h`, `dm-space-map.h`, `dm-space-map-disk.h`, `dm-space-map-metadata.h`, `dm-persistent-data-internal.h`, `linux/export.h`, `linux/mutex.h`, `linux/hash.h`.
- Detected declarations: `struct prefetch_set`, `struct shadow_info`, `struct dm_transaction_manager`, `function prefetch_hash`, `function prefetch_wipe`, `function prefetch_init`, `function prefetch_add`, `function prefetch_issue`, `function is_shadow`, `function insert_shadow`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: integration 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.