]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md/raid5: add some missing locking in handle_failed_stripe.
authorNeilBrown <neilb@suse.de>
Thu, 27 Sep 2012 02:37:29 +0000 (12:37 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 27 Sep 2012 02:37:29 +0000 (12:37 +1000)
We really should hold the stripe_lock while accessing
'toread' else we could race with add_stripe_bio and corrupt
a list.

Reported-by: "Jianpeng Ma" <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid5.c

index 576f796969a766397cd04bc1d5390d5560952939..c09a1aaa0cb7987ada7fd0fd1dfc8ef73a266ef7 100644 (file)
@@ -2593,8 +2593,10 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
                if (!test_bit(R5_Wantfill, &sh->dev[i].flags) &&
                    (!test_bit(R5_Insync, &sh->dev[i].flags) ||
                      test_bit(R5_ReadError, &sh->dev[i].flags))) {
+                       spin_lock_irq(&sh->stripe_lock);
                        bi = sh->dev[i].toread;
                        sh->dev[i].toread = NULL;
+                       spin_unlock_irq(&sh->stripe_lock);
                        if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
                                wake_up(&conf->wait_for_overlap);
                        if (bi) s->to_read--;