LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: lijinlin <lijinlin3@huawei.com>
To: John Garry <john.garry@huawei.com>, <jejb@linux.ibm.com>,
	<martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <bvanassche@acm.org>, <yanaijie@huawei.com>,
	<linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero
Date: Tue, 27 Jul 2021 20:08:41 +0800	[thread overview]
Message-ID: <b507879a-8bfe-ed3e-dba6-328d349d2f1f@huawei.com> (raw)
In-Reply-To: <21370ef0-88c0-e0b7-6099-4e3ee7af502f@huawei.com>

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;
>>
> 
> .

  reply	other threads:[~2021-07-27 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27  3:44 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 [this message]
2021-07-29  3:37 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b507879a-8bfe-ed3e-dba6-328d349d2f1f@huawei.com \
    --to=lijinlin3@huawei.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=wubo40@huawei.com \
    --cc=yanaijie@huawei.com \
    --subject='Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).