Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f232d6a authored by NeilBrown's avatar NeilBrown Committed by Shaohua Li
Browse files

md/raid5: add rcu protection to rdev accesses in want_replace



Being in the middle of resync is no longer protection against failed
rdevs disappearing.  So add rcu protection.

Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent e50d3992
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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;
}