提交 c0c09f90 编写于 作者: H Hou Tao 提交者: Yongqiang Liu

scsi: cancel the inflight async device probe when remove scsi_target

hulk inclusion
category: bugfix
bugzilla: 188150, https://gitee.com/openeuler/kernel/issues/I643OL
CVE: NA

----------------------------------------

Cancel the inflight async device probe when removing scsi_target, so
no new disk will be added when __scsi_target_remove() returns.
Signed-off-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 74313e96
......@@ -1447,6 +1447,40 @@ void scsi_remove_device(struct scsi_device *sdev)
}
EXPORT_SYMBOL(scsi_remove_device);
/* Cancel the inflight async probe for scsi_device */
static void __scsi_kill_devices(struct scsi_target *starget)
{
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
struct scsi_device *sdev, *to_put = NULL;
unsigned long flags;
spin_lock_irqsave(shost->host_lock, flags);
list_for_each_entry(sdev, &shost->__devices, siblings) {
if (sdev->channel != starget->channel ||
sdev->id != starget->id)
continue;
if ((sdev->sdev_state != SDEV_DEL &&
sdev->sdev_state != SDEV_CANCEL) || !sdev->is_visible)
continue;
if (!kobject_get_unless_zero(&sdev->sdev_gendev.kobj))
continue;
spin_unlock_irqrestore(shost->host_lock, flags);
if (to_put)
put_device(&to_put->sdev_gendev);
device_lock(&sdev->sdev_gendev);
kill_device(&sdev->sdev_gendev);
device_unlock(&sdev->sdev_gendev);
to_put = sdev;
spin_lock_irqsave(shost->host_lock, flags);
}
spin_unlock_irqrestore(shost->host_lock, flags);
if (to_put)
put_device(&to_put->sdev_gendev);
}
static void __scsi_remove_target(struct scsi_target *starget)
{
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
......@@ -1476,6 +1510,8 @@ static void __scsi_remove_target(struct scsi_target *starget)
goto restart;
}
spin_unlock_irqrestore(shost->host_lock, flags);
__scsi_kill_devices(starget);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册