Commit 83206d66 authored by NeilBrown's avatar NeilBrown

md/raid5: Remove use of sh->lock in sync_request

This is the start of a series of patches to remove sh->lock.

sync_request takes sh->lock before setting STRIPE_SYNCING to ensure
there is no race with testing it in handle_stripe[56].

Instead, use a new flag STRIPE_SYNC_REQUESTED and test it early
in handle_stripe[56] (after getting the same lock) and perform the
same set/clear operations if it was set.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Reviewed-by: default avatarNamhyung Kim <namhyung@gmail.com>
parent ffd96e35
...@@ -3022,6 +3022,10 @@ static void handle_stripe5(struct stripe_head *sh) ...@@ -3022,6 +3022,10 @@ static void handle_stripe5(struct stripe_head *sh)
sh->reconstruct_state); sh->reconstruct_state);
spin_lock(&sh->lock); spin_lock(&sh->lock);
if (test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
set_bit(STRIPE_SYNCING, &sh->state);
clear_bit(STRIPE_INSYNC, &sh->state);
}
clear_bit(STRIPE_HANDLE, &sh->state); clear_bit(STRIPE_HANDLE, &sh->state);
clear_bit(STRIPE_DELAYED, &sh->state); clear_bit(STRIPE_DELAYED, &sh->state);
...@@ -3313,6 +3317,10 @@ static void handle_stripe6(struct stripe_head *sh) ...@@ -3313,6 +3317,10 @@ static void handle_stripe6(struct stripe_head *sh)
memset(&s, 0, sizeof(s)); memset(&s, 0, sizeof(s));
spin_lock(&sh->lock); spin_lock(&sh->lock);
if (test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
set_bit(STRIPE_SYNCING, &sh->state);
clear_bit(STRIPE_INSYNC, &sh->state);
}
clear_bit(STRIPE_HANDLE, &sh->state); clear_bit(STRIPE_HANDLE, &sh->state);
clear_bit(STRIPE_DELAYED, &sh->state); clear_bit(STRIPE_DELAYED, &sh->state);
...@@ -4373,10 +4381,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski ...@@ -4373,10 +4381,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded); bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
spin_lock(&sh->lock); set_bit(STRIPE_SYNC_REQUESTED, &sh->state);
set_bit(STRIPE_SYNCING, &sh->state);
clear_bit(STRIPE_INSYNC, &sh->state);
spin_unlock(&sh->lock);
handle_stripe(sh); handle_stripe(sh);
release_stripe(sh); release_stripe(sh);
......
...@@ -289,21 +289,24 @@ struct r6_state { ...@@ -289,21 +289,24 @@ struct r6_state {
/* /*
* Stripe state * Stripe state
*/ */
#define STRIPE_HANDLE 2 enum {
#define STRIPE_SYNCING 3 STRIPE_HANDLE,
#define STRIPE_INSYNC 4 STRIPE_SYNC_REQUESTED,
#define STRIPE_PREREAD_ACTIVE 5 STRIPE_SYNCING,
#define STRIPE_DELAYED 6 STRIPE_INSYNC,
#define STRIPE_DEGRADED 7 STRIPE_PREREAD_ACTIVE,
#define STRIPE_BIT_DELAY 8 STRIPE_DELAYED,
#define STRIPE_EXPANDING 9 STRIPE_DEGRADED,
#define STRIPE_EXPAND_SOURCE 10 STRIPE_BIT_DELAY,
#define STRIPE_EXPAND_READY 11 STRIPE_EXPANDING,
#define STRIPE_IO_STARTED 12 /* do not count towards 'bypass_count' */ STRIPE_EXPAND_SOURCE,
#define STRIPE_FULL_WRITE 13 /* all blocks are set to be overwritten */ STRIPE_EXPAND_READY,
#define STRIPE_BIOFILL_RUN 14 STRIPE_IO_STARTED, /* do not count towards 'bypass_count' */
#define STRIPE_COMPUTE_RUN 15 STRIPE_FULL_WRITE, /* all blocks are set to be overwritten */
#define STRIPE_OPS_REQ_PENDING 16 STRIPE_BIOFILL_RUN,
STRIPE_COMPUTE_RUN,
STRIPE_OPS_REQ_PENDING,
};
/* /*
* Operation request flags * Operation request flags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment