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

Commit 1a940fce authored by NeilBrown's avatar NeilBrown
Browse files

md/raid5: handle manually-added spares in start_reshape.



It is possible to manually add spares to specific slots before
starting a reshape.
raid5_start_reshape should recognised this possibility and include
it in the accounting.

Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 13ae864b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -5527,8 +5527,8 @@ static int raid5_start_reshape(mddev_t *mddev)
		return -ENOSPC;

	list_for_each_entry(rdev, &mddev->disks, same_set)
		if (rdev->raid_disk < 0 &&
		    !test_bit(Faulty, &rdev->flags))
		if ((rdev->raid_disk < 0 || rdev->raid_disk >= conf->raid_disks)
		     && !test_bit(Faulty, &rdev->flags))
			spares++;

	if (spares - mddev->degraded < mddev->delta_disks - conf->max_degraded)
@@ -5588,6 +5588,11 @@ static int raid5_start_reshape(mddev_t *mddev)
					/* Failure here is OK */;
			} else
				break;
		} else if (rdev->raid_disk >= conf->previous_raid_disks
			   && !test_bit(Faulty, &rdev->flags)) {
			/* This is a spare that was manually added */
			set_bit(In_sync, &rdev->flags);
			added_devices++;
		}

	/* When a reshape changes the number of devices, ->degraded