diff options
author | NeilBrown <neilb@suse.de> | 2011-01-14 09:14:34 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-01-14 09:14:34 +1100 |
commit | ba1b41b6b4e30cb66ae2775faadea05cae3ce61c (patch) | |
tree | 02da80f72095418dd1a08661f59c24607029a8e7 /drivers | |
parent | 1a940fcee31ec6c18c2f24dbdad31d54e4c35048 (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')
-rw-r--r-- | drivers/md/md.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5e3714fecee..66585130881 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) if (rdev2->raid_disk == slot) return -EEXIST; + if (slot >= rdev->mddev->raid_disks && + slot >= rdev->mddev->raid_disks + rdev->mddev->delta_disks) + return -ENOSPC; + rdev->raid_disk = slot; if (test_bit(In_sync, &rdev->flags)) rdev->saved_raid_disk = slot; @@ -2496,7 +2500,8 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) /* failure here is OK */; /* don't wakeup anyone, leave that to userspace. */ } else { - if (slot >= rdev->mddev->raid_disks) + if (slot >= rdev->mddev->raid_disks && + slot >= rdev->mddev->raid_disks + rdev->mddev->delta_disks) return -ENOSPC; rdev->raid_disk = slot; /* assume it is working */ |