Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _RAID10_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _RAID10_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) /* Note: raid10_info.rdev can be set to NULL asynchronously by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * raid10_remove_disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * There are three safe ways to access raid10_info.rdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * 1/ when holding mddev->reconfig_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * 2/ when resync/recovery/reshape is known to be happening - i.e. in code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *    that is called as part of performing resync/recovery/reshape.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * 3/ while holding rcu_read_lock(), use rcu_dereference to get the pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *    and if it is non-NULL, increment rdev->nr_pending before dropping the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *    RCU lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * When .rdev is set to NULL, the nr_pending count checked again and if it has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * been incremented, the pointer is put back in .rdev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct raid10_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	struct md_rdev	*rdev, *replacement;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	sector_t	head_position;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	int		recovery_disabled;	/* matches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 						 * mddev->recovery_disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 						 * when we shouldn't try
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 						 * recovering this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 						 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct r10conf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct mddev		*mddev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct raid10_info	*mirrors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct raid10_info	*mirrors_new, *mirrors_old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	spinlock_t		device_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	/* geometry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct geom {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		int		raid_disks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		int		near_copies;  /* number of copies laid out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 					       * raid0 style */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		int		far_copies;   /* number of copies laid out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 					       * at large strides across drives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 					       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		int		far_offset;   /* far_copies are offset by 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 					       * stripe instead of many
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 					       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		sector_t	stride;	      /* distance between far copies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 					       * This is size / far_copies unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 					       * far_offset, in which case it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 					       * 1 stripe.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 					       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		int             far_set_size; /* The number of devices in a set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 					       * where a 'set' are devices that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 					       * contain far/offset copies of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 					       * each other.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 					       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		int		chunk_shift; /* shift from chunks to sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		sector_t	chunk_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	} prev, geo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int			copies;	      /* near_copies * far_copies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 					       * must be <= raid_disks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 					       */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	sector_t		dev_sectors;  /* temp copy of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 					       * mddev->dev_sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	sector_t		reshape_progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	sector_t		reshape_safe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	unsigned long		reshape_checkpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	sector_t		offset_diff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct list_head	retry_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	/* A separate list of r1bio which just need raid_end_bio_io called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 * This mustn't happen for writes which had any errors if the superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	 * needs to be written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct list_head	bio_end_io_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/* queue pending writes and submit them on unplug */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	struct bio_list		pending_bio_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int			pending_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	spinlock_t		resync_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	atomic_t		nr_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int			nr_waiting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int			nr_queued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	int			barrier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int			array_freeze_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	sector_t		next_resync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	int			fullsync;  /* set to 1 if a full sync is needed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 					    * (fresh device added).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 					    * Cleared when a sync completes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 					    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int			have_replacement; /* There is at least one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 						   * replacement device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 						   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	wait_queue_head_t	wait_barrier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	mempool_t		r10bio_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	mempool_t		r10buf_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct page		*tmppage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct bio_set		bio_split;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	/* When taking over an array from a different personality, we store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 * the new thread here until we fully activate the array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct md_thread	*thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	 * Keep track of cluster resync window to send to other nodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	sector_t		cluster_sync_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	sector_t		cluster_sync_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * this is our 'private' RAID10 bio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * it contains information about what kind of IO operations were started
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * for this RAID10 operation, and about their status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct r10bio {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	atomic_t		remaining; /* 'have we finished' count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 					    * used from IRQ handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 					    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	sector_t		sector;	/* virtual sector number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	int			sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	unsigned long		state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct mddev		*mddev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * original bio going to /dev/mdx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct bio		*master_bio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	 * if the IO is in READ direction, then this is where we read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	int			read_slot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	struct list_head	retry_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 * if the IO is in WRITE direction, then multiple bios are used,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 * one for each copy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	 * When resyncing we also use one for each copy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	 * When reconstructing, we use 2 bios, one for read, one for write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	 * We choose the number when they are allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	 * We sometimes need an extra bio to write to the replacement.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct r10dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		struct bio	*bio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			struct bio	*repl_bio; /* used for resync and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 						    * writes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			struct md_rdev	*rdev;	   /* used for reads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 						    * (read_slot >= 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		sector_t	addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		int		devnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	} devs[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* bits for r10bio.state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) enum r10bio_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	R10BIO_Uptodate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	R10BIO_IsSync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	R10BIO_IsRecover,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	R10BIO_IsReshape,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	R10BIO_Degraded,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* Set ReadError on bios that experience a read error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * so that raid10d knows what to do with them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	R10BIO_ReadError,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* If a write for this request means we can clear some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * known-bad-block records, we set this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	R10BIO_MadeGood,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	R10BIO_WriteError,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* During a reshape we might be performing IO on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * 'previous' part of the array, in which case this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * flag is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	R10BIO_Previous,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* failfast devices did receive failfast requests. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	R10BIO_FailFast,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #endif