drivers/md/dm-target.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-target.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-target.c- Extension
.c- Size
- 5781 bytes
- Lines
- 288
- 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.
- 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.hlinux/module.hlinux/init.hlinux/kmod.hlinux/bio.hlinux/dax.h
Detected Declarations
struct io_err_cfunction load_modulefunction dm_put_target_typefunction dm_target_iteratefunction dm_register_targetfunction dm_unregister_targetfunction io_err_get_argsfunction io_err_ctrfunction io_err_dtrfunction io_err_mapfunction io_err_clone_and_map_rqfunction io_err_release_clone_rqfunction io_err_report_zonesfunction io_err_iterate_devicesfunction io_err_io_hintsfunction io_err_dax_direct_accessfunction dm_target_initfunction dm_target_exitexport dm_register_targetexport dm_unregister_target
Annotated Snippet
struct io_err_c {
struct dm_dev *dev;
sector_t start;
};
static int io_err_get_args(struct dm_target *tt, unsigned int argc, char **args)
{
unsigned long long start;
struct io_err_c *ioec;
char dummy;
int ret;
ioec = kmalloc_obj(*ioec);
if (!ioec) {
tt->error = "Cannot allocate io_err context";
return -ENOMEM;
}
ret = -EINVAL;
if (sscanf(args[1], "%llu%c", &start, &dummy) != 1 ||
start != (sector_t)start) {
tt->error = "Invalid device sector";
goto bad;
}
ioec->start = start;
ret = dm_get_device(tt, args[0], dm_table_get_mode(tt->table), &ioec->dev);
if (ret) {
tt->error = "Device lookup failed";
goto bad;
}
tt->private = ioec;
return 0;
bad:
kfree(ioec);
return ret;
}
static int io_err_ctr(struct dm_target *tt, unsigned int argc, char **args)
{
/*
* If we have arguments, assume it is the path to the backing
* block device and its mapping start sector (same as dm-linear).
* In this case, get the device so that we can get its limits.
*/
if (argc == 2) {
int ret = io_err_get_args(tt, argc, args);
if (ret)
return ret;
}
/*
* Return error for discards instead of -EOPNOTSUPP
*/
tt->num_discard_bios = 1;
tt->discards_supported = true;
return 0;
}
static void io_err_dtr(struct dm_target *tt)
{
struct io_err_c *ioec = tt->private;
if (ioec) {
dm_put_device(tt, ioec->dev);
kfree(ioec);
}
}
static int io_err_map(struct dm_target *tt, struct bio *bio)
{
return DM_MAPIO_KILL;
}
static int io_err_clone_and_map_rq(struct dm_target *ti, struct request *rq,
union map_info *map_context,
struct request **clone)
{
return DM_MAPIO_KILL;
}
static void io_err_release_clone_rq(struct request *clone,
union map_info *map_context)
{
Annotation
- Immediate include surface: `dm-core.h`, `linux/module.h`, `linux/init.h`, `linux/kmod.h`, `linux/bio.h`, `linux/dax.h`.
- Detected declarations: `struct io_err_c`, `function load_module`, `function dm_put_target_type`, `function dm_target_iterate`, `function dm_register_target`, `function dm_unregister_target`, `function io_err_get_args`, `function io_err_ctr`, `function io_err_dtr`, `function io_err_map`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: integration 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.