提交 f0f82e24 编写于 作者: L lijinlin 提交者: Martin K. Petersen

scsi: core: Fix capacity set to zero after offlinining device

After adding physical volumes to a volume group through vgextend, the
kernel will rescan the partitions. This in turn will cause the device
capacity to be queried.

If the device status is set to offline through sysfs at this time, READ
CAPACITY command will return a result which the host byte is
DID_NO_CONNECT, and the capacity of the device will be set to zero in
read_capacity_error(). After setting device status back to running, the
capacity of the device will remain stuck at zero.

Fix this issue by rescanning device when the device state changes to
SDEV_RUNNING.

Link: https://lore.kernel.org/r/20210727034455.1494960-1-lijinlin3@huawei.comReviewed-by: NBart Van Assche <bvanassche@acm.org>
Signed-off-by: Nlijinlin <lijinlin3@huawei.com>
Signed-off-by: NWu Bo <wubo40@huawei.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 5c04243a
...@@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr, ...@@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
mutex_lock(&sdev->state_mutex); mutex_lock(&sdev->state_mutex);
ret = scsi_device_set_state(sdev, state); ret = scsi_device_set_state(sdev, state);
/* /*
* If the device state changes to SDEV_RUNNING, we need to run * If the device state changes to SDEV_RUNNING, we need to
* the queue to avoid I/O hang. * rescan the device to revalidate it, and run the queue to
* avoid I/O hang.
*/ */
if (ret == 0 && state == SDEV_RUNNING) if (ret == 0 && state == SDEV_RUNNING) {
scsi_rescan_device(dev);
blk_mq_run_hw_queues(sdev->request_queue, true); blk_mq_run_hw_queues(sdev->request_queue, true);
}
mutex_unlock(&sdev->state_mutex); mutex_unlock(&sdev->state_mutex);
return ret == 0 ? count : -EINVAL; return ret == 0 ? count : -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册