aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@notabene.brown>2008-06-27 18:31:31 -0400
committerNeil Brown <neilb@notabene.brown>2008-06-27 18:31:31 -0400
commit6c2fce2ef6b4821c21b5c42c7207cb9cf8c87eda (patch)
tree726b16f46c039df387f7cdfe0d195821d8955532 /drivers/md/raid5.c
parent8ed0a5216a0238f53b482ec88ce4aeed4b9f0da1 (diff)
Support adding a spare to a live md array with external metadata.
i.e. extend the 'md/dev-XXX/slot' attribute so that you can tell a device to fill an vacant slot in an and md array. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 214b44122822..002f33b1ae00 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4607,21 +4607,27 @@ static int raid5_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
4607 int found = 0; 4607 int found = 0;
4608 int disk; 4608 int disk;
4609 struct disk_info *p; 4609 struct disk_info *p;
4610 int first = 0;
4611 int last = conf->raid_disks - 1;
4610 4612
4611 if (mddev->degraded > conf->max_degraded) 4613 if (mddev->degraded > conf->max_degraded)
4612 /* no point adding a device */ 4614 /* no point adding a device */
4613 return 0; 4615 return 0;
4614 4616
4617 if (rdev->raid_disk >= 0)
4618 first = last = rdev->raid_disk;
4619
4615 /* 4620 /*
4616 * find the disk ... but prefer rdev->saved_raid_disk 4621 * find the disk ... but prefer rdev->saved_raid_disk
4617 * if possible. 4622 * if possible.
4618 */ 4623 */
4619 if (rdev->saved_raid_disk >= 0 && 4624 if (rdev->saved_raid_disk >= 0 &&
4625 rdev->saved_raid_disk >= first &&
4620 conf->disks[rdev->saved_raid_disk].rdev == NULL) 4626 conf->disks[rdev->saved_raid_disk].rdev == NULL)
4621 disk = rdev->saved_raid_disk; 4627 disk = rdev->saved_raid_disk;
4622 else 4628 else
4623 disk = 0; 4629 disk = first;
4624 for ( ; disk < conf->raid_disks; disk++) 4630 for ( ; disk <= last ; disk++)
4625 if ((p=conf->disks + disk)->rdev == NULL) { 4631 if ((p=conf->disks + disk)->rdev == NULL) {
4626 clear_bit(In_sync, &rdev->flags); 4632 clear_bit(In_sync, &rdev->flags);
4627 rdev->raid_disk = disk; 4633 rdev->raid_disk = disk;