From mboxrd@z Thu Jan 1 00:00:00 1970 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 0D08CC7EE31 for ; Thu, 25 May 2023 18:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241841AbjEYS4E (ORCPT ); Thu, 25 May 2023 14:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243026AbjEYSyq (ORCPT ); Thu, 25 May 2023 14:54:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2213C24; Thu, 25 May 2023 11:46:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9EDFF61B63; Thu, 25 May 2023 18:43:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45FECC433A1; Thu, 25 May 2023 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685040219; bh=oyPpsdiiYGCTTprqxp91T5VCcifNXHdYZElVvTsCJvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cj4l1xDf48QMzHkzjnIk536ztzYRheHaz6qZHYZGvIBDQhfvBrPcDPDMI+PCEhSAF Lb3CvB9rFM5NbkP+FU3TVavxzdX3ky7C7ju8AVDAPRNrYygTncCvc6dmT3po2yixm1 9Bi9ZcJ996eOVJfZWqA6uaV9t9Kr2L2Xi8AZ9JWCIiIWSoKHTNnqFEBxsEFvJS1a83 Bi52em0A020O4Qj4CxIRG15Hr17nhdyvQFCTZjIXfGPbPMuOSbhJNbmrgWgpeVfPd7 LON3tjVtosvz9ULxj0r3WxBwHrdlg4GqOzHRx4mMUSt8p/AaXRhcsFTrj7Ape/cgoR XhV8qznAC0VIA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenchao Hao , Ming Lei , "Martin K . Petersen" , Sasha Levin , jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 22/27] scsi: core: Decrease scsi_device's iorequest_cnt if dispatch failed Date: Thu, 25 May 2023 14:42:31 -0400 Message-Id: <20230525184238.1943072-22-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525184238.1943072-1-sashal@kernel.org> References: <20230525184238.1943072-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Wenchao Hao [ Upstream commit 09e797c8641f6ad435c33ae24c223351197ea29a ] If scsi_dispatch_cmd() failed, the SCSI command was not sent to the target, scsi_queue_rq() would return BLK_STS_RESOURCE and the related request would be requeued. The timeout of this request would not fire, no one would increase iodone_cnt. The above flow would result the iodone_cnt smaller than iorequest_cnt. So decrease the iorequest_cnt if dispatch failed to workaround the issue. Signed-off-by: Wenchao Hao Reported-by: Ming Lei Closes: https://lore.kernel.org/r/ZF+zB+bB7iqe0wGd@ovpn-8-17.pek2.redhat.com Link: https://lore.kernel.org/r/20230515070156.1790181-3-haowenchao2@huawei.com Reviewed-by: Ming Lei Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 490d6c72d8bd6..8d05faf95ac3b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1534,6 +1534,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) */ SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, "queuecommand : device blocked\n")); + atomic_dec(&cmd->device->iorequest_cnt); return SCSI_MLQUEUE_DEVICE_BUSY; } @@ -1566,6 +1567,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) trace_scsi_dispatch_cmd_start(cmd); rtn = host->hostt->queuecommand(host, cmd); if (rtn) { + atomic_dec(&cmd->device->iorequest_cnt); trace_scsi_dispatch_cmd_error(cmd, rtn); if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && rtn != SCSI_MLQUEUE_TARGET_BUSY) -- 2.39.2