From patchwork Wed Oct 18 11:37:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 154841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4724799vqb; Wed, 18 Oct 2023 04:38:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvfGaQMWqjv4ski5c2U7RU6fn3WS2EUl4kcd9KCU/Ojeolsj7Y182xkOBl/rgn/ywGXmUX X-Received: by 2002:a05:6a20:c182:b0:13d:fff1:c672 with SMTP id bg2-20020a056a20c18200b0013dfff1c672mr5370814pzb.4.1697629124030; Wed, 18 Oct 2023 04:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697629124; cv=none; d=google.com; s=arc-20160816; b=clXTn6PF+VKuM8Hyf2gflnIFBTmwS6NLgpYJHegxhVaw/pxllkRNZ6ctoXgAR5A6a+ PE33lTNs4j4p7/lKg7G10+2IxgvfvI+IGqX0cEffqX6n+vrHMcySADyL7vqde76bo3rv 7ijg8y8l1xvNqkTU/UKN5W95i5j/QNGBraRibzIRQBESouK6PAtx2sT/JJHRG1tix71a hPETro83uOCRRetSUwv8QXh7tESTCzMSKumMOCQ9AdMBzzb3bEMVPJpsHZRDiKwWezBX rSB2TRb/8MxGo501pmD8b0vatSuAlnN9EaXhuVFFxOum5nb1Jr+mS5NWglXhvaOjKt3e gVXQ== 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=cPEVmYch9XYXeyMUpU0fwXr02FfPK4ytNh9rPl5V+PU=; fh=eCnJ8dvt+KkuS6aWX+B9QrxoJYHNRCqsmb8Kf0CFQHo=; b=jVftCOJwGbSxkIqgHHYcw4kwNgTBcVf/WbJzXFRLzLFJKnNxSkNO//mWbq4uQOjH0N 2SNawWs84rBon99MakJ2ywV0nLirwhzTvvSLy2/MKC+4m0m6JlvL8T+034FUs8ZcqTRJ rzrpkDBByyr1OFo7J9dp1tXViWdlvIDFGb0H0jKmqHxfN7790x3bbWMRBqLYSBS/tXO0 WNUi8/XoXUmkcdJqbll4RevOhDwSTyt4J3yigSYfGmmIqRTwOFQxegZ0L1tsd6EJ9MJ/ rUQW1Us7hFnypyOgsXtnA3NV6070jyi9SWV3CUJ93IiFB0rVpKNkGoVoK4RWH7OD8Qtz E2Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id 26-20020a17090a005a00b00277277fd2besi953209pjb.190.2023.10.18.04.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1EC55802372E; Wed, 18 Oct 2023 04:38:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbjJRLi1 (ORCPT + 24 others); Wed, 18 Oct 2023 07:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235236AbjJRLiP (ORCPT ); Wed, 18 Oct 2023 07:38:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67BED76; Wed, 18 Oct 2023 04:38:03 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S9TJs0nwjzRt83; Wed, 18 Oct 2023 19:34:21 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 19:38:00 +0800 From: Wenchao Hao To: "Martin K . Petersen" , Bart Van Assche CC: "James E . J . Bottomley" , , , , Wenchao Hao Subject: [PATCH v3 1/2] scsi: core: cleanup scsi_dev_queue_ready() Date: Wed, 18 Oct 2023 19:37:45 +0800 Message-ID: <20231018113746.1940197-2-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231018113746.1940197-1-haowenchao2@huawei.com> References: <20231018113746.1940197-1-haowenchao2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:38:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780093156109721607 X-GMAIL-MSGID: 1780093156109721607 This is just a cleanup for scsi_dev_queue_ready() to avoid redundant goto and if statement, it did not change the origin logic. Signed-off-by: Wenchao Hao Reviewed-by: Bart Van Assche --- drivers/scsi/scsi_lib.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index aca57c3ab626..cf3864f72093 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1251,28 +1251,26 @@ static inline int scsi_dev_queue_ready(struct request_queue *q, int token; token = sbitmap_get(&sdev->budget_map); - if (atomic_read(&sdev->device_blocked)) { - if (token < 0) - goto out; + if (token < 0) + return -1; - if (scsi_device_busy(sdev) > 1) - goto out_dec; + if (!atomic_read(&sdev->device_blocked)) + return token; - /* - * unblock after device_blocked iterates to zero - */ - if (atomic_dec_return(&sdev->device_blocked) > 0) - goto out_dec; - SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev, - "unblocking device at zero depth\n")); + /* + * Only unblock if no other commands are pending and + * if device_blocked has decreased to zero + */ + if (scsi_device_busy(sdev) > 1 || + atomic_dec_return(&sdev->device_blocked) > 0) { + sbitmap_put(&sdev->budget_map, token); + return -1; } + SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev, + "unblocking device at zero depth\n")); + return token; -out_dec: - if (token >= 0) - sbitmap_put(&sdev->budget_map, token); -out: - return -1; } /* From patchwork Wed Oct 18 11:37:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 154840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4724758vqb; Wed, 18 Oct 2023 04:38:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFro+aK0XZNLZP+DZZrcoeV0qd/avRrOoHCZ9v7A1DDZgLoTk28S81U8RuHcF/Y8nNSDMx4 X-Received: by 2002:a17:90b:4a0b:b0:27d:4d4d:3b19 with SMTP id kk11-20020a17090b4a0b00b0027d4d4d3b19mr5322788pjb.0.1697629117630; Wed, 18 Oct 2023 04:38:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697629117; cv=none; d=google.com; s=arc-20160816; b=0xYM9o/SVgDvbsFBfTFgdJLRQgJXY2oy4/xi/gfmxYAZSZXXyFITZlQsi6NKFlTDHp SwBHp37CT6+BKF0pXJ3fgGjxAovcw3f600dnIW3NwPs7eGLNHY6bPTQk+tnUBJjPamM8 1rVB/CNd8Hg8OoOXjOvK/1d4WcA62u1dU2+t3/TWW8Yo7SNjNFaJluIUxooJ/znIDI6B bo/0iqRay/L9ACFa5oR6T6EppVIwEne9lsJRCXlKqtXCD7KWY/pBtmYBTGsaN7Ou0+rH pcVUc9b3oNlWrYV2qYI1YL+upWh7yCvAvWaZ71nqyG2gc1NqPhAMUt4X7scUTLEW9uug o9fw== 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=1pZDs/s5AomhMzui9dqhDW4eUjvM16hLt14xCE41J/Y=; fh=eCnJ8dvt+KkuS6aWX+B9QrxoJYHNRCqsmb8Kf0CFQHo=; b=Ax8zF2ORLLZHj2pZ2QhPoVWZq7PrUkjlvMpPfTei82aJ1gKRuUizjYgvtSFQcw/ZR9 iWilkksv9VJkgKvWVQZZ0jX1peIPalpyc52vsbDPqvhnVgQSRwSD1w/Qg3M5MD6/m0rQ w1qCdneob9WTKMgDXho0CYFqTdhtXz0YZ/8CGgBEpgy/Qby8BtzmMA/qvTkf/ihCJVM5 NvTLV1Duswr4O9OEWOGRe8by116n/+C8R3VPpE0L04QxSC80Af22S23pXzszVIbtJZb5 FB6RVAZ07L2bWEc1NCwDE/q/DyM1CvPx2hGrJ3pqBNc/qwSGmjm5iRyefQ/xRAgTfrV3 1Drg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l62-20020a639141000000b005b5df8bf695si1943686pge.328.2023.10.18.04.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:38:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 018E2813A58E; Wed, 18 Oct 2023 04:38:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235211AbjJRLid (ORCPT + 24 others); Wed, 18 Oct 2023 07:38:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235197AbjJRLiQ (ORCPT ); Wed, 18 Oct 2023 07:38:16 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76BA810C1; Wed, 18 Oct 2023 04:38:04 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S9TKz2WF6z15NQC; Wed, 18 Oct 2023 19:35:19 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 19:38:01 +0800 From: Wenchao Hao To: "Martin K . Petersen" , Bart Van Assche CC: "James E . J . Bottomley" , , , , Wenchao Hao Subject: [PATCH v3 2/2] scsi: Add comment of target_destroy in scsi_host_template Date: Wed, 18 Oct 2023 19:37:46 +0800 Message-ID: <20231018113746.1940197-3-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231018113746.1940197-1-haowenchao2@huawei.com> References: <20231018113746.1940197-1-haowenchao2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:38:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780093149886614447 X-GMAIL-MSGID: 1780093149886614447 Add comment to tell callback function target_destroy of scsi_host_template must not sleep. Signed-off-by: Wenchao Hao Reviewed-by: Bart Van Assche --- include/scsi/scsi_host.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 49f768d0ff37..2c61dd30d766 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -245,6 +245,9 @@ struct scsi_host_template { * midlayer calls this point so that the driver may deallocate * and terminate any references to the target. * + * Note: This callback is called with the host lock held and hence + * must not sleep. + * * Status: OPTIONAL */ void (* target_destroy)(struct scsi_target *);