Commit b2a0c975 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] md: Remove the 'disks' array from md which holds the gendisk structures.

From: NeilBrown <neilb@cse.unsw.edu.au>

Move the pointers into mddev.  The reduces dependance on MAX_MD_DEVS.
parent 24ae7480
...@@ -124,8 +124,6 @@ static ctl_table raid_root_table[] = { ...@@ -124,8 +124,6 @@ static ctl_table raid_root_table[] = {
static struct block_device_operations md_fops; static struct block_device_operations md_fops;
static struct gendisk *disks[MAX_MD_DEVS];
/* /*
* Enables to iterate over all existing md arrays * Enables to iterate over all existing md arrays
* all_mddevs_lock protects this list as well as mddev_map. * all_mddevs_lock protects this list as well as mddev_map.
...@@ -1463,7 +1461,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) ...@@ -1463,7 +1461,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
return NULL; return NULL;
down(&disks_sem); down(&disks_sem);
if (disks[unit]) { if (mddev->gendisk) {
up(&disks_sem); up(&disks_sem);
mddev_put(mddev); mddev_put(mddev);
return NULL; return NULL;
...@@ -1481,7 +1479,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) ...@@ -1481,7 +1479,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
disk->private_data = mddev; disk->private_data = mddev;
disk->queue = mddev->queue; disk->queue = mddev->queue;
add_disk(disk); add_disk(disk);
disks[mdidx(mddev)] = disk; mddev->gendisk = disk;
up(&disks_sem); up(&disks_sem);
return NULL; return NULL;
} }
...@@ -1599,7 +1597,7 @@ static int do_md_run(mddev_t * mddev) ...@@ -1599,7 +1597,7 @@ static int do_md_run(mddev_t * mddev)
unit = mdidx(mddev); unit = mdidx(mddev);
md_probe(0, &unit, NULL); md_probe(0, &unit, NULL);
disk = disks[unit]; disk = mddev->gendisk;
if (!disk) if (!disk)
return -ENOMEM; return -ENOMEM;
...@@ -1650,7 +1648,7 @@ static int do_md_run(mddev_t * mddev) ...@@ -1650,7 +1648,7 @@ static int do_md_run(mddev_t * mddev)
static int restart_array(mddev_t *mddev) static int restart_array(mddev_t *mddev)
{ {
struct gendisk *disk = disks[mdidx(mddev)]; struct gendisk *disk = mddev->gendisk;
int err; int err;
/* /*
...@@ -1690,7 +1688,7 @@ static int restart_array(mddev_t *mddev) ...@@ -1690,7 +1688,7 @@ static int restart_array(mddev_t *mddev)
static int do_md_stop(mddev_t * mddev, int ro) static int do_md_stop(mddev_t * mddev, int ro)
{ {
int err = 0; int err = 0;
struct gendisk *disk = disks[mdidx(mddev)]; struct gendisk *disk = mddev->gendisk;
if (mddev->pers) { if (mddev->pers) {
if (atomic_read(&mddev->active)>2) { if (atomic_read(&mddev->active)>2) {
...@@ -1741,7 +1739,7 @@ static int do_md_stop(mddev_t * mddev, int ro) ...@@ -1741,7 +1739,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
export_array(mddev); export_array(mddev);
mddev->array_size = 0; mddev->array_size = 0;
disk = disks[mdidx(mddev)]; disk = mddev->gendisk;
if (disk) if (disk)
set_capacity(disk, 0); set_capacity(disk, 0);
} else } else
...@@ -2532,7 +2530,7 @@ static int md_ioctl(struct inode *inode, struct file *file, ...@@ -2532,7 +2530,7 @@ static int md_ioctl(struct inode *inode, struct file *file,
err = put_user (4, (char *) &loc->sectors); err = put_user (4, (char *) &loc->sectors);
if (err) if (err)
goto abort_unlock; goto abort_unlock;
err = put_user(get_capacity(disks[mdidx(mddev)])/8, err = put_user(get_capacity(mddev->gendisk)/8,
(short *) &loc->cylinders); (short *) &loc->cylinders);
if (err) if (err)
goto abort_unlock; goto abort_unlock;
...@@ -3574,6 +3572,8 @@ static void autostart_arrays(void) ...@@ -3574,6 +3572,8 @@ static void autostart_arrays(void)
static __exit void md_exit(void) static __exit void md_exit(void)
{ {
mddev_t *mddev;
struct list_head *tmp;
int i; int i;
blk_unregister_region(MKDEV(MAJOR_NR,0), MAX_MD_DEVS); blk_unregister_region(MKDEV(MAJOR_NR,0), MAX_MD_DEVS);
for (i=0; i < MAX_MD_DEVS; i++) for (i=0; i < MAX_MD_DEVS; i++)
...@@ -3586,15 +3586,14 @@ static __exit void md_exit(void) ...@@ -3586,15 +3586,14 @@ static __exit void md_exit(void)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
remove_proc_entry("mdstat", NULL); remove_proc_entry("mdstat", NULL);
#endif #endif
for (i = 0; i < MAX_MD_DEVS; i++) { ITERATE_MDDEV(mddev,tmp) {
struct gendisk *disk = disks[i]; struct gendisk *disk = mddev->gendisk;
mddev_t *mddev; if (!disk)
if (!disks[i])
continue; continue;
mddev = disk->private_data;
export_array(mddev); export_array(mddev);
del_gendisk(disk); del_gendisk(disk);
put_disk(disk); put_disk(disk);
mddev->gendisk = NULL;
mddev_put(mddev); mddev_put(mddev);
} }
} }
......
...@@ -191,6 +191,8 @@ struct mddev_s ...@@ -191,6 +191,8 @@ struct mddev_s
int sb_dirty; int sb_dirty;
int ro; int ro;
struct gendisk *gendisk;
/* Superblock information */ /* Superblock information */
int major_version, int major_version,
minor_version, minor_version,
......
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