Commit 91dd54ad authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md: Remove dependancy on MD_SB_DISKS from multipath

Multipath has a dependancy on MD_SB_DISKS which is no
longer authoritative.  We change it to use a separately
allocated array.
parent 30a92b27
...@@ -58,7 +58,7 @@ static void mp_pool_free(void *mpb, void *data) ...@@ -58,7 +58,7 @@ static void mp_pool_free(void *mpb, void *data)
static int multipath_map (mddev_t *mddev, mdk_rdev_t **rdevp) static int multipath_map (mddev_t *mddev, mdk_rdev_t **rdevp)
{ {
multipath_conf_t *conf = mddev_to_conf(mddev); multipath_conf_t *conf = mddev_to_conf(mddev);
int i, disks = mddev->max_disks; int i, disks = conf->raid_disks;
/* /*
* Later we do read balancing on the read side * Later we do read balancing on the read side
...@@ -146,7 +146,7 @@ static int multipath_read_balance (multipath_conf_t *conf) ...@@ -146,7 +146,7 @@ static int multipath_read_balance (multipath_conf_t *conf)
{ {
int disk; int disk;
for (disk = 0; disk < conf->mddev->max_disks; disk++) { for (disk = 0; disk < conf->raid_disks; disk++) {
mdk_rdev_t *rdev = conf->multipaths[disk].rdev; mdk_rdev_t *rdev = conf->multipaths[disk].rdev;
if (rdev && rdev->in_sync) if (rdev && rdev->in_sync)
return disk; return disk;
...@@ -246,7 +246,7 @@ static void print_multipath_conf (multipath_conf_t *conf) ...@@ -246,7 +246,7 @@ static void print_multipath_conf (multipath_conf_t *conf)
printk(" --- wd:%d rd:%d\n", conf->working_disks, printk(" --- wd:%d rd:%d\n", conf->working_disks,
conf->raid_disks); conf->raid_disks);
for (i = 0; i < conf->mddev->max_disks; i++) { for (i = 0; i < conf->raid_disks; i++) {
tmp = conf->multipaths + i; tmp = conf->multipaths + i;
if (tmp->rdev) if (tmp->rdev)
printk(" disk%d, o:%d, dev:%s\n", printk(" disk%d, o:%d, dev:%s\n",
...@@ -385,6 +385,15 @@ static int multipath_run (mddev_t *mddev) ...@@ -385,6 +385,15 @@ static int multipath_run (mddev_t *mddev)
} }
memset(conf, 0, sizeof(*conf)); memset(conf, 0, sizeof(*conf));
conf->multipaths = kmalloc(sizeof(struct multipath_info)*mddev->raid_disks,
GFP_KERNEL);
if (!conf->multipaths) {
printk(KERN_ERR
"multipath: couldn't allocate memory for md%d\n",
mdidx(mddev));
goto out_free_conf;
}
conf->working_disks = 0; conf->working_disks = 0;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
disk_idx = rdev->raid_disk; disk_idx = rdev->raid_disk;
...@@ -443,6 +452,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -443,6 +452,8 @@ static int multipath_run (mddev_t *mddev)
out_free_conf: out_free_conf:
if (conf->pool) if (conf->pool)
mempool_destroy(conf->pool); mempool_destroy(conf->pool);
if (conf->multipaths)
kfree(conf->multipaths);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
out: out:
...@@ -456,6 +467,7 @@ static int multipath_stop (mddev_t *mddev) ...@@ -456,6 +467,7 @@ static int multipath_stop (mddev_t *mddev)
md_unregister_thread(mddev->thread); md_unregister_thread(mddev->thread);
mempool_destroy(conf->pool); mempool_destroy(conf->pool);
kfree(conf->multipaths);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
return 0; return 0;
......
...@@ -9,7 +9,7 @@ struct multipath_info { ...@@ -9,7 +9,7 @@ struct multipath_info {
struct multipath_private_data { struct multipath_private_data {
mddev_t *mddev; mddev_t *mddev;
struct multipath_info multipaths[MD_SB_DISKS]; struct multipath_info *multipaths;
int raid_disks; int raid_disks;
int working_disks; int working_disks;
spinlock_t device_lock; spinlock_t device_lock;
......
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