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