summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-09-25 09:00:11 +0200
committerNeilBrown <neilb@suse.de>2014-10-14 04:08:28 +0200
commit4878e9eb88c3a3223de68760e64dd71da01a3118 (patch)
treefcdc5bafd36f4961fe2b07f49e935803e4ab29b5 /drivers/md
parentmd: use wait_event() to simplify md_super_wait() (diff)
downloadlinux-4878e9eb88c3a3223de68760e64dd71da01a3118.tar.xz
linux-4878e9eb88c3a3223de68760e64dd71da01a3118.zip
md: discard find_rdev_nr in favour of find_rdev_nr_rcu
Having both is a waste - just use the one. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6be7146be5b3..73451f325dda 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -630,17 +630,6 @@ static void mddev_unlock(struct mddev * mddev)
spin_unlock(&pers_lock);
}
-static struct md_rdev * find_rdev_nr(struct mddev *mddev, int nr)
-{
- struct md_rdev *rdev;
-
- rdev_for_each(rdev, mddev)
- if (rdev->desc_nr == nr)
- return rdev;
-
- return NULL;
-}
-
static struct md_rdev *find_rdev_nr_rcu(struct mddev *mddev, int nr)
{
struct md_rdev *rdev;
@@ -2060,16 +2049,21 @@ static int bind_rdev_to_array(struct md_rdev * rdev, struct mddev * mddev)
* If it is -1, assign a free number, else
* check number is not in use
*/
+ rcu_read_lock();
if (rdev->desc_nr < 0) {
int choice = 0;
- if (mddev->pers) choice = mddev->raid_disks;
- while (find_rdev_nr(mddev, choice))
+ if (mddev->pers)
+ choice = mddev->raid_disks;
+ while (find_rdev_nr_rcu(mddev, choice))
choice++;
rdev->desc_nr = choice;
} else {
- if (find_rdev_nr(mddev, rdev->desc_nr))
+ if (find_rdev_nr_rcu(mddev, rdev->desc_nr)) {
+ rcu_read_unlock();
return -EBUSY;
+ }
}
+ rcu_read_unlock();
if (mddev->max_disks && rdev->desc_nr >= mddev->max_disks) {
printk(KERN_WARNING "md: %s: array is limited to %d devices\n",
mdname(mddev), mddev->max_disks);