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: 628167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC388C4332F for ; Wed, 23 Nov 2022 12:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236773AbiKWMWG (ORCPT ); Wed, 23 Nov 2022 07:22:06 -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 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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);