From patchwork Wed Nov 23 12:21:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 24935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2754781wrr; Wed, 23 Nov 2022 04:26:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7g1f1GTO9nEMCfiHhmAn3AMhm9YAbdYCb0no1vTxXOdaiLheIqUCzUQ+7n4z/JkzdBdH4P X-Received: by 2002:a17:90b:128b:b0:20a:f469:7307 with SMTP id fw11-20020a17090b128b00b0020af4697307mr36723165pjb.213.1669206362486; Wed, 23 Nov 2022 04:26:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206362; cv=none; d=google.com; s=arc-20160816; b=woOZoSwO/BhkYHk2ZNFZKmQTIvIqRgAgvKXMkdeHEHcUKWJpyJi6F9Xmb6mh2qUHTx y1NcKWo0pCXSze/N9AlWD8qTEVlelncGyIzPStiCwvjwPQRmpFgBwzg98ZC8Qpt+5FFL BZLPHV+NB9Kj90ELkWeeHECdiN97tQtKUpgDxXje/Nze655aTT2aqof5AQ3/EjFB0K0r uLi6XABo7KWHKrgSb1ouwfGrhCM80C6gT/VwDsEqRbZ+FVOq548iglNK+u5uP3NbhAga xCKbVfa/WeIpmDB3P8NMwmDxs+Y3cgK0lKySZiLka7OqnOojC1TbcmGwtEXCLvmPy14+ AuHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mdMLkH8WXDq8s5x1lp001lJN9pfuCaqEbEFynQkUd3I=; b=Q+79tZBCdKK/DnCsqVe2Io878YEaML3Tv8e6em11kc8hCUmSAzEmoYQpZraV9bq3So PTDbXH0wRnRL8G1YE1ppcmhblEiDbtt/Uam1zEKCcjCyXsVeHHT9yhYrW/1N/9KzYHzJ lUKu2ecmw5aW5JFIP8gZtST/9KkLRkvQfF/BKhYcf52Zl6dx25lBySjs/fAwWihOyR8Y obgzsZ1a0SvFhGZ8lskCU9Hu1HJjqAq8giQ0+rvan02OeaFd/wpo01PNpqgUYXY+dfkY A24QdwhP3m6daLo26WCb3+R12g7rF4MTvfu1vZR5/BMJ0O/Vn1vd8qQqiEstJqjvobvH aMGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a635348000000b0047704a39c4asi17117568pgl.504.2022.11.23.04.25.49; Wed, 23 Nov 2022 04:26:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236038AbiKWMWJ (ORCPT + 99 others); Wed, 23 Nov 2022 07:22:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236376AbiKWMVy (ORCPT ); Wed, 23 Nov 2022 07:21:54 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D77C3FB89; Wed, 23 Nov 2022 04:21:53 -0800 (PST) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NHKrz6K9TzqSX5; Wed, 23 Nov 2022 20:17:55 +0800 (CST) Received: from dggpemm500017.china.huawei.com (7.185.36.178) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 20:21:51 +0800 Received: from build.huawei.com (10.175.101.6) by dggpemm500017.china.huawei.com (7.185.36.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 20:21:50 +0800 From: Wenchao Hao To: Lee Duncan , Chris Leech , "Mike Christie" , "James E . J . Bottomley" , "Martin K . Petersen" , , CC: , , , Wenchao Hao Subject: [PATCH v3 1/2] scsi: increase scsi device's iodone_cnt in scsi_timeout() Date: Wed, 23 Nov 2022 20:21:36 +0800 Message-ID: <20221123122137.150776-2-haowenchao@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221123122137.150776-1-haowenchao@huawei.com> References: <20221123122137.150776-1-haowenchao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500017.china.huawei.com (7.185.36.178) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289730568244844?= X-GMAIL-MSGID: =?utf-8?q?1750289730568244844?= If an scsi command time out and going to be aborted, we should increase the iodone_cnt of the related scsi device, or the iodone_cnt would be less than iorequest_cnt Increase iodone_cnt in scsi_timeout() would not cause double accounting issue, briefly analysed as following: - we add the iodone_cnt when BLK_EH_DONE would be returned in scsi_timeout(), so the related scsi command's timeout event would not happened - if the abort succeed and do not retry, the command would be done with scsi_finish_command() which would not increase iodone_cnt; - if the abort succeed and retry the command, it would be requeue, a scsi_dispatch_cmd() would be called and iorequest_cnt would be increased again - if the abort failed, the error handler successfully recover the device, do not retry this command, the command would be done with scsi_finish_command() which would not increase iodone_cnt; - if the abort failed, the error handler successfully recover the device, and retry this command, the iorequest_cnt would be increased again Signed-off-by: Wenchao Hao Reviewed-by: Mike Christie --- drivers/scsi/scsi_error.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index be2a70c5ac6d..613d5aeb1e3c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -354,6 +354,7 @@ enum blk_eh_timer_return scsi_timeout(struct request *req) */ if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state)) return BLK_EH_DONE; + atomic_inc(&scmd->device->iodone_cnt); if (scsi_abort_command(scmd) != SUCCESS) { set_host_byte(scmd, DID_TIME_OUT); scsi_eh_scmd_add(scmd); From patchwork Wed Nov 23 12:21:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 24936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2754863wrr; Wed, 23 Nov 2022 04:26:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Z74ilj6VZ2qbaUL2bZlRZklcMUerFgDpsGyQ7/5phuZI8eVMaComVn+TiysQV1JpZUr91 X-Received: by 2002:a17:902:edcd:b0:188:d4ea:2565 with SMTP id q13-20020a170902edcd00b00188d4ea2565mr10656727plk.30.1669206372640; Wed, 23 Nov 2022 04:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206372; cv=none; d=google.com; s=arc-20160816; b=jevhpFCsXBvZpL/xgbHgK7YNeqwcj0yC4jlQtjNvz4wtBUbHiR4MjxQzp61zX4glB9 d81DJ7Bo1MQJmdyq6+3fW2WBPFzyfBgEBDn4D6fgRmfgQ8ZZepp0+KmT20cA1+EaKsui CKVlHHLQeHgxwTU3lhfJjdlB5SoO1kMyd/HCjN1TTh9JmXAMWfF2fw2mqAcXbL9iqEsk QCa178icP2uPhxcKnM+yDB3A4GFVSkIagntHgOCqENf6/ZICBqErcqbh0HYdkUMzGpgP iGP1Wn1+QW8M2gUc7I1DfugXCToo9gvk8wrH1G0Z/Kq3gtXHJPa3cjXOXLEN8XezGcAW UXQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HMMHGb4YeWCEe58+IL/3PmOmedDUK7noYyhiLZwiQBw=; b=nncXvaOiz8fJNeWBTMMHHZpNP4BRJ6B4UC/KFsZbIuGzJeLa/5VozYCG6HK6NmfaBr NcT6INd61xjToTnrh08Q3MtxP5RvxZYYHI0UyleQehKEUVofYtl1mhsH2yDkttL4F+dK sAZXEx8yL24aEPBpNtCIj3uieTY3+XzGwk/OD0Vo9108pyDeYs7MQXTzKMUNERm5Y1uP j36ijAggw/EZBNhv9mhdy/blJai2Tsb1hum8P0G/MgVrC8o2cDGjSaSMebiTd0BRlwcj lS/wpLYt01vAFF1VBYqybUFaAm/LbjC6XKT43+O1GRzqiM0x5uICefpCzL/GPY1ezeMx y4bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja1-20020a170902efc100b001891509807fsi9897579plb.575.2022.11.23.04.25.59; Wed, 23 Nov 2022 04:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237192AbiKWMWN (ORCPT + 99 others); Wed, 23 Nov 2022 07:22:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236498AbiKWMVy (ORCPT ); Wed, 23 Nov 2022 07:21:54 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C3AF3F077; Wed, 23 Nov 2022 04:21:53 -0800 (PST) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NHKwx5BjLzRnsC; Wed, 23 Nov 2022 20:21:21 +0800 (CST) Received: from dggpemm500017.china.huawei.com (7.185.36.178) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 20:21:51 +0800 Received: from build.huawei.com (10.175.101.6) by dggpemm500017.china.huawei.com (7.185.36.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 20:21:51 +0800 From: Wenchao Hao To: Lee Duncan , Chris Leech , "Mike Christie" , "James E . J . Bottomley" , "Martin K . Petersen" , , CC: , , , Wenchao Hao Subject: [PATCH v3 2/2] scsi: donot increase scsi_device's iorequest_cnt if dispatch failed Date: Wed, 23 Nov 2022 20:21:37 +0800 Message-ID: <20221123122137.150776-3-haowenchao@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221123122137.150776-1-haowenchao@huawei.com> References: <20221123122137.150776-1-haowenchao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500017.china.huawei.com (7.185.36.178) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289741453304585?= X-GMAIL-MSGID: =?utf-8?q?1750289741453304585?= If scsi_dispatch_cmd() failed, the scsi command did not send to disks, so it would never done from LLDs. scsi scsi_queue_rq() would return BLK_STS_RESOURCE if scsi_dispatch_cmd() failed, the related request would be requeued, and the timeout of this request would not fired any more, so no one would increase iodone_cnt which matches with this increase of iorequest_cnt. Signed-off-by: Wenchao Hao Reviewed-by: Mike Christie --- drivers/scsi/scsi_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ec890865abae..a29d87e57430 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1464,8 +1464,6 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) struct Scsi_Host *host = cmd->device->host; int rtn = 0; - atomic_inc(&cmd->device->iorequest_cnt); - /* check if the device is still usable */ if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { /* in SDEV_DEL we error all commands. DID_NO_CONNECT @@ -1764,6 +1762,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, goto out_dec_host_busy; } + atomic_inc(&cmd->device->iorequest_cnt); return BLK_STS_OK; out_dec_host_busy: