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.

Dependency Surface

Detected Declarations

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

Implementation Notes