diff options
author | NeilBrown <neilb@suse.de> | 2011-07-26 05:19:49 +0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-07-26 05:19:49 +0400 |
commit | 83206d66b65118d995c38746f21edc2bb8564b49 (patch) | |
tree | 69e1c082cb33d19a508c764da613e0c6b5ced27b /drivers/md/raid5.c | |
parent | ffd96e35c16a99fdb490cc5723b8e32135ae5883 (diff) | |
download | linux-83206d66b65118d995c38746f21edc2bb8564b49.tar.xz |
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: NeilBrown <neilb@suse.de>
Reviewed-by: Namhyung Kim <namhyung@gmail.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r-- | drivers/md/raid5.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 71480646a459..f2f2ab329690 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -3022,6 +3022,10 @@ static void handle_stripe5(struct stripe_head *sh) sh->reconstruct_state); 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_DELAYED, &sh->state); @@ -3313,6 +3317,10 @@ static void handle_stripe6(struct stripe_head *sh) memset(&s, 0, sizeof(s)); 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_DELAYED, &sh->state); @@ -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); - spin_lock(&sh->lock); - set_bit(STRIPE_SYNCING, &sh->state); - clear_bit(STRIPE_INSYNC, &sh->state); - spin_unlock(&sh->lock); + set_bit(STRIPE_SYNC_REQUESTED, &sh->state); handle_stripe(sh); release_stripe(sh); |