Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2691600rdb; Fri, 22 Sep 2023 06:07:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuPqKqK93WiG5hVJiOhpRrFIFL3xoAQT/F6GqXB/0Wq550Z5UbAMrFCKuOZR5Ol0prozVk X-Received: by 2002:a17:903:2810:b0:1c5:cebd:ee83 with SMTP id kp16-20020a170903281000b001c5cebdee83mr4602351plb.54.1695388071562; Fri, 22 Sep 2023 06:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695388071; cv=none; d=google.com; s=arc-20160816; b=ZSvms0ntC6MEbQB5KkmW04gm8QXQzZ2vrjIdV0K9OaK+v1Aj+HqO6tuzPjg4YTmBLH dn3TjP3ga9NiSaLWnnp53yl7z7pB1lW2GuMRE2iGwg0YETnQ2MnICXFYXTTZwB2YPzlW VTCVLaAvzvrdLH8Vvf9VIF10L7sig5xOSv7igESMJ5zE0cDdpSImpRcR4WQ5J+/5koTV wMMow34D88m8wGEjqoWOV5M1AGU5l7iHRqqZ+Udghvk3p5KOAI1aokz/SFdqajmzHYOL LF6fykQXnLJ6lcHL9lYPj2h1WQzgv53K4YoaNvVrqWl/ENv7VFxWIbtpf+9fti6xCfj3 xqfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=Wy7P1iFXeqsvz/8pNRnHifKZlT3r1E+U4CFwH8MtEtI=; fh=UEpFMKOqyweapDowiE7VvOt2ySza3HVObMQ+Ezn7xQ0=; b=kbvFj/mm3r2PvdubSFsHYpOw6ttWhsJbInI2g5PUwOITRcFZ1UAyFgyn2hlZiRd+C4 BLVrLimxgL0OnALksy/E6q1QQwg18Msw4hY/1dtakjVWpkqpexDNkZv2OAfHSrM4XLF1 J9LquvUcQEOTYaBiNqCWEnU2QC3FjeXNcWwNwlVje82YA1tC21dCN36n66yCumyCbdt+ Bsf+7s6ILN6PXFMSnJUPBvlBWy+CRBd+knlrq3S4t/TJd5u29PvzArD8evty1zNv/qaD DJJ6isf8LUCYbU8yOTY2U5cBvR39L6lZThj4j0jk+Gm2GtFvMYTGFlreIUOFz9gNiEKv /Adg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a9Hq6mkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id o2-20020a170903210200b001c59c73c937si3614057ple.598.2023.09.22.06.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a9Hq6mkk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3FB8683C8F68; Fri, 22 Sep 2023 05:50:09 -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 S233140AbjIVMuK (ORCPT + 99 others); Fri, 22 Sep 2023 08:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjIVMuI (ORCPT ); Fri, 22 Sep 2023 08:50:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B87794; Fri, 22 Sep 2023 05:50:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9F5DC433C8; Fri, 22 Sep 2023 12:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695387002; bh=xCBIRsurVeVVeQpsNZBwynvGXg5d5UV4Dr22oeCKBHY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=a9Hq6mkkP9g0G+/1CpfRpe6A2V29UGp+HroLtkOUbjL4UhNI56ROtYigf+1xWiu6K mHmSgQS2VNJF+QxCpcqH9uZd+lBVcoMiSrPPxaGQ9wHsti4EWACeTaHfVsib6riRFs LFVcTMnhD7n+lU2FX11feyLx41cPCCddGZhmmvZAJVbvsCLyiXJVzykr39J7+fERkx swxss2UBGaR1apHxpPaCuj91Uip+WEZa5oBbmCxVAc1Y1XvErk2nVFvJP2bvtNw5R3 FY5gtwRXJ4AEja2qzAXVTp7cg10BqKn+Hau4DvC6YtPZ9ybuZeQJfD4pCBC40RZYk/ VKWX3tXKQOOpg== Message-ID: Date: Fri, 22 Sep 2023 05:50:01 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 1/2] scsi: core: cleanup scsi_dev_queue_ready() Content-Language: en-US To: Wenchao Hao , "James E . J . Bottomley" , "Martin K . Petersen" , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, louhongxiang@huawei.com References: <20230922093842.2646157-1-haowenchao2@huawei.com> <20230922093842.2646157-2-haowenchao2@huawei.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20230922093842.2646157-2-haowenchao2@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, 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]); Fri, 22 Sep 2023 05:50:09 -0700 (PDT) On 2023/09/22 2:38, Wenchao Hao wrote: > 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 ca5eb058d5c7..f3e388127dbd 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -1254,28 +1254,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; This is changing how this function works... > > - 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; ...because you reversed the tests order. > > - /* > - * 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) { And here too, you are changing how the function works. The atomic_dec may not be done if the first condition is true. > + 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; > } > > /* -- Damien Le Moal Western Digital Research