Commit f97fcad3 authored by NeilBrown's avatar NeilBrown

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: default avatarNeilBrown <neilb@suse.de>
parent 978a7a47
...@@ -6950,9 +6950,6 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -6950,9 +6950,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
return 0; return 0;
} }
if (mddev_lock(mddev) < 0)
return -EINTR;
spin_lock(&mddev->lock); spin_lock(&mddev->lock);
if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) {
seq_printf(seq, "%s : %sactive", mdname(mddev), seq_printf(seq, "%s : %sactive", mdname(mddev),
...@@ -6966,7 +6963,8 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -6966,7 +6963,8 @@ static int md_seq_show(struct seq_file *seq, void *v)
} }
sectors = 0; sectors = 0;
rdev_for_each(rdev, mddev) { rcu_read_lock();
rdev_for_each_rcu(rdev, mddev) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
seq_printf(seq, " %s[%d]", seq_printf(seq, " %s[%d]",
bdevname(rdev->bdev,b), rdev->desc_nr); bdevname(rdev->bdev,b), rdev->desc_nr);
...@@ -6982,6 +6980,7 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -6982,6 +6980,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "(R)"); seq_printf(seq, "(R)");
sectors += rdev->sectors; sectors += rdev->sectors;
} }
rcu_read_unlock();
if (!list_empty(&mddev->disks)) { if (!list_empty(&mddev->disks)) {
if (mddev->pers) if (mddev->pers)
...@@ -7025,7 +7024,6 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -7025,7 +7024,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "\n"); seq_printf(seq, "\n");
} }
spin_unlock(&mddev->lock); spin_unlock(&mddev->lock);
mddev_unlock(mddev);
return 0; return 0;
} }
......
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