提交 5f0aa21d 编写于 作者: G Guoqing Jiang 提交者: Shaohua Li

md-cluster: protect md_find_rdev_nr_rcu with rcu lock

We need to use rcu_read_lock/unlock to avoid potential
race.
Reported-by: NShaohua Li <shli@fb.com>
Reviewed-by: NNeilBrown <neilb@suse.com>
Signed-off-by: NGuoqing Jiang <gqjiang@suse.com>
Signed-off-by: NShaohua Li <shli@fb.com>
上级 c20c33f0
...@@ -489,9 +489,10 @@ static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg ...@@ -489,9 +489,10 @@ static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg
static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg) static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg)
{ {
struct md_rdev *rdev = md_find_rdev_nr_rcu(mddev, struct md_rdev *rdev;
le32_to_cpu(msg->raid_slot));
rcu_read_lock();
rdev = md_find_rdev_nr_rcu(mddev, le32_to_cpu(msg->raid_slot));
if (rdev) { if (rdev) {
set_bit(ClusterRemove, &rdev->flags); set_bit(ClusterRemove, &rdev->flags);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
...@@ -500,18 +501,21 @@ static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg) ...@@ -500,18 +501,21 @@ static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg)
else else
pr_warn("%s: %d Could not find disk(%d) to REMOVE\n", pr_warn("%s: %d Could not find disk(%d) to REMOVE\n",
__func__, __LINE__, le32_to_cpu(msg->raid_slot)); __func__, __LINE__, le32_to_cpu(msg->raid_slot));
rcu_read_unlock();
} }
static void process_readd_disk(struct mddev *mddev, struct cluster_msg *msg) static void process_readd_disk(struct mddev *mddev, struct cluster_msg *msg)
{ {
struct md_rdev *rdev = md_find_rdev_nr_rcu(mddev, struct md_rdev *rdev;
le32_to_cpu(msg->raid_slot));
rcu_read_lock();
rdev = md_find_rdev_nr_rcu(mddev, le32_to_cpu(msg->raid_slot));
if (rdev && test_bit(Faulty, &rdev->flags)) if (rdev && test_bit(Faulty, &rdev->flags))
clear_bit(Faulty, &rdev->flags); clear_bit(Faulty, &rdev->flags);
else else
pr_warn("%s: %d Could not find disk(%d) which is faulty", pr_warn("%s: %d Could not find disk(%d) which is faulty",
__func__, __LINE__, le32_to_cpu(msg->raid_slot)); __func__, __LINE__, le32_to_cpu(msg->raid_slot));
rcu_read_unlock();
} }
static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册