aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/md.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9ef21d9b8e27..26b3d2879d93 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1070,10 +1070,13 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1070 mddev->bitmap_info.default_offset; 1070 mddev->bitmap_info.default_offset;
1071 1071
1072 } else if (mddev->pers == NULL) { 1072 } else if (mddev->pers == NULL) {
1073 /* Insist on good event counter while assembling */ 1073 /* Insist on good event counter while assembling, except
1074 * for spares (which don't need an event count) */
1074 ++ev1; 1075 ++ev1;
1075 if (ev1 < mddev->events) 1076 if (sb->disks[rdev->desc_nr].state & (
1076 return -EINVAL; 1077 (1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE)))
1078 if (ev1 < mddev->events)
1079 return -EINVAL;
1077 } else if (mddev->bitmap) { 1080 } else if (mddev->bitmap) {
1078 /* if adding to array with a bitmap, then we can accept an 1081 /* if adding to array with a bitmap, then we can accept an
1079 * older device ... but not too old. 1082 * older device ... but not too old.
@@ -1469,10 +1472,14 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1469 } 1472 }
1470 1473
1471 } else if (mddev->pers == NULL) { 1474 } else if (mddev->pers == NULL) {
1472 /* Insist of good event counter while assembling */ 1475 /* Insist of good event counter while assembling, except for
1476 * spares (which don't need an event count) */
1473 ++ev1; 1477 ++ev1;
1474 if (ev1 < mddev->events) 1478 if (rdev->desc_nr >= 0 &&
1475 return -EINVAL; 1479 rdev->desc_nr < le32_to_cpu(sb->max_dev) &&
1480 le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < 0xfffe)
1481 if (ev1 < mddev->events)
1482 return -EINVAL;
1476 } else if (mddev->bitmap) { 1483 } else if (mddev->bitmap) {
1477 /* If adding to array with a bitmap, then we can accept an 1484 /* If adding to array with a bitmap, then we can accept an
1478 * older device, but not too old. 1485 * older device, but not too old.