Commit 1bbe254e authored by Denis Plotnikov's avatar Denis Plotnikov Committed by Song Liu

md-cluster: check for timeout while a new disk adding

A new disk adding may end up with timeout and a new disk won't be added.
Add returning the error in that case.

Found by Linux Verification Center (linuxtesting.org) with SVACE
Signed-off-by: default avatarDenis Plotnikov <den-plotnikov@yandex-team.ru>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230925125940.1542506-1-den-plotnikov@yandex-team.ru
parent 9164e4a5
...@@ -501,7 +501,7 @@ static void process_suspend_info(struct mddev *mddev, ...@@ -501,7 +501,7 @@ static void process_suspend_info(struct mddev *mddev,
mddev->pers->quiesce(mddev, 0); mddev->pers->quiesce(mddev, 0);
} }
static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg) static int process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
{ {
char disk_uuid[64]; char disk_uuid[64];
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
...@@ -509,6 +509,7 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg) ...@@ -509,6 +509,7 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
char raid_slot[16]; char raid_slot[16];
char *envp[] = {event_name, disk_uuid, raid_slot, NULL}; char *envp[] = {event_name, disk_uuid, raid_slot, NULL};
int len; int len;
int res = 0;
len = snprintf(disk_uuid, 64, "DEVICE_UUID="); len = snprintf(disk_uuid, 64, "DEVICE_UUID=");
sprintf(disk_uuid + len, "%pU", cmsg->uuid); sprintf(disk_uuid + len, "%pU", cmsg->uuid);
...@@ -517,9 +518,14 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg) ...@@ -517,9 +518,14 @@ static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg)
init_completion(&cinfo->newdisk_completion); init_completion(&cinfo->newdisk_completion);
set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp); kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp);
wait_for_completion_timeout(&cinfo->newdisk_completion, if (!wait_for_completion_timeout(&cinfo->newdisk_completion,
NEW_DEV_TIMEOUT); NEW_DEV_TIMEOUT)) {
pr_err("md-cluster(%s:%d): timeout on a new disk adding\n",
__func__, __LINE__);
res = -1;
}
clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state);
return res;
} }
...@@ -594,7 +600,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) ...@@ -594,7 +600,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
le64_to_cpu(msg->high)); le64_to_cpu(msg->high));
break; break;
case NEWDISK: case NEWDISK:
process_add_new_disk(mddev, msg); if (process_add_new_disk(mddev, msg))
ret = -1;
break; break;
case REMOVE: case REMOVE:
process_remove_disk(mddev, msg); process_remove_disk(mddev, msg);
......
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