Commit b55e6bfc authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: Split disks array out of raid5 conf structure so it is easier to grow

The remainder of this batch implements raid5 reshaping.  Currently the only
shape change that is supported is added a device, but it is envisioned that
changing the chunksize and layout will also be supported, as well as changing
the level (e.g.  1->5, 5->6).

The reshape process naturally has to move all of the data in the array, and so
should be used with caution.  It is believed to work, and some testing does
support this, but wider testing would be great for increasing my confidence.

You will need a version of mdadm newer than 2.3.1 to make use of raid5 growth.
 This is because mdadm need to take a copy of a 'critical section' at the
start of the array incase there is a crash at an awkward moment.  On restart,
mdadm will restore the critical section and allow reshape to continue.

I hope to release a 2.4-pre by early next week - it still needs a little more
polishing.

This patch:

Previously the array of disk information was included in the raid5 'conf'
structure which was allocated to an appropriate size.  This makes it awkward
to change the size of that array.  So we split it off into a separate
kmalloced array which will require a little extra indexing, but is much easier
to grow.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4588b42e
...@@ -1822,11 +1822,13 @@ static int run(mddev_t *mddev) ...@@ -1822,11 +1822,13 @@ static int run(mddev_t *mddev)
return -EIO; return -EIO;
} }
mddev->private = kzalloc(sizeof (raid5_conf_t) mddev->private = kzalloc(sizeof (raid5_conf_t), GFP_KERNEL);
+ mddev->raid_disks * sizeof(struct disk_info),
GFP_KERNEL);
if ((conf = mddev->private) == NULL) if ((conf = mddev->private) == NULL)
goto abort; goto abort;
conf->disks = kzalloc(mddev->raid_disks * sizeof(struct disk_info),
GFP_KERNEL);
if (!conf->disks)
goto abort;
conf->mddev = mddev; conf->mddev = mddev;
...@@ -1966,6 +1968,7 @@ static int run(mddev_t *mddev) ...@@ -1966,6 +1968,7 @@ static int run(mddev_t *mddev)
abort: abort:
if (conf) { if (conf) {
print_raid5_conf(conf); print_raid5_conf(conf);
kfree(conf->disks);
kfree(conf->stripe_hashtbl); kfree(conf->stripe_hashtbl);
kfree(conf); kfree(conf);
} }
...@@ -1986,6 +1989,7 @@ static int stop(mddev_t *mddev) ...@@ -1986,6 +1989,7 @@ static int stop(mddev_t *mddev)
kfree(conf->stripe_hashtbl); kfree(conf->stripe_hashtbl);
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); sysfs_remove_group(&mddev->kobj, &raid5_attrs_group);
kfree(conf->disks);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
return 0; return 0;
......
...@@ -2006,11 +2006,14 @@ static int run(mddev_t *mddev) ...@@ -2006,11 +2006,14 @@ static int run(mddev_t *mddev)
return -EIO; return -EIO;
} }
mddev->private = kzalloc(sizeof (raid6_conf_t) mddev->private = kzalloc(sizeof (raid6_conf_t), GFP_KERNEL);
+ mddev->raid_disks * sizeof(struct disk_info),
GFP_KERNEL);
if ((conf = mddev->private) == NULL) if ((conf = mddev->private) == NULL)
goto abort; goto abort;
conf->disks = kzalloc(mddev->raid_disks * sizeof(struct disk_info),
GFP_KERNEL);
if (!conf->disks)
goto abort;
conf->mddev = mddev; conf->mddev = mddev;
if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL) if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
...@@ -2158,6 +2161,7 @@ abort: ...@@ -2158,6 +2161,7 @@ abort:
print_raid6_conf(conf); print_raid6_conf(conf);
safe_put_page(conf->spare_page); safe_put_page(conf->spare_page);
kfree(conf->stripe_hashtbl); kfree(conf->stripe_hashtbl);
kfree(conf->disks);
kfree(conf); kfree(conf);
} }
mddev->private = NULL; mddev->private = NULL;
......
...@@ -240,7 +240,7 @@ struct raid5_private_data { ...@@ -240,7 +240,7 @@ struct raid5_private_data {
* waiting for 25% to be free * waiting for 25% to be free
*/ */
spinlock_t device_lock; spinlock_t device_lock;
struct disk_info disks[0]; struct disk_info *disks;
}; };
typedef struct raid5_private_data raid5_conf_t; typedef struct raid5_private_data raid5_conf_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment