summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-12-15 12:56:59 +1100
committerNeilBrown <neilb@suse.de>2015-02-06 09:32:55 +1100
commitf97fcad38f2ecf2e34b6f0ab93f74f2978dbe008 (patch)
treebff93531bc4bf444adf29337202b4814359d8a61
parent978a7a47cae79ae7a7b5a1e80bfcaef6ee700312 (diff)
downloadtalos-obmc-linux-f97fcad38f2ecf2e34b6f0ab93f74f2978dbe008.tar.gz
talos-obmc-linux-f97fcad38f2ecf2e34b6f0ab93f74f2978dbe008.zip
md: remove need for mddev_lock() in md_seq_show()
The only access in md_seq_show that could suffer from races not protected by ->lock is walking the rdev list. This can receive sufficient protection from 'rcu'. So use rdev_for_each_rcu() and get rid of mddev_lock(). Now reading /proc/mdstat will never block in md_seq_show. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/md.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4db4e4146a35..eb0c3b576d7d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6950,9 +6950,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
return 0;
}
- if (mddev_lock(mddev) < 0)
- return -EINTR;
-
spin_lock(&mddev->lock);
if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) {
seq_printf(seq, "%s : %sactive", mdname(mddev),
@@ -6966,7 +6963,8 @@ static int md_seq_show(struct seq_file *seq, void *v)
}
sectors = 0;
- rdev_for_each(rdev, mddev) {
+ rcu_read_lock();
+ rdev_for_each_rcu(rdev, mddev) {
char b[BDEVNAME_SIZE];
seq_printf(seq, " %s[%d]",
bdevname(rdev->bdev,b), rdev->desc_nr);
@@ -6982,6 +6980,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "(R)");
sectors += rdev->sectors;
}
+ rcu_read_unlock();
if (!list_empty(&mddev->disks)) {
if (mddev->pers)
@@ -7025,7 +7024,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "\n");
}
spin_unlock(&mddev->lock);
- mddev_unlock(mddev);
return 0;
}
OpenPOWER on IntegriCloud