drivers/md/dm-table.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-table.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-table.c- Extension
.c- Size
- 55373 bytes
- Lines
- 2232
- 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-core.hdm-rq.hlinux/module.hlinux/vmalloc.hlinux/blkdev.hlinux/blk-integrity.hlinux/namei.hlinux/ctype.hlinux/string.hlinux/slab.hlinux/interrupt.hlinux/mutex.hlinux/delay.hlinux/atomic.hlinux/blk-mq.hlinux/mount.hlinux/dax.h
Detected Declarations
struct dm_crypto_profilestruct dm_wrappedkey_op_argsenum dm_wrappedkey_openum suspend_modefunction Copyrightfunction get_childfunction highfunction setup_btree_indexfunction alloc_targetsfunction dm_table_createfunction free_devicesfunction list_for_each_safefunction dm_table_destroyfunction device_area_is_invalidfunction devicefunction upgrade_modefunction dm_devt_from_pathfunction dm_get_devicefunction dm_set_device_limitsfunction dm_put_devicefunction list_for_each_entryfunction adjoinfunction dm_split_argsfunction dm_set_stacking_limitsfunction validate_hardware_logical_block_alignmentfunction dm_table_add_targetfunction validate_next_argfunction dm_read_argfunction dm_read_arg_groupfunction dm_consume_argsfunction __table_type_bio_basedfunction __table_type_request_basedfunction dm_table_set_typefunction device_not_dax_capablefunction device_not_dax_synchronous_capablefunction dm_table_supports_daxfunction device_is_not_rq_stackablefunction dm_table_determine_typefunction dm_table_get_typefunction dm_table_request_basedfunction dm_table_alloc_md_mempoolsfunction setup_indexesfunction dm_table_build_indexfunction dm_keyslot_evict_callbackfunction dm_keyslot_evictfunction dm_wrappedkey_op_callbackfunction dm_exec_wrappedkey_opfunction dm_derive_sw_secret
Annotated Snippet
struct dm_crypto_profile {
struct blk_crypto_profile profile;
struct mapped_device *md;
};
static int dm_keyslot_evict_callback(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
const struct blk_crypto_key *key = data;
blk_crypto_evict_key(dev->bdev, key);
return 0;
}
/*
* When an inline encryption key is evicted from a device-mapper device, evict
* it from all the underlying devices.
*/
static int dm_keyslot_evict(struct blk_crypto_profile *profile,
const struct blk_crypto_key *key, unsigned int slot)
{
struct mapped_device *md =
container_of(profile, struct dm_crypto_profile, profile)->md;
struct dm_table *t;
int srcu_idx;
t = dm_get_live_table(md, &srcu_idx);
if (!t)
goto put_live_table;
for (unsigned int i = 0; i < t->num_targets; i++) {
struct dm_target *ti = dm_table_get_target(t, i);
if (!ti->type->iterate_devices)
continue;
ti->type->iterate_devices(ti, dm_keyslot_evict_callback,
(void *)key);
}
put_live_table:
dm_put_live_table(md, srcu_idx);
return 0;
}
enum dm_wrappedkey_op {
DERIVE_SW_SECRET,
IMPORT_KEY,
GENERATE_KEY,
PREPARE_KEY,
};
struct dm_wrappedkey_op_args {
enum dm_wrappedkey_op op;
int err;
union {
struct {
const u8 *eph_key;
size_t eph_key_size;
u8 *sw_secret;
} derive_sw_secret;
struct {
const u8 *raw_key;
size_t raw_key_size;
u8 *lt_key;
} import_key;
struct {
u8 *lt_key;
} generate_key;
struct {
const u8 *lt_key;
size_t lt_key_size;
u8 *eph_key;
} prepare_key;
};
};
static int dm_wrappedkey_op_callback(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
struct dm_wrappedkey_op_args *args = data;
struct block_device *bdev = dev->bdev;
struct blk_crypto_profile *profile =
bdev_get_queue(bdev)->crypto_profile;
int err = -EOPNOTSUPP;
switch (args->op) {
case DERIVE_SW_SECRET:
err = blk_crypto_derive_sw_secret(
bdev,
args->derive_sw_secret.eph_key,
Annotation
- Immediate include surface: `dm-core.h`, `dm-rq.h`, `linux/module.h`, `linux/vmalloc.h`, `linux/blkdev.h`, `linux/blk-integrity.h`, `linux/namei.h`, `linux/ctype.h`.
- Detected declarations: `struct dm_crypto_profile`, `struct dm_wrappedkey_op_args`, `enum dm_wrappedkey_op`, `enum suspend_mode`, `function Copyright`, `function get_child`, `function high`, `function setup_btree_index`, `function alloc_targets`, `function dm_table_create`.
- 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.