瀏覽代碼

md/multipath: add rcu protection to rdev access in multipath_status.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
NeilBrown 9 年之前
父節點
當前提交
40cf2123c5
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      drivers/md/multipath.c

+ 7 - 5
drivers/md/multipath.c

@@ -141,17 +141,19 @@ static void multipath_make_request(struct mddev *mddev, struct bio * bio)
 	return;
 	return;
 }
 }
 
 
-static void multipath_status (struct seq_file *seq, struct mddev *mddev)
+static void multipath_status(struct seq_file *seq, struct mddev *mddev)
 {
 {
 	struct mpconf *conf = mddev->private;
 	struct mpconf *conf = mddev->private;
 	int i;
 	int i;
 
 
 	seq_printf (seq, " [%d/%d] [", conf->raid_disks,
 	seq_printf (seq, " [%d/%d] [", conf->raid_disks,
 		    conf->raid_disks - mddev->degraded);
 		    conf->raid_disks - mddev->degraded);
-	for (i = 0; i < conf->raid_disks; i++)
-		seq_printf (seq, "%s",
-			       conf->multipaths[i].rdev &&
-			       test_bit(In_sync, &conf->multipaths[i].rdev->flags) ? "U" : "_");
+	rcu_read_lock();
+	for (i = 0; i < conf->raid_disks; i++) {
+		struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev);
+		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
+	}
+	rcu_read_unlock();
 	seq_printf (seq, "]");
 	seq_printf (seq, "]");
 }
 }