drivers/md/dm-io-tracker.h
Source file repositories/reference/linux-study-clean/drivers/md/dm-io-tracker.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-io-tracker.h- Extension
.h- Size
- 1574 bytes
- Lines
- 83
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/jiffies.h
Detected Declarations
struct dm_io_trackerfunction dm_iot_initfunction dm_iot_idle_forfunction dm_iot_idle_timefunction dm_iot_io_beginfunction dm_iot_io_end
Annotated Snippet
struct dm_io_tracker {
spinlock_t lock;
/*
* Sectors of in-flight IO.
*/
sector_t in_flight;
/*
* The time, in jiffies, when this device became idle
* (if it is indeed idle).
*/
unsigned long idle_time;
unsigned long last_update_time;
};
static inline void dm_iot_init(struct dm_io_tracker *iot)
{
spin_lock_init(&iot->lock);
iot->in_flight = 0ul;
iot->idle_time = 0ul;
iot->last_update_time = jiffies;
}
static inline bool dm_iot_idle_for(struct dm_io_tracker *iot, unsigned long j)
{
bool r = false;
spin_lock_irq(&iot->lock);
if (!iot->in_flight)
r = time_after(jiffies, iot->idle_time + j);
spin_unlock_irq(&iot->lock);
return r;
}
static inline unsigned long dm_iot_idle_time(struct dm_io_tracker *iot)
{
unsigned long r = 0;
spin_lock_irq(&iot->lock);
if (!iot->in_flight)
r = jiffies - iot->idle_time;
spin_unlock_irq(&iot->lock);
return r;
}
static inline void dm_iot_io_begin(struct dm_io_tracker *iot, sector_t len)
{
spin_lock_irq(&iot->lock);
iot->in_flight += len;
spin_unlock_irq(&iot->lock);
}
static inline void dm_iot_io_end(struct dm_io_tracker *iot, sector_t len)
{
unsigned long flags;
if (!len)
return;
spin_lock_irqsave(&iot->lock, flags);
iot->in_flight -= len;
if (!iot->in_flight)
iot->idle_time = jiffies;
spin_unlock_irqrestore(&iot->lock, flags);
}
#endif
Annotation
- Immediate include surface: `linux/jiffies.h`.
- Detected declarations: `struct dm_io_tracker`, `function dm_iot_init`, `function dm_iot_idle_for`, `function dm_iot_idle_time`, `function dm_iot_io_begin`, `function dm_iot_io_end`.
- 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.