aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-01-13 17:14:34 -0500
committerNeilBrown <neilb@suse.de>2011-01-13 17:14:34 -0500
commitba1b41b6b4e30cb66ae2775faadea05cae3ce61c (patch)
tree02da80f72095418dd1a08661f59c24607029a8e7 /drivers/md
parent1a940fcee31ec6c18c2f24dbdad31d54e4c35048 (diff)
md: range check slot number when manually adding a spare.
When adding a spare to an active array, we should check the slot number, but allow it to be larger than raid_disks if a reshape is being prepared. Apply the same test when adding a device to an array-under-construction. It already had most of the test in place, but not quite all. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5e3714fecee9..665851308818 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2479,6 +2479,10 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2479 if (rdev2->raid_disk == slot) 2479 if (rdev2->raid_disk == slot)
2480 return -EEXIST; 2480 return -EEXIST;
2481 2481
2482 if (slot >= rdev->mddev->raid_disks &&
2483 slot >= rdev->mddev->raid_disks + rdev->mddev->delta_disks)
2484 return -ENOSPC;
2485
2482 rdev->raid_disk = slot; 2486 rdev->raid_disk = slot;
2483 if (test_bit(In_sync, &rdev->flags)) 2487 if (test_bit(In_sync, &rdev->flags))
2484 rdev->saved_raid_disk = slot; 2488 rdev->saved_raid_disk = slot;
@@ -2496,7 +2500,8 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2496 /* failure here is OK */; 2500 /* failure here is OK */;
2497 /* don't wakeup anyone, leave that to userspace. */ 2501 /* don't wakeup anyone, leave that to userspace. */
2498 } else { 2502 } else {
2499 if (slot >= rdev->mddev->raid_disks) 2503 if (slot >= rdev->mddev->raid_disks &&
2504 slot >= rdev->mddev->raid_disks + rdev->mddev->delta_disks)
2500 return -ENOSPC; 2505 return -ENOSPC;
2501 rdev->raid_disk = slot; 2506 rdev->raid_disk = slot;
2502 /* assume it is working */ 2507 /* assume it is working */