drivers/md/md.c
Source file repositories/reference/linux-study-clean/drivers/md/md.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/md.c- Extension
.c- Size
- 289716 bytes
- Lines
- 11020
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/sched/mm.hlinux/sched/signal.hlinux/kthread.hlinux/blkdev.hlinux/blk-integrity.hlinux/badblocks.hlinux/sysctl.hlinux/seq_file.hlinux/fs.hlinux/poll.hlinux/ctype.hlinux/string.hlinux/hdreg.hlinux/proc_fs.hlinux/random.hlinux/major.hlinux/module.hlinux/reboot.hlinux/file.hlinux/compat.hlinux/delay.hlinux/raid/md_p.hlinux/raid/md_u.hlinux/raid/detect.hlinux/slab.hlinux/percpu-refcount.hlinux/part_stat.hmd.hmd-bitmap.hmd-cluster.h
Detected Declarations
struct super_typestruct rdev_sysfs_entrystruct detected_devices_nodeenum array_statefunction speed_minfunction speed_maxfunction sync_io_depthfunction rdev_uninit_serialfunction rdevs_uninit_serialfunction rdev_init_serialfunction rdevs_init_serialfunction rdev_for_eachfunction rdev_need_serialfunction rdevfunction rdevfunction rdev_for_eachfunction md_new_eventfunction is_md_suspendedfunction is_suspendedfunction md_handle_requestfunction md_submit_biofunction mddev_suspendfunction __mddev_resumefunction mddev_resumefunction mddev_set_closing_and_sync_blockdevfunction bio_chain_endiofunction md_flush_requestfunction rdev_for_eachfunction __mddev_putfunction mddev_put_lockedfunction mddev_putfunction active_io_releasefunction no_opfunction md_bitmap_sysfs_delfunction mddev_set_bitmap_ops_nosysfsfunction mddev_initfunction mddev_destroyfunction mddev_alloc_unitfunction mddev_freefunction mddev_unlockfunction list_for_each_entry_safefunction put_persfunction calc_dev_sboffsetfunction alloc_disk_sbfunction md_rdev_clearfunction super_writtenfunction md_write_metadatafunction md_super_wait
Annotated Snippet
subsys_initcall(md_init);
module_exit(md_exit)
static int get_ro(char *buffer, const struct kernel_param *kp)
{
return sprintf(buffer, "%d\n", start_readonly);
}
static int set_ro(const char *val, const struct kernel_param *kp)
{
return kstrtouint(val, 10, (unsigned int *)&start_readonly);
}
module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR);
module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR);
module_param_call(new_array, add_named_array, NULL, NULL, S_IWUSR);
module_param(create_on_open, bool, S_IRUSR|S_IWUSR);
module_param(legacy_async_del_gendisk, bool, 0600);
module_param(check_new_feature, bool, 0600);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MD RAID framework");
MODULE_ALIAS("md");
MODULE_ALIAS_BLOCKDEV_MAJOR(MD_MAJOR);
Annotation
- Immediate include surface: `linux/sched/mm.h`, `linux/sched/signal.h`, `linux/kthread.h`, `linux/blkdev.h`, `linux/blk-integrity.h`, `linux/badblocks.h`, `linux/sysctl.h`, `linux/seq_file.h`.
- Detected declarations: `struct super_type`, `struct rdev_sysfs_entry`, `struct detected_devices_node`, `enum array_state`, `function speed_min`, `function speed_max`, `function sync_io_depth`, `function rdev_uninit_serial`, `function rdevs_uninit_serial`, `function rdev_init_serial`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.