drivers/md/dm-delay.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-delay.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-delay.c- Extension
.c- Size
- 10856 bytes
- Lines
- 471
- 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
linux/module.hlinux/init.hlinux/blkdev.hlinux/bio.hlinux/slab.hlinux/kthread.hlinux/delay.hlinux/device-mapper.h
Detected Declarations
struct delay_classstruct delay_cstruct dm_delay_infofunction handle_delayed_timerfunction queue_timeoutfunction delay_is_fastfunction flush_biosfunction flush_delayed_biosfunction flush_worker_fnfunction flush_expired_biosfunction delay_dtrfunction delay_class_ctrfunction delay_ctrfunction delay_biofunction delay_presuspendfunction delay_resumefunction delay_mapfunction delay_report_zonesfunction delay_statusfunction delay_iterate_devices
Annotated Snippet
struct delay_class {
struct dm_dev *dev;
sector_t start;
unsigned int delay;
unsigned int ops;
};
struct delay_c {
struct timer_list delay_timer;
struct mutex process_bios_lock; /* hold while removing bios to be processed from list */
spinlock_t delayed_bios_lock; /* hold on all accesses to delayed_bios list */
struct workqueue_struct *kdelayd_wq;
struct work_struct flush_expired_bios;
struct list_head delayed_bios;
struct task_struct *worker;
unsigned int worker_sleep_us;
bool may_delay;
struct delay_class read;
struct delay_class write;
struct delay_class flush;
int argc;
};
struct dm_delay_info {
struct delay_c *context;
struct delay_class *class;
struct list_head list;
unsigned long expires;
};
static void handle_delayed_timer(struct timer_list *t)
{
struct delay_c *dc = timer_container_of(dc, t, delay_timer);
queue_work(dc->kdelayd_wq, &dc->flush_expired_bios);
}
static void queue_timeout(struct delay_c *dc, unsigned long expires)
{
timer_reduce(&dc->delay_timer, expires);
}
static inline bool delay_is_fast(struct delay_c *dc)
{
return !!dc->worker;
}
static void flush_bios(struct bio *bio)
{
struct bio *n;
while (bio) {
n = bio->bi_next;
bio->bi_next = NULL;
dm_submit_bio_remap(bio, NULL);
bio = n;
}
}
static void flush_delayed_bios(struct delay_c *dc, bool flush_all)
{
struct dm_delay_info *delayed, *next;
struct bio_list flush_bio_list;
LIST_HEAD(local_list);
unsigned long next_expires = 0;
bool start_timer = false;
bio_list_init(&flush_bio_list);
mutex_lock(&dc->process_bios_lock);
spin_lock(&dc->delayed_bios_lock);
list_replace_init(&dc->delayed_bios, &local_list);
spin_unlock(&dc->delayed_bios_lock);
list_for_each_entry_safe(delayed, next, &local_list, list) {
cond_resched();
if (flush_all || time_after_eq(jiffies, delayed->expires)) {
struct bio *bio = dm_bio_from_per_bio_data(delayed,
sizeof(struct dm_delay_info));
list_del(&delayed->list);
bio_list_add(&flush_bio_list, bio);
delayed->class->ops--;
continue;
}
if (!delay_is_fast(dc)) {
if (!start_timer) {
start_timer = true;
next_expires = delayed->expires;
} else {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/blkdev.h`, `linux/bio.h`, `linux/slab.h`, `linux/kthread.h`, `linux/delay.h`, `linux/device-mapper.h`.
- Detected declarations: `struct delay_class`, `struct delay_c`, `struct dm_delay_info`, `function handle_delayed_timer`, `function queue_timeout`, `function delay_is_fast`, `function flush_bios`, `function flush_delayed_bios`, `function flush_worker_fn`, `function flush_expired_bios`.
- 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.