Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4456856 authored by Dan Williams's avatar Dan Williams
Browse files

raid5: refactor handle_stripe5 and handle_stripe6 (v3)



handle_stripe5 and handle_stripe6 have very deep logic paths handling the
various states of a stripe_head.  By introducing the 'stripe_head_state'
and 'r6_state' objects, large portions of the logic can be moved to
sub-routines.

'struct stripe_head_state' consumes all of the automatic variables that previously
stood alone in handle_stripe5,6.  'struct r6_state' contains the handle_stripe6
specific variables like p_failed and q_failed.

One of the nice side effects of the 'stripe_head_state' change is that it
allows for further reductions in code duplication between raid5 and raid6.
The following new routines are shared between raid5 and raid6:

	handle_completed_write_requests
	handle_requests_to_failed_array
	handle_stripe_expansion

Changes:
* v2: fixed 'conf->raid_disk-1' for the raid6 'handle_stripe_expansion' path
* v3: removed the unused 'dirty' field from struct stripe_head_state
* v3: coalesced open coded bi_end_io routines into return_io()

Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Acked-By: default avatarNeilBrown <neilb@suse.de>
parent 9bc89cd8
Loading
Loading
Loading
Loading
+740 −786

File changed.

Preview size limit exceeded, changes collapsed.

+16 −0
Original line number Original line Diff line number Diff line
@@ -145,6 +145,22 @@ struct stripe_head {
		unsigned long	flags;
		unsigned long	flags;
	} dev[1]; /* allocated with extra space depending of RAID geometry */
	} dev[1]; /* allocated with extra space depending of RAID geometry */
};
};

/* stripe_head_state - collects and tracks the dynamic state of a stripe_head
 *     for handle_stripe.  It is only valid under spin_lock(sh->lock);
 */
struct stripe_head_state {
	int syncing, expanding, expanded;
	int locked, uptodate, to_read, to_write, failed, written;
	int non_overwrite;
	int failed_num;
};

/* r6_state - extra state data only relevant to r6 */
struct r6_state {
	int p_failed, q_failed, qd_idx, failed_num[2];
};

/* Flags */
/* Flags */
#define	R5_UPTODATE	0	/* page contains current data */
#define	R5_UPTODATE	0	/* page contains current data */
#define	R5_LOCKED	1	/* IO has been submitted on "req" */
#define	R5_LOCKED	1	/* IO has been submitted on "req" */