]> git.karo-electronics.de Git - linux-beck.git/commitdiff
md/raid5: add rcu protection to rdev accesses in want_replace
authorNeilBrown <neilb@suse.com>
Thu, 2 Jun 2016 06:19:52 +0000 (16:19 +1000)
committerShaohua Li <shli@fb.com>
Mon, 13 Jun 2016 18:54:19 +0000 (11:54 -0700)
Being in the middle of resync is no longer protection against failed
rdevs disappearing.  So add rcu protection.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c

index e56c7e0627fa6d0824e6610f32bf31e0847a7632..198b2a9eef980d89648a00bea2eb657825a46c9f 100644 (file)
@@ -3239,15 +3239,16 @@ static int want_replace(struct stripe_head *sh, int disk_idx)
 {
        struct md_rdev *rdev;
        int rv = 0;
-       /* Doing recovery so rcu locking not required */
-       rdev = sh->raid_conf->disks[disk_idx].replacement;
+
+       rcu_read_lock();
+       rdev = rcu_dereference(sh->raid_conf->disks[disk_idx].replacement);
        if (rdev
            && !test_bit(Faulty, &rdev->flags)
            && !test_bit(In_sync, &rdev->flags)
            && (rdev->recovery_offset <= sh->sector
                || rdev->mddev->recovery_cp <= sh->sector))
                rv = 1;
-
+       rcu_read_unlock();
        return rv;
 }