lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 27 Jul 2021 09:48:24 +0100
From:   John Garry <john.garry@...wei.com>
To:     <lijinlin3@...wei.com>, <jejb@...ux.ibm.com>,
        <martin.petersen@...cle.com>, <linux-scsi@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     <bvanassche@....org>, <yanaijie@...wei.com>,
        <linfeilong@...wei.com>, <wubo40@...wei.com>
Subject: Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero

On 27/07/2021 04:44, lijinlin3@...wei.com wrote:
> From: lijinlin <lijinlin3@...wei.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@...wei.com>
> Signed-off-by: Wu Bo <wubo40@...wei.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;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ