Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2242381rdg; Sun, 15 Oct 2023 19:09:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYq8I8C7vTgxTD5eu6Ebsp4dF/T1HD9KECh4VbrbL0gnR2SxRs89NoqWO5663w+oS7dtze X-Received: by 2002:a17:90a:5d:b0:27d:5588:b3ff with SMTP id 29-20020a17090a005d00b0027d5588b3ffmr3257245pjb.4.1697422165131; Sun, 15 Oct 2023 19:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697422165; cv=none; d=google.com; s=arc-20160816; b=PpgGZ6h2gTBUN3dNOgTBfnQXzCpaTST5z5G8nQ5XUVYYxYG5j3x2u/y+DDZP8Hza+l ZdKAQwaIYmwVF6zu+tZ+zbpuE7AI6KV1kcafFAl9a71xx/KHrOwiKCcUvLXGIO7KHIeM uH46s2fc2YzywwdwAbiTOi+xH0N/vz2vjXoRirumGuUX1DlDy7zBFQ4qpZIomMUAdwx9 SaFzIu56hKTIO3ya/LhCdIEUWKLL0U4k1JGPlKAsHCYi95CWwcHM3bRPb9U7eqVdIE++ RWBh/LOrdZN9x0WKtUIEgpMATytN0IZSxq7fhqsrGK3IljP9ZjhCK7NLLhjzKpL0iB3O 22uA== 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.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s64-20020a17090a2f4600b002772ff87ee4si5282912pjd.82.2023.10.15.19.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 19:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5EC568068974; Sun, 15 Oct 2023 19:09:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjJPCJG (ORCPT + 99 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 15 Oct 2023 19:09:17 -0700 (PDT) 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; } /* -- 2.32.0