Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4076373pxv; Mon, 26 Jul 2021 20:43:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynYYx4PX+8XK78hzkaaYaawizn9ca+DB/OqJUwGmvWGvHJfEf0zhPqjrhIDcZW43j9LCiQ X-Received: by 2002:a17:907:7e89:: with SMTP id qb9mr7085521ejc.333.1627357401504; Mon, 26 Jul 2021 20:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627357401; cv=none; d=google.com; s=arc-20160816; b=qU04M6a6z0bPrax1FCUsrM9xMBUd3fGfnl7d82IdUYdWp+VS2wexasS69cEPyVgAEr KSyQATrDrjVCfZNjCjpg0fXhPA+4q8lAqFq0TxFgVcvkucDiCklqYFn9pDfaXGmhvvs2 79RaA6NltKNp1k9lhAQcoGhzznQKK9Z7iC9DOkZS8IqjSt46m4Jlc3HIM2e52j3xq4pL DgcI2ohYwKzu4H9Dlmo8LvAAzn2xa5oPw/VuZ6e63Z5onuaHoo3XJYnSpw3DhDh9XeUG phpPKJpyNIjGWBaX2itgCmU/Ulf7JLtFZcijcFOumgWWoP2NjdG/sz/iaWuyjQ9EV2qA yT5A== 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=sZkIhanFYkY2vIMYu6ANcE0looF7hlq8r4h6+faW4J0=; b=kfvODe0Lcak/7UbDeYiKWFjiO+Fl2VkWSsMib1sQqxY/ocuKBxrInOzHbLizuh1yA3 UvLZibrDMzvR+8AGtrhA/qz39HGmF1UpCEASuoI2hzd34uoBqGQIvetP9W7y1depSL8o 7hun8EmqNcseROGH5PAP9/ZpwJggeDxKihYfUhcmMKZZ3n+ZzgqPDpctZyn4fSRNTGmX bL75NzZs+cpmwbynGVwWV/lysVeiy1hhlOjjeO0xgjMB4k4CLfJo/Z5ye6SZ+QSF4H56 w4c5uY6GLtWItzHdMHY70KW36SZKraUM0hih2QkR3nhnUHEqANPq5mUK8acolvunOgm4 JiXg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si1645263edd.535.2021.07.26.20.42.58; Mon, 26 Jul 2021 20:43:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235174AbhG0C6n (ORCPT + 99 others); Mon, 26 Jul 2021 22:58:43 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:39840 "EHLO mail-pl1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235138AbhG0C6m (ORCPT ); Mon, 26 Jul 2021 22:58:42 -0400 Received: by mail-pl1-f172.google.com with SMTP id e5so12257123pld.6; Mon, 26 Jul 2021 20:39:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sZkIhanFYkY2vIMYu6ANcE0looF7hlq8r4h6+faW4J0=; b=FBg4Yi9D1YHrAeIzMzFXtaFFR3iQE0or8//6sJoCuKdMC3rRio2ALmvaMx7f3u+NPw rvimvexGMpFRRUSpwOtQuV4cqsmjqB+C2LSSfi2mJpD1ZdWPNW7iAqoQvBMXyNJAaj/q e7bz0T+kljeT/uY15kqH+cuoxiZqlL4GHzM2DDwUtGRnTrfe0WIdaX6hoxnGWBS+h8Ek UHDBgFW+UqVhKnAwDY7JcXSXKDzEUla+BqA+jIBAYzHHH0OHSYS/UxNI8T3yxM56hPTc CSRLuUIbee0/AzhtOBZgfBiSoSCNKA+LOXlr+CPSdLn49OUM7yPtLHH0O2O2mi6bsE50 VFoQ== X-Gm-Message-State: AOAM532FDVgIx6mlriiSfWA3I3w0/Wxzx/9b99l7sn4TwE0xAGknEXnc efkSY5zqTInJ8tQMKCryi4o= X-Received: by 2002:aa7:9ec3:0:b029:32b:4eb5:4bad with SMTP id r3-20020aa79ec30000b029032b4eb54badmr20957694pfq.6.1627357147654; Mon, 26 Jul 2021 20:39:07 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:d009:b5bd:a16e:1de3? ([2601:647:4000:d7:d009:b5bd:a16e:1de3]) by smtp.gmail.com with ESMTPSA id b3sm1585811pfi.179.2021.07.26.20.39.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jul 2021 20:39:07 -0700 (PDT) Subject: Re: [PATCH v2] scsi: Fix the issue that the disk capacity set to zero To: lijinlin3@huawei.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: john.garry@huawei.com, yanaijie@huawei.com, linfeilong@huawei.com, wubo40@huawei.com References: <20210727034455.1494960-1-lijinlin3@huawei.com> From: Bart Van Assche Message-ID: <54403480-2a57-ba54-57eb-927d706cafed@acm.org> Date: Mon, 26 Jul 2021 20:39:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210727034455.1494960-1-lijinlin3@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/26/21 8:44 PM, 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); > + } > 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