drivers/md/md.h
Source file repositories/reference/linux-study-clean/drivers/md/md.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/md.h- Extension
.h- Size
- 35006 bytes
- Lines
- 1104
- 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/blkdev.hlinux/backing-dev.hlinux/badblocks.hlinux/kobject.hlinux/list.hlinux/mm.hlinux/mutex.hlinux/timer.hlinux/wait.hlinux/workqueue.hlinux/raid/md_u.htrace/events/block.h
Detected Declarations
struct md_submodule_headstruct serial_in_rdevstruct md_rdevstruct md_cluster_infostruct md_cluster_operationsstruct serial_infostruct mddevstruct md_personalitystruct md_sysfs_entrystruct md_threadstruct md_io_clonestruct mdu_array_info_sstruct mdu_disk_info_senum md_submodule_typeenum md_submodule_idenum sync_actionenum flag_bitsenum mddev_flagsenum mddev_sb_flagsenum recovery_flagsenum md_ro_statefunction is_badblockfunction rdev_has_badblockfunction md_is_rdwrfunction reshape_interruptedfunction mddev_lockfunction mddev_lock_nointrfunction mddev_trylockfunction sysfs_notify_dirent_safefunction mdnamefunction sysfs_link_rdevfunction sysfs_unlink_rdevfunction safe_put_pagefunction is_rdev_brokenfunction rdev_dec_pendingfunction mddev_is_clusteredfunction mddev_clear_unsupported_flagsfunction mddev_check_write_zeroesfunction mddev_suspend_and_lockfunction mddev_suspend_and_lock_nointrfunction mddev_unlock_and_resumefunction md_cloned_biofunction mddev_is_dmfunction raid_is_456function mddev_trace_remapfunction rdev_blocked
Annotated Snippet
struct md_submodule_head {
enum md_submodule_type type;
enum md_submodule_id id;
const char *name;
struct module *owner;
};
/*
* These flags should really be called "NO_RETRY" rather than
* "FAILFAST" because they don't make any promise about time lapse,
* only about the number of retries, which will be zero.
* REQ_FAILFAST_DRIVER is not included because
* Commit: 4a27446f3e39 ("[SCSI] modify scsi to handle new fail fast flags.")
* seems to suggest that the errors it avoids retrying should usually
* be retried.
*/
#define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT)
/* Status of sync thread. */
enum sync_action {
/*
* Represent by MD_RECOVERY_SYNC, start when:
* 1) after assemble, sync data from first rdev to other copies, this
* must be done first before other sync actions and will only execute
* once;
* 2) resize the array(notice that this is not reshape), sync data for
* the new range;
*/
ACTION_RESYNC,
/*
* Represent by MD_RECOVERY_RECOVER, start when:
* 1) for new replacement, sync data based on the replace rdev or
* available copies from other rdev;
* 2) for new member disk while the array is degraded, sync data from
* other rdev;
* 3) reassemble after power failure or re-add a hot removed rdev, sync
* data from first rdev to other copies based on bitmap;
*/
ACTION_RECOVER,
/*
* Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED |
* MD_RECOVERY_CHECK, start when user echo "check" to sysfs api
* sync_action, used to check if data copies from differenct rdev are
* the same. The number of mismatch sectors will be exported to user
* by sysfs api mismatch_cnt;
*/
ACTION_CHECK,
/*
* Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when
* user echo "repair" to sysfs api sync_action, usually paired with
* ACTION_CHECK, used to force syncing data once user found that there
* are inconsistent data,
*/
ACTION_REPAIR,
/*
* Represent by MD_RECOVERY_RESHAPE, start when new member disk is added
* to the conf, notice that this is different from spares or
* replacement;
*/
ACTION_RESHAPE,
/*
* Represent by MD_RECOVERY_FROZEN, can be set by sysfs api sync_action
* or internal usage like setting the array read-only, will forbid above
* actions.
*/
ACTION_FROZEN,
/*
* All above actions don't match.
*/
ACTION_IDLE,
NR_SYNC_ACTIONS,
};
/*
* The struct embedded in rdev is used to serialize IO.
*/
struct serial_in_rdev {
struct rb_root_cached serial_rb;
spinlock_t serial_lock;
};
/*
* MD's 'extended' device
*/
struct md_rdev {
struct list_head same_set; /* RAID devices within the same set */
sector_t sectors; /* Device size (in 512bytes sectors) */
struct mddev *mddev; /* RAID array if running */
unsigned long last_events; /* IO event timestamp */
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/backing-dev.h`, `linux/badblocks.h`, `linux/kobject.h`, `linux/list.h`, `linux/mm.h`, `linux/mutex.h`, `linux/timer.h`.
- Detected declarations: `struct md_submodule_head`, `struct serial_in_rdev`, `struct md_rdev`, `struct md_cluster_info`, `struct md_cluster_operations`, `struct serial_info`, `struct mddev`, `struct md_personality`, `struct md_sysfs_entry`, `struct md_thread`.
- 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.