From patchwork Mon Oct 16 02:08: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: 153142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3191649vqb; Sun, 15 Oct 2023 19:09:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjUe4BRBiCz/PQ341JoPIWu4Zvnk71G5bs3ytajLMuleMUh+rcEJa0eyFaPUXsmK7Ojqnu X-Received: by 2002:a17:90b:4d86:b0:27c:fd8d:164a with SMTP id oj6-20020a17090b4d8600b0027cfd8d164amr14616503pjb.1.1697422161792; Sun, 15 Oct 2023 19:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697422161; cv=none; d=google.com; s=arc-20160816; b=jqH72axksbmdJFjoc1o+jzRKSijLxaeabcQX+BuoO+YoBgpPsc6q14JRmX6RxblM+/ 7rPXZiQkH/cdNxoLpdW6xIDQjRvvPIfZR4gLndh/Ue+SLQInZOVb25HzFI1yN43ApcSA Xb9KPtN/uvFytodmvYZT3nW/CmKU1hlPg1nZyNlJa7QDA+l4O+/i8JTcgQpwgyjkBvYu PAKi/AwDQHwvbns0BX06WjtrTHezgsAFrGXzThrq5rUckVCFMma3J3t3C1J2pzbzLxup 8UUmTmB4GpsEq2lmRTty5fsOhh4RS49d+BQnL1znHrPzQ8BOb+G/DndoF4kbIXlYPMky qYlQ== 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=p14rLW6ppMIRnnf0TrFoiiFZ8LUXBJlWt9X+vk/BEPk=; fh=ZDcIlyYggP5K3GvQBQF3K/GzUnCJV+bQb/1GDPxM7E4=; b=Y+kGupVPZsuLPS7a0U6Ajri6Zu1ApJvYptuvFFetiH1xCKTaMJi6Y8LAVa4+Xix9v9 oRxgvNdCgEOUzoOb/Am+yZ2t8XrlUzIj6XAP/T0R4WmE6Bqi0mcOL/mC4swPnvIDuDwy k/1o1pOjj9lE5tsj++QWwnNpd5pQ+Q1rStNaLvPbdVtPfxPvdca2giL7ghn41W+p2OmI glzug6jEU4L5ohhz7nJDnsTMUYcPRNyrmUttXDSy5Zi7tsnb3Lig9Z98mpqId6AIdabx k89WtBbFda+s9sKIMYnx5rXKnYsLQDgouH7wsYKfc5e3hHzJDHT68nl58gQij1FatdkU WbxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id kk15-20020a17090b4a0f00b0027d032092d7si5660363pjb.184.2023.10.15.19.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 19:09:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 3FCA780BB5EB; Sun, 15 Oct 2023 19:09:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbjJPCJG (ORCPT + 19 others); Sun, 15 Oct 2023 22:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjJPCJF (ORCPT ); Sun, 15 Oct 2023 22:09:05 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D4F3AB; Sun, 15 Oct 2023 19:09:03 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S80mn6DsfzMm19; Mon, 16 Oct 2023 10:04:57 +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; Mon, 16 Oct 2023 10:09:00 +0800 From: Wenchao Hao To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: , , Wenchao Hao Subject: [PATCH v2 1/2] scsi: core: cleanup scsi_dev_queue_ready() Date: Mon, 16 Oct 2023 10:08:46 +0800 Message-ID: <20231016020847.1270258-2-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231016020847.1270258-1-haowenchao2@huawei.com> References: <20231016020847.1270258-1-haowenchao2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 morse.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 (morse.vger.email [0.0.0.0]); Sun, 15 Oct 2023 19:09:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779876140374185010 X-GMAIL-MSGID: 1779876140374185010 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 --- drivers/scsi/scsi_lib.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 40f407ffd26f..b179c24f9c76 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1250,28 +1250,29 @@ 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; + /* + * device_blocked is not set at mostly time, so check it first + * and return token when it is not set. + */ + 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")); + /* + * unblock after device_blocked iterates 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 Mon Oct 16 02:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 153143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3191670vqb; Sun, 15 Oct 2023 19:09:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHInpbDznirR0LGFWRfIq6W+MTV+qF1b2Hpn5AB2NFsgL3ZzSj4w2aVdPBnz88MEBQmOy1k X-Received: by 2002:a05:6808:2129:b0:3ae:5aab:a6fd with SMTP id r41-20020a056808212900b003ae5aaba6fdmr41030009oiw.5.1697422164801; Sun, 15 Oct 2023 19:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697422164; cv=none; d=google.com; s=arc-20160816; b=j9ZRpQgM/PJxdsm/JfDniN+iBhY6zLtQbP94q4yL3wb1Vpt5ezbHGPhVt0rCjJzVt0 Uh0rJW0eOCUXM2ls97eQC/Q1SL/4IVXu9XJgkalnwAifvUABgOiJ/6cAuKWENLleaZCy JKKMMY+L5569nMvSvZWITAFqKVUSihEVWfJL7QbnkHazaPRfABB9Dzf9cf0W/e3+LsF0 0ksDIIiH9CSUw7Qnd5YugbVuUcpfVyyvTDppGTBfMl1+avMN/6W0AfuumwZhrq9/Y4cH Zp2r34gJO7mT5Ehe9qYTjq11IA95I0Sqv2ohqFs00iqbuGfoVgthxcC7Ry6c8ouga4VO RZdQ== 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=nY8KtV7wXdBWkQRfXLiFodakR4N32TXn3VHZcWWjMT0=; fh=ZDcIlyYggP5K3GvQBQF3K/GzUnCJV+bQb/1GDPxM7E4=; b=R0sfkAGQIAdKca9DK46IAXC0sWEEx+F5a8Dj3V4rGRhIoYTfCU0WbOmnYAffW253XG 8kgzE6cGbczpySv+IvcQqqvwt8HcJYgg+VReXJzSDcIEnseH1faX59VpPX8btpG8DVCD S4kv6k8WMtXp42G+URorPwQBO+Z6tO8qgwNVNhefkOt5dI7i+w5OQ0JKKIBb9sZ4SPgA NaQlKDr+K1sxIlaxz9XIBh+QBcTzc1ye000xZaloAF3+xEkcS2yaRLdoaoARqV0n5AO/ AGKlvfoRXeliPGFgA8zFUH0nHFYZbMwrDyWJQiYGWlPrpoPQGZXRw5AfGc+LzcGkjRHK J9mg== 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 c1-20020a056a00008100b0068fe9c452acsi2722559pfj.376.2023.10.15.19.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 19:09:24 -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 1C93F80A2658; Sun, 15 Oct 2023 19:09:23 -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 S231415AbjJPCJL (ORCPT + 19 others); Sun, 15 Oct 2023 22:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbjJPCJH (ORCPT ); Sun, 15 Oct 2023 22:09:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99327AB; Sun, 15 Oct 2023 19:09:05 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S80m31nv5zvQ5n; Mon, 16 Oct 2023 10:04: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; Mon, 16 Oct 2023 10:09:00 +0800 From: Wenchao Hao To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: , , Wenchao Hao Subject: [PATCH v2 2/2] scsi: Add comment of target_destroy in scsi_host_template Date: Mon, 16 Oct 2023 10:08:47 +0800 Message-ID: <20231016020847.1270258-3-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231016020847.1270258-1-haowenchao2@huawei.com> References: <20231016020847.1270258-1-haowenchao2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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]); Sun, 15 Oct 2023 19:09:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779876143958814558 X-GMAIL-MSGID: 1779876143958814558 Add comment to tell callback function target_destroy of scsi_host_template is called in atomic context. Signed-off-by: Wenchao Hao --- 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..2e8d77441064 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 in called with spin_lock shost->host_lock held, + * so donot call functions might cause schedule + * * Status: OPTIONAL */ void (* target_destroy)(struct scsi_target *);