diff options
author | NeilBrown <neilb@suse.de> | 2007-05-23 16:58:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-23 23:14:14 -0400 |
commit | a778b73ff793d34c0082f76110f73a7754915067 (patch) | |
tree | 54bf868afb3375cfdb0d01d6ce9e5eea47395f85 /drivers/md/md.c | |
parent | ab6085c795a71b6a21afe7469d30a365338add7a (diff) |
md: fix bug with linear hot-add and elsewhere
Adding a drive to a linear array seems to have stopped working, due to changes
elsewhere in md, and insufficient ongoing testing...
So the patch to make linear hot-add work in the first place introduced a
subtle bug elsewhere that interracts poorly with older version of mdadm.
This fixes it all up.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index c10ce91b64e9..1c54f3c1cca7 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1298,8 +1298,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) | |||
1298 | ITERATE_RDEV(mddev,rdev2,tmp) | 1298 | ITERATE_RDEV(mddev,rdev2,tmp) |
1299 | if (rdev2->desc_nr+1 > max_dev) | 1299 | if (rdev2->desc_nr+1 > max_dev) |
1300 | max_dev = rdev2->desc_nr+1; | 1300 | max_dev = rdev2->desc_nr+1; |
1301 | 1301 | ||
1302 | sb->max_dev = cpu_to_le32(max_dev); | 1302 | if (max_dev > le32_to_cpu(sb->max_dev)) |
1303 | sb->max_dev = cpu_to_le32(max_dev); | ||
1303 | for (i=0; i<max_dev;i++) | 1304 | for (i=0; i<max_dev;i++) |
1304 | sb->dev_roles[i] = cpu_to_le16(0xfffe); | 1305 | sb->dev_roles[i] = cpu_to_le16(0xfffe); |
1305 | 1306 | ||
@@ -1365,10 +1366,14 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1365 | } | 1366 | } |
1366 | /* make sure rdev->size exceeds mddev->size */ | 1367 | /* make sure rdev->size exceeds mddev->size */ |
1367 | if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { | 1368 | if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { |
1368 | if (mddev->pers) | 1369 | if (mddev->pers) { |
1369 | /* Cannot change size, so fail */ | 1370 | /* Cannot change size, so fail |
1370 | return -ENOSPC; | 1371 | * If mddev->level <= 0, then we don't care |
1371 | else | 1372 | * about aligning sizes (e.g. linear) |
1373 | */ | ||
1374 | if (mddev->level > 0) | ||
1375 | return -ENOSPC; | ||
1376 | } else | ||
1372 | mddev->size = rdev->size; | 1377 | mddev->size = rdev->size; |
1373 | } | 1378 | } |
1374 | 1379 | ||
@@ -2142,6 +2147,9 @@ static void analyze_sbs(mddev_t * mddev) | |||
2142 | rdev->desc_nr = i++; | 2147 | rdev->desc_nr = i++; |
2143 | rdev->raid_disk = rdev->desc_nr; | 2148 | rdev->raid_disk = rdev->desc_nr; |
2144 | set_bit(In_sync, &rdev->flags); | 2149 | set_bit(In_sync, &rdev->flags); |
2150 | } else if (rdev->raid_disk >= mddev->raid_disks) { | ||
2151 | rdev->raid_disk = -1; | ||
2152 | clear_bit(In_sync, &rdev->flags); | ||
2145 | } | 2153 | } |
2146 | } | 2154 | } |
2147 | 2155 | ||