Skip to content

Commit 12fcf66

Browse files
committed
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
Pull MD fixes from Shaohua Li: "Two small patches to fix long-lived raid5 stripe batch bugs, one from Dennis and the other from me" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md: md/raid5: preserve STRIPE_ON_UNPLUG_LIST in break_stripe_batch_list md/raid5: fix a race condition in stripe batch
2 parents 2442086 + 184a09e commit 12fcf66

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/md/raid5.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,21 @@ static void stripe_add_to_batch_list(struct r5conf *conf, struct stripe_head *sh
811811
spin_unlock(&head->batch_head->batch_lock);
812812
goto unlock_out;
813813
}
814+
/*
815+
* We must assign batch_head of this stripe within the
816+
* batch_lock, otherwise clear_batch_ready of batch head
817+
* stripe could clear BATCH_READY bit of this stripe and
818+
* this stripe->batch_head doesn't get assigned, which
819+
* could confuse clear_batch_ready for this stripe
820+
*/
821+
sh->batch_head = head->batch_head;
814822

815823
/*
816824
* at this point, head's BATCH_READY could be cleared, but we
817825
* can still add the stripe to batch list
818826
*/
819827
list_add(&sh->batch_list, &head->batch_list);
820828
spin_unlock(&head->batch_head->batch_lock);
821-
822-
sh->batch_head = head->batch_head;
823829
} else {
824830
head->batch_head = head;
825831
sh->batch_head = head->batch_head;
@@ -4599,7 +4605,8 @@ static void break_stripe_batch_list(struct stripe_head *head_sh,
45994605

46004606
set_mask_bits(&sh->state, ~(STRIPE_EXPAND_SYNC_FLAGS |
46014607
(1 << STRIPE_PREREAD_ACTIVE) |
4602-
(1 << STRIPE_DEGRADED)),
4608+
(1 << STRIPE_DEGRADED) |
4609+
(1 << STRIPE_ON_UNPLUG_LIST)),
46034610
head_sh->state & (1 << STRIPE_INSYNC));
46044611

46054612
sh->check_state = head_sh->check_state;

0 commit comments

Comments
 (0)