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

[PATCH] md: Discard the mddev_map array.

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

We only need it occasionally to map unit number to mddev, and we can use a
linear search for that.  This reduces dependance on MAX_MD_DEVS
parent b2a0c975
...@@ -126,7 +126,7 @@ static struct block_device_operations md_fops; ...@@ -126,7 +126,7 @@ static struct block_device_operations md_fops;
/* /*
* 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.
*/ */
static LIST_HEAD(all_mddevs); static LIST_HEAD(all_mddevs);
static spinlock_t all_mddevs_lock = SPIN_LOCK_UNLOCKED; static spinlock_t all_mddevs_lock = SPIN_LOCK_UNLOCKED;
...@@ -154,8 +154,6 @@ static spinlock_t all_mddevs_lock = SPIN_LOCK_UNLOCKED; ...@@ -154,8 +154,6 @@ static spinlock_t all_mddevs_lock = SPIN_LOCK_UNLOCKED;
tmp = tmp->next;}) \ tmp = tmp->next;}) \
) )
static mddev_t *mddev_map[MAX_MD_DEVS];
static int md_fail_request (request_queue_t *q, struct bio *bio) static int md_fail_request (request_queue_t *q, struct bio *bio)
{ {
bio_io_error(bio, bio->bi_size); bio_io_error(bio, bio->bi_size);
...@@ -174,7 +172,6 @@ static void mddev_put(mddev_t *mddev) ...@@ -174,7 +172,6 @@ static void mddev_put(mddev_t *mddev)
return; return;
if (!mddev->raid_disks && list_empty(&mddev->disks)) { if (!mddev->raid_disks && list_empty(&mddev->disks)) {
list_del(&mddev->all_mddevs); list_del(&mddev->all_mddevs);
mddev_map[mdidx(mddev)] = NULL;
blk_put_queue(mddev->queue); blk_put_queue(mddev->queue);
kfree(mddev); kfree(mddev);
} }
...@@ -187,15 +184,16 @@ static mddev_t * mddev_find(int unit) ...@@ -187,15 +184,16 @@ static mddev_t * mddev_find(int unit)
retry: retry:
spin_lock(&all_mddevs_lock); spin_lock(&all_mddevs_lock);
if (mddev_map[unit]) { list_for_each_entry(mddev, &all_mddevs, all_mddevs)
mddev = mddev_get(mddev_map[unit]); if (mdidx(mddev) == unit) {
mddev_get(mddev);
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
if (new) if (new)
kfree(new); kfree(new);
return mddev; return mddev;
} }
if (new) { if (new) {
mddev_map[unit] = new;
list_add(&new->all_mddevs, &all_mddevs); list_add(&new->all_mddevs, &all_mddevs);
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
return new; return new;
......
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