LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 3:44 [PATCH v2] scsi: Fix the issue that the disk capacity set to zero lijinlin3
@ 2021-07-27 3:25 ` Martin K. Petersen
2021-07-27 6:15 ` lijinlin
2021-07-27 3:39 ` Bart Van Assche
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Martin K. Petersen @ 2021-07-27 3:25 UTC (permalink / raw)
To: lijinlin3
Cc: jejb, martin.petersen, linux-scsi, linux-kernel, john.garry,
bvanassche, yanaijie, linfeilong, wubo40
lijinlin,
What changed in v2? Please make sure to include a change log after the
"---" separator when you resubmit a patch.
Thank you!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 3:44 [PATCH v2] scsi: Fix the issue that the disk capacity set to zero lijinlin3
2021-07-27 3:25 ` Martin K. Petersen
@ 2021-07-27 3:39 ` Bart Van Assche
2021-07-27 8:48 ` John Garry
2021-07-29 3:37 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2021-07-27 3:39 UTC (permalink / raw)
To: lijinlin3, jejb, martin.petersen, linux-scsi, linux-kernel
Cc: john.garry, yanaijie, linfeilong, wubo40
On 7/26/21 8:44 PM, lijinlin3@huawei.com wrote:
> From: lijinlin <lijinlin3@huawei.com>
>
> After add physical volumes to a volume group through vgextend, kernel
> will rescan partitions, which will read the capacity of the device.
> 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, the capacity of the device will be set to zero in
> read_capacity_error(). However, the capacity of the device can't be
> reread after reset the device status to running, is still zero.
>
> Fix this issue by rescan device when the device state changes to
> SDEV_RUNNING.
>
> Signed-off-by: lijinlin <lijinlin3@huawei.com>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
> ---
> drivers/scsi/scsi_sysfs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 32489d25158f..ae9bfc658203 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
> mutex_lock(&sdev->state_mutex);
> ret = scsi_device_set_state(sdev, state);
> /*
> - * If the device state changes to SDEV_RUNNING, we need to run
> - * the queue to avoid I/O hang.
> + * If the device state changes to SDEV_RUNNING, we need to
> + * 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);
> + }
> mutex_unlock(&sdev->state_mutex);
>
> return ret == 0 ? count : -EINVAL;
In the future, please mention what has been changed between v1 and v2
under the three dashes ("---"). Anyway:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
@ 2021-07-27 3:44 lijinlin3
2021-07-27 3:25 ` Martin K. Petersen
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: lijinlin3 @ 2021-07-27 3:44 UTC (permalink / raw)
To: jejb, martin.petersen, linux-scsi, linux-kernel
Cc: john.garry, bvanassche, yanaijie, linfeilong, wubo40, lijinlin3
From: lijinlin <lijinlin3@huawei.com>
After add physical volumes to a volume group through vgextend, kernel
will rescan partitions, which will read the capacity of the device.
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, the capacity of the device will be set to zero in
read_capacity_error(). However, the capacity of the device can't be
reread after reset the device status to running, is still zero.
Fix this issue by rescan device when the device state changes to
SDEV_RUNNING.
Signed-off-by: lijinlin <lijinlin3@huawei.com>
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/scsi/scsi_sysfs.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 32489d25158f..ae9bfc658203 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
mutex_lock(&sdev->state_mutex);
ret = scsi_device_set_state(sdev, state);
/*
- * If the device state changes to SDEV_RUNNING, we need to run
- * the queue to avoid I/O hang.
+ * If the device state changes to SDEV_RUNNING, we need to
+ * 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);
+ }
mutex_unlock(&sdev->state_mutex);
return ret == 0 ? count : -EINVAL;
--
2.27.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 3:25 ` Martin K. Petersen
@ 2021-07-27 6:15 ` lijinlin
0 siblings, 0 replies; 7+ messages in thread
From: lijinlin @ 2021-07-27 6:15 UTC (permalink / raw)
To: Martin K. Petersen
Cc: jejb, linux-scsi, linux-kernel, john.garry, bvanassche, yanaijie,
linfeilong, wubo40
Patch v2 only change 'scsi_sysfs:' to 'scsi:' in subject, thanks.
On 2021/7/27 11:25, Martin K. Petersen wrote:>
> lijinlin,
>
> What changed in v2? Please make sure to include a change log after the
> "---" separator when you resubmit a patch.
>
> Thank you!
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 3:44 [PATCH v2] scsi: Fix the issue that the disk capacity set to zero lijinlin3
2021-07-27 3:25 ` Martin K. Petersen
2021-07-27 3:39 ` Bart Van Assche
@ 2021-07-27 8:48 ` John Garry
2021-07-27 12:08 ` lijinlin
2021-07-29 3:37 ` Martin K. Petersen
3 siblings, 1 reply; 7+ messages in thread
From: John Garry @ 2021-07-27 8:48 UTC (permalink / raw)
To: lijinlin3, jejb, martin.petersen, linux-scsi, linux-kernel
Cc: bvanassche, yanaijie, linfeilong, wubo40
On 27/07/2021 04:44, lijinlin3@huawei.com wrote:
> From: lijinlin <lijinlin3@huawei.com>
>
> After add physical volumes to a volume group through vgextend, kernel
> will rescan partitions, which will read the capacity of the device.
> 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, the capacity of the device will be set to zero in
> read_capacity_error(). However, the capacity of the device can't be
> reread after reset the device status to running, is still zero.
>
> Fix this issue by rescan device when the device state changes to
> SDEV_RUNNING.
>
> Signed-off-by: lijinlin <lijinlin3@huawei.com>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
> ---
> drivers/scsi/scsi_sysfs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 32489d25158f..ae9bfc658203 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
> mutex_lock(&sdev->state_mutex);
> ret = scsi_device_set_state(sdev, state);
> /*
> - * If the device state changes to SDEV_RUNNING, we need to run
> - * the queue to avoid I/O hang.
> + * If the device state changes to SDEV_RUNNING, we need to
> + * 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);
I am wondering does any of this need to be done with the device state
mutex held?
Thanks,
John
> + }
> mutex_unlock(&sdev->state_mutex);
>
> return ret == 0 ? count : -EINVAL;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 8:48 ` John Garry
@ 2021-07-27 12:08 ` lijinlin
0 siblings, 0 replies; 7+ messages in thread
From: lijinlin @ 2021-07-27 12:08 UTC (permalink / raw)
To: John Garry, jejb, martin.petersen, linux-scsi, linux-kernel
Cc: bvanassche, yanaijie, linfeilong, wubo40
On 2021/7/27 16:48, John Garry wrote:
> On 27/07/2021 04:44, lijinlin3@huawei.com wrote:
>> From: lijinlin <lijinlin3@huawei.com>
>>
>> After add physical volumes to a volume group through vgextend, kernel
>> will rescan partitions, which will read the capacity of the device.
>> 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, the capacity of the device will be set to zero in
>> read_capacity_error(). However, the capacity of the device can't be
>> reread after reset the device status to running, is still zero.
>>
>> Fix this issue by rescan device when the device state changes to
>> SDEV_RUNNING.
>>
>> Signed-off-by: lijinlin <lijinlin3@huawei.com>
>> Signed-off-by: Wu Bo <wubo40@huawei.com>
>> ---
>> drivers/scsi/scsi_sysfs.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
>> index 32489d25158f..ae9bfc658203 100644
>> --- a/drivers/scsi/scsi_sysfs.c
>> +++ b/drivers/scsi/scsi_sysfs.c
>> @@ -807,11 +807,14 @@ store_state_field(struct device *dev, struct device_attribute *attr,
>> mutex_lock(&sdev->state_mutex);
>> ret = scsi_device_set_state(sdev, state);
>> /*
>> - * If the device state changes to SDEV_RUNNING, we need to run
>> - * the queue to avoid I/O hang.
>> + * If the device state changes to SDEV_RUNNING, we need to
>> + * 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);
>
> I am wondering does any of this need to be done with the device state mutex held?
>
> Thanks,
> John
To ensure that the rescan is invoked only in the running state.
Thanks.
>
>> + }
>> mutex_unlock(&sdev->state_mutex);
>> return ret == 0 ? count : -EINVAL;
>>
>
> .
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
2021-07-27 3:44 [PATCH v2] scsi: Fix the issue that the disk capacity set to zero lijinlin3
` (2 preceding siblings ...)
2021-07-27 8:48 ` John Garry
@ 2021-07-29 3:37 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2021-07-29 3:37 UTC (permalink / raw)
To: linux-kernel, jejb, linux-scsi, lijinlin3
Cc: Martin K . Petersen, bvanassche, yanaijie, wubo40, john.garry,
linfeilong
On Tue, 27 Jul 2021 11:44:55 +0800, lijinlin3@huawei.com wrote:
> After add physical volumes to a volume group through vgextend, kernel
> will rescan partitions, which will read the capacity of the device.
> 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, the capacity of the device will be set to zero in
> read_capacity_error(). However, the capacity of the device can't be
> reread after reset the device status to running, is still zero.
>
> [...]
Applied to 5.14/scsi-fixes, thanks!
[1/1] scsi: Fix the issue that the disk capacity set to zero
https://git.kernel.org/mkp/scsi/c/d5c8db0e5cd4
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-07-29 3:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 3:44 [PATCH v2] scsi: Fix the issue that the disk capacity set to zero lijinlin3
2021-07-27 3:25 ` Martin K. Petersen
2021-07-27 6:15 ` lijinlin
2021-07-27 3:39 ` Bart Van Assche
2021-07-27 8:48 ` John Garry
2021-07-27 12:08 ` lijinlin
2021-07-29 3:37 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).