Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp1177403rdb; Fri, 1 Sep 2023 15:41:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW4NZgfHVpZtGJNopNmOPvFYmHONzfrt7igOfkLLczO6Er+Z7T47XQJBBK3AHguSIXs+9A X-Received: by 2002:a05:6a20:8e1b:b0:14c:83a0:2aa with SMTP id y27-20020a056a208e1b00b0014c83a002aamr4937186pzj.53.1693608105888; Fri, 01 Sep 2023 15:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693608105; cv=none; d=google.com; s=arc-20160816; b=nd+xlTcpKlninegh1zWaQn4CbJ9nmVHfZvgSWBEDX85RRywqbezNOeOid9pzZi4Xyf 9RlQmAvMHO0JfY7Qx3XDKNfolVGFSzPiD3eB68FaoUqzq5lnQz0oNCNnQy+EXp9cXNuM N4i6DKuH6651LW+v1fhYA+FSeARMt6WvJyhj+P1E5of2A6UltjiN5gfgW0txb1c5hO/E God1Bjtb219TRossn/v79K6KTSgefo0bvn07Q4Qv5WdMEuC43+FakuamLRgdNT3q/vbb 9Fj/oishGUhEH5xAOPrqa9tu1hLpiOWmugwV0qFnli1dSn89BnS0QyNQXAmc+i59/ON5 EnPg== 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=2s/zlVYSIErzg4wmi4OznJ2/v6HiKNY5zCBQ+/11fzk=; fh=U8QwZ5xHaU2/8ln497S/E2sKzHGkM9mdrpYdmq3DJOs=; b=o5Cw9CEweK1lzK1KkIiifR65QFRPz/Ip55zVqZ7QzIjyZ0+BA7vOakq3AQJqrtjkhG Srqs5BNwOOAmbhLiF5in4ccgSUfYPd3n70b2ml+myBEsG86tWcSfbIl0RbTeVCviCpzk wp7f2qAyQ0SZosNCeAcqpDOOIBHys00ArcqR64IGQvB5JGQ8fvq54beDqgj15lgf2sUo orLecoZ8b4Hu9ZcyzC1w7ssYqDgtTloDRWTMUYW0/RChYwp91lYQsZxNHBxS/CBuB1BO Qhj2UP+djXjsxJke7fzwlJYkJitKfneTFMo+FjWgC8m+jdRjEzdmkYp0zILDNsFQ32Fw yJYA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a9-20020a656549000000b0056341268ed7si3597648pgw.853.2023.09.01.15.41.32; Fri, 01 Sep 2023 15:41:45 -0700 (PDT) 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 S1348968AbjIAJm1 (ORCPT + 99 others); Fri, 1 Sep 2023 05:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348905AbjIAJmM (ORCPT ); Fri, 1 Sep 2023 05:42:12 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E531717; Fri, 1 Sep 2023 02:41:59 -0700 (PDT) Received: from kwepemm600012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RcY0v3ZpBzrSFC; Fri, 1 Sep 2023 17:40:15 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm600012.china.huawei.com (7.193.23.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 1 Sep 2023 17:41:56 +0800 From: Wenchao Hao To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: Hannes Reinecke , , , , Wenchao Hao Subject: [RFC PATCH v2 09/19] scsi: core: increase/decrease target_busy without check can_queue Date: Fri, 1 Sep 2023 17:41:17 +0800 Message-ID: <20230901094127.2010873-10-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230901094127.2010873-1-haowenchao2@huawei.com> References: <20230901094127.2010873-1-haowenchao2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600012.china.huawei.com (7.193.23.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 This is preparation for a genernal target based error handle strategy to check if to wake up actual error handler. Signed-off-by: Wenchao Hao --- drivers/scsi/scsi_lib.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index db0a42fe49c0..4a7fb48aa60f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -293,8 +293,7 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd) scsi_dec_host_busy(shost, cmd); - if (starget->can_queue > 0) - atomic_dec(&starget->target_busy); + atomic_dec(&starget->target_busy); sbitmap_put(&sdev->budget_map, cmd->budget_token); cmd->budget_token = -1; @@ -1311,10 +1310,10 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost, spin_unlock_irq(shost->host_lock); } + busy = atomic_inc_return(&starget->target_busy) - 1; if (starget->can_queue <= 0) return 1; - busy = atomic_inc_return(&starget->target_busy) - 1; if (atomic_read(&starget->target_blocked) > 0) { if (busy) goto starved; @@ -1339,8 +1338,7 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost, list_move_tail(&sdev->starved_entry, &shost->starved_list); spin_unlock_irq(shost->host_lock); out_dec: - if (starget->can_queue > 0) - atomic_dec(&starget->target_busy); + atomic_dec(&starget->target_busy); return 0; } @@ -1784,8 +1782,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, out_dec_host_busy: scsi_dec_host_busy(shost, cmd); out_dec_target_busy: - if (scsi_target(sdev)->can_queue > 0) - atomic_dec(&scsi_target(sdev)->target_busy); + atomic_dec(&scsi_target(sdev)->target_busy); out_put_budget: scsi_mq_put_budget(q, cmd->budget_token); cmd->budget_token = -1; -- 2.35.3