drivers/md/dm-stripe.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-stripe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-stripe.c- Extension
.c- Size
- 12682 bytes
- Lines
- 517
- 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.hlinux/device-mapper.hlinux/module.hlinux/init.hlinux/blkdev.hlinux/bio.hlinux/dax.hlinux/slab.hlinux/log2.h
Detected Declarations
struct stripestruct stripe_cfunction trigger_eventfunction get_stripefunction stripe_ctrfunction stripe_dtrfunction stripe_map_sectorfunction stripe_map_range_sectorfunction stripe_map_rangefunction stripe_mapfunction unlikelyfunction stripe_dax_direct_accessfunction stripe_dax_zero_page_rangefunction stripe_dax_recovery_writefunction stripe_statusfunction stripe_end_iofunction stripe_iterate_devicesfunction stripe_io_hintsfunction dm_stripe_initfunction dm_stripe_exit
Annotated Snippet
struct stripe {
struct dm_dev *dev;
sector_t physical_start;
atomic_t error_count;
};
struct stripe_c {
uint32_t stripes;
int stripes_shift;
/* The size of this target / num. stripes */
sector_t stripe_width;
uint32_t chunk_size;
int chunk_size_shift;
/* Needed for handling events */
struct dm_target *ti;
/* Work struct used for triggering events*/
struct work_struct trigger_event;
struct stripe stripe[] __counted_by(stripes);
};
/*
* An event is triggered whenever a drive
* drops out of a stripe volume.
*/
static void trigger_event(struct work_struct *work)
{
struct stripe_c *sc = container_of(work, struct stripe_c,
trigger_event);
dm_table_event(sc->ti->table);
}
/*
* Parse a single <dev> <sector> pair
*/
static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
unsigned int stripe, char **argv)
{
unsigned long long start;
char dummy;
int ret;
if (sscanf(argv[1], "%llu%c", &start, &dummy) != 1)
return -EINVAL;
ret = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
&sc->stripe[stripe].dev);
if (ret)
return ret;
sc->stripe[stripe].physical_start = start;
return 0;
}
/*
* Construct a striped mapping.
* <number of stripes> <chunk size> [<dev_path> <offset>]+
*/
static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct stripe_c *sc;
sector_t width, tmp_len;
uint32_t stripes;
uint32_t chunk_size;
int r;
unsigned int i;
if (argc < 2) {
ti->error = "Not enough arguments";
return -EINVAL;
}
if (kstrtouint(argv[0], 10, &stripes) || !stripes) {
ti->error = "Invalid stripe count";
return -EINVAL;
}
if (kstrtouint(argv[1], 10, &chunk_size) || !chunk_size) {
ti->error = "Invalid chunk_size";
return -EINVAL;
}
width = ti->len;
if (sector_div(width, stripes)) {
Annotation
- Immediate include surface: `dm.h`, `linux/device-mapper.h`, `linux/module.h`, `linux/init.h`, `linux/blkdev.h`, `linux/bio.h`, `linux/dax.h`, `linux/slab.h`.
- Detected declarations: `struct stripe`, `struct stripe_c`, `function trigger_event`, `function get_stripe`, `function stripe_ctr`, `function stripe_dtr`, `function stripe_map_sector`, `function stripe_map_range_sector`, `function stripe_map_range`, `function stripe_map`.
- 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.