drivers/md/md-llbitmap.c
Source file repositories/reference/linux-study-clean/drivers/md/md-llbitmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/md-llbitmap.c- Extension
.c- Size
- 50666 bytes
- Lines
- 1811
- 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/blkdev.hlinux/module.hlinux/errno.hlinux/slab.hlinux/init.hlinux/timer.hlinux/sched.hlinux/list.hlinux/file.hlinux/seq_file.htrace/events/block.hmd.hmd-bitmap.h
Detected Declarations
struct llbitmap_page_ctlstruct llbitmapstruct llbitmap_unplug_workenum llbitmap_stateenum llbitmap_actionenum llbitmap_page_statefunction llbitmap_readfunction llbitmap_infect_dirty_bitsfunction llbitmap_set_page_dirtyfunction llbitmap_writefunction rdev_for_eachfunction llbitmap_write_pagefunction rdev_for_eachfunction active_releasefunction llbitmap_free_pagesfunction llbitmap_cache_pagesfunction llbitmap_all_disks_support_wzeroes_unmapfunction rdev_for_eachfunction llbitmap_zero_all_disksfunction rdev_for_eachfunction llbitmap_init_statefunction llbitmap_all_disks_support_wzeroes_unmapfunction llbitmap_state_machinefunction llbitmap_raise_barrierfunction llbitmap_release_barrierfunction llbitmap_suspend_timeoutfunction llbitmap_resumefunction llbitmap_check_supportfunction llbitmap_initfunction llbitmap_read_sbfunction llbitmap_pending_timer_fnfunction md_llbitmap_daemon_fnfunction llbitmap_createfunction llbitmap_resizefunction llbitmap_loadfunction llbitmap_destroyfunction llbitmap_start_writefunction llbitmap_end_writefunction llbitmap_start_discardfunction llbitmap_end_discardfunction llbitmap_unplug_fnfunction llbitmap_dirtyfunction llbitmap_unplugfunction __llbitmap_flushfunction llbitmap_flushfunction llbitmap_blocks_syncedfunction llbitmap_skip_sync_blocksfunction llbitmap_start_sync
Annotated Snippet
struct llbitmap_page_ctl {
char *state;
struct page *page;
unsigned long expire;
unsigned long flags;
wait_queue_head_t wait;
struct percpu_ref active;
/* Per block size dirty state, maximum 64k page / 1 sector = 128 */
unsigned long dirty[];
};
struct llbitmap {
struct mddev *mddev;
struct llbitmap_page_ctl **pctl;
unsigned int nr_pages;
unsigned int io_size;
unsigned int blocks_per_page;
/* shift of one chunk */
unsigned long chunkshift;
/* size of one chunk in sector */
unsigned long chunksize;
/* total number of chunks */
unsigned long chunks;
unsigned long last_end_sync;
/*
* time in seconds that dirty bits will be cleared if the page is not
* accessed.
*/
unsigned long barrier_idle;
/* fires on first BitDirty state */
struct timer_list pending_timer;
struct work_struct daemon_work;
unsigned long flags;
__u64 events_cleared;
/* for slow disks */
atomic_t behind_writes;
wait_queue_head_t behind_wait;
};
struct llbitmap_unplug_work {
struct work_struct work;
struct llbitmap *llbitmap;
struct completion *done;
};
static struct workqueue_struct *md_llbitmap_io_wq;
static struct workqueue_struct *md_llbitmap_unplug_wq;
static char state_machine[BitStateCount][BitmapActionCount] = {
[BitUnwritten] = {
[BitmapActionStartwrite] = BitDirty,
[BitmapActionStartsync] = BitNone,
[BitmapActionEndsync] = BitNone,
[BitmapActionAbortsync] = BitNone,
[BitmapActionReload] = BitNone,
[BitmapActionDaemon] = BitNone,
[BitmapActionDiscard] = BitNone,
[BitmapActionStale] = BitNone,
[BitmapActionProactiveSync] = BitNeedSyncUnwritten,
[BitmapActionClearUnwritten] = BitNone,
},
[BitClean] = {
[BitmapActionStartwrite] = BitDirty,
[BitmapActionStartsync] = BitNone,
[BitmapActionEndsync] = BitNone,
[BitmapActionAbortsync] = BitNone,
[BitmapActionReload] = BitNone,
[BitmapActionDaemon] = BitNone,
[BitmapActionDiscard] = BitUnwritten,
[BitmapActionStale] = BitNeedSync,
[BitmapActionProactiveSync] = BitNone,
[BitmapActionClearUnwritten] = BitNone,
},
[BitDirty] = {
[BitmapActionStartwrite] = BitNone,
[BitmapActionStartsync] = BitNone,
[BitmapActionEndsync] = BitNone,
[BitmapActionAbortsync] = BitNone,
[BitmapActionReload] = BitNeedSync,
[BitmapActionDaemon] = BitClean,
[BitmapActionDiscard] = BitUnwritten,
[BitmapActionStale] = BitNeedSync,
[BitmapActionProactiveSync] = BitNone,
[BitmapActionClearUnwritten] = BitNone,
},
[BitNeedSync] = {
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/module.h`, `linux/errno.h`, `linux/slab.h`, `linux/init.h`, `linux/timer.h`, `linux/sched.h`, `linux/list.h`.
- Detected declarations: `struct llbitmap_page_ctl`, `struct llbitmap`, `struct llbitmap_unplug_work`, `enum llbitmap_state`, `enum llbitmap_action`, `enum llbitmap_page_state`, `function llbitmap_read`, `function llbitmap_infect_dirty_bits`, `function llbitmap_set_page_dirty`, `function llbitmap_write`.
- 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.