Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4225278pxv; Tue, 27 Jul 2021 01:51:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk7hvVl8K+YR29z6F0Ma6Ii4gsnqsnaElWE0WsVtTtUp08PjXsoJuAli6ygZ3Q7hIyyOM9 X-Received: by 2002:a05:6402:10cc:: with SMTP id p12mr26659528edu.328.1627375904787; Tue, 27 Jul 2021 01:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627375904; cv=none; d=google.com; s=arc-20160816; b=wRxNRU9/9PLGdG0J0YcUDhV+wFcoQmk9B2GyFCbKAQgd7fCbFh2FAoMIef0f85p1xW H5K5c6HsA/20rFeqNBYCUMbH3D3nw5VAqg8RPalSsMEJ54hFVhTYZYcfKZmwi9fx6Rj4 So2GkSR+MLEacBJaCpI3D6WIp+PssOj/cd4DEjrmHt0YW5RnQ1EZFDzOVQ0q49ozgp1w tYEkAK/5Fk4sxEorj0b0vAfRId6tZtomxg6ZSjlln2+z92bQNgI+8P4LlusP5IaYxu8O BFyL9aKI4vJ+Y1qoU3DwkbbZwgYYsz7Oor678akH3Nn1nP1RwQvF60RhJB7SQn0qBK3m YWqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=421ZSpHsq/erjADIgVfZbkL5BU9K48U/AL3EHa7GnZU=; b=YzTDr6S9vpWv7LrVNi9h/z0CGX2nhv5Kl2PNLAX4dnRY/kassJgvsVZOL5DL3/dQom ZuMpQfGIMYnE3UipRqkHyLQQmaiEYQphKrB/ASLhOnhVJ8Tj5fNHwNADPDGtlQpQ43T0 c6X6PHjd2LxVdKUITMJ3hoinqlQS3Eb58nY0CRv5GJe0+q5IhbwrmB/TL5LDMUAp0iDT E5z6/fPvL5Dv/X+t6Ah8fNkR6Ak6avRFdstzJRaYG3hDpQ6685ShBnm6+cpZJqprCbJL pUrh5IUoTXHM+0pAN3HXOBEAMLfftDmOrx3qVa0dTfPXogIrNdw4puyFsJ1752Rv+7lC +gzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df12si2345287edb.406.2021.07.27.01.51.21; Tue, 27 Jul 2021 01:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbhG0Isq (ORCPT + 99 others); Tue, 27 Jul 2021 04:48:46 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3497 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235923AbhG0Isp (ORCPT ); Tue, 27 Jul 2021 04:48:45 -0400 Received: from fraeml708-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GYqnd4nCDz6GDBf; Tue, 27 Jul 2021 16:33:41 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml708-chm.china.huawei.com (10.206.15.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 27 Jul 2021 10:48:44 +0200 Received: from [10.47.80.220] (10.47.80.220) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 27 Jul 2021 09:48:43 +0100 Subject: Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero To: , , , , CC: , , , References: <20210727034455.1494960-1-lijinlin3@huawei.com> From: John Garry Message-ID: <21370ef0-88c0-e0b7-6099-4e3ee7af502f@huawei.com> Date: Tue, 27 Jul 2021 09:48:24 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20210727034455.1494960-1-lijinlin3@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.80.220] X-ClientProxiedBy: lhreml752-chm.china.huawei.com (10.201.108.202) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/07/2021 04:44, lijinlin3@huawei.com wrote: > From: lijinlin > > 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 > Signed-off-by: Wu Bo > --- > 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; >