]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: increase raid_disks before adding specific spares.
authorNeilBrown <neilb@suse.de>
Tue, 22 Mar 2011 03:52:36 +0000 (14:52 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 22 Mar 2011 03:52:36 +0000 (14:52 +1100)
When we add spared that have been targeted at a specific slot,
we need raid_disks to be bigger than the slot number.
But currently we don't increase raid_disks until after we add
these spares.

So introduce an early increase of raid_disks to allow the spares
to be added.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index b6395850ac26270e41595ca8a149eaed4d448b8c..d6ecde2deea71072ee17c794af34f6b7ea4f9e5f 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1786,6 +1786,15 @@ static int reshape_array(char *container, int fd, char *devname,
 
                if (info2) {
                        sysfs_init(info2, fd, st->devnum);
+                       /* When increasing number of devices, we need to set
+                        * new raid_disks before adding these, or they might
+                        * be rejected.
+                        */
+                       if (reshape.backup_blocks &&
+                           reshape.after.data_disks > reshape.before.data_disks)
+                               subarray_set_num(container, info2, "raid_disks",
+                                                reshape.after.data_disks +
+                                                reshape.parity);
                        for (d = info2->devs; d; d = d->next) {
                                if (d->disk.state == 0 &&
                                    d->disk.raid_disk >= 0) {