From patchwork Tue Oct 25 10:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 10664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp907374wru; Tue, 25 Oct 2022 02:51:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nCuG+d2Xa+o27j6sob3b4NvOKiT0mI44KVucB+MwOTB3qn3QeNC6IJw1CHZzWQilvldLP X-Received: by 2002:a05:6402:a46:b0:461:ed76:cb56 with SMTP id bt6-20020a0564020a4600b00461ed76cb56mr6067824edb.264.1666691465469; Tue, 25 Oct 2022 02:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666691465; cv=none; d=google.com; s=arc-20160816; b=Z5vrmIol/JiNsQy/+uRfmOSSwYpniiw7OSPFGp/cThwr9gFIK/jyFJRWP41T+1Dunx hPPLnxXyGiUCCrZTbRrgRXWJ23dMZi0yqNPdq8kRXEvs854zlSXxXoeJ/lerzOfphTzJ ke01JyHUMjWRK6ZHzvKe8siy+mjaWCjxxphy9bwvdz/33/uGd6jEz7jNl3xvnctDwatt NnJZJWn+KiQl8LmHark+jt1T7zDXaNRITslojeAM/vFg6/9QmXb2a0bRaH0OomSeVwBj mTTbJwrMP6CVZ0VHq2UaxY2LyGYRsylN9wrkjmUWTOMbgYZj8qEnvwba18HYTmWc/5wz rgAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=i+6xc6vyImYhdJ+LENv/mkNCXJV0E6KkFR6KXHgG7bk=; b=AliPwmsk06kDPnGB9zrhFnraq/9rYglJGswUVEhEFNSORwO5gRrOLR35kAoMMpAvkO 4iXK30uxtRInwlfFkh99GbK7hQNBlafb0fNAmJfU9QdTFNRYWc7TXPTAPF2GL7qNGrso fn7DjN5IXdPihc02Fr6+xoQVBm288r4auUuPMLqFjf6gLfD9G4SiluNBInzsSN4F/4vA wfNLXvuEAbLEQi5m1qX/daMOqN6IGWg9zNhhiMapA36gFP4af5bEEmGBuJOyXLvahcId pW23Bwy5ej0jXHphPZz4sa2gnqhVQhGutGOB4nmF7ON1tgVIvBLjxqGYhkEnv7a7f5Qo Y2WQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a056402181200b00461b93cfe9dsi2095596edy.55.2022.10.25.02.50.40; Tue, 25 Oct 2022 02:51:05 -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 S231640AbiJYJsN (ORCPT + 99 others); Tue, 25 Oct 2022 05:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbiJYJsB (ORCPT ); Tue, 25 Oct 2022 05:48:01 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF17C118764; Tue, 25 Oct 2022 02:47:58 -0700 (PDT) Received: from fraeml708-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MxRsm01JJz6HJLh; Tue, 25 Oct 2022 17:46:36 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml708-chm.china.huawei.com (10.206.15.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 11:47:57 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 10:47:52 +0100 From: John Garry To: , , , , , , , , , CC: , , , , , John Garry Subject: [PATCH RFC v3 01/22] blk-mq: Don't get budget for reserved requests Date: Tue, 25 Oct 2022 18:17:55 +0800 Message-ID: <1666693096-180008-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1666693096-180008-1-git-send-email-john.garry@huawei.com> References: <1666693096-180008-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747652670337761584?= X-GMAIL-MSGID: =?utf-8?q?1747652670337761584?= It should be possible to send reserved requests even when there is no budget, so don't request a budget in that case. This comes into play when we need to allocate a reserved request from the target device request queue for error handling for that same device. Signed-off-by: John Garry --- block/blk-mq.c | 4 +++- drivers/scsi/scsi_lib.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 260adeb2e455..d8baabb32ea4 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1955,11 +1955,13 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list, errors = queued = 0; do { struct blk_mq_queue_data bd; + bool need_budget; rq = list_first_entry(list, struct request, queuelist); WARN_ON_ONCE(hctx != rq->mq_hctx); - prep = blk_mq_prep_dispatch_rq(rq, !nr_budgets); + need_budget = !nr_budgets && !blk_mq_is_reserved_rq(rq); + prep = blk_mq_prep_dispatch_rq(rq, need_budget); if (prep != PREP_DISPATCH_OK) break; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fa96d3cfdfa3..39d4fd124375 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -298,7 +298,8 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd) if (starget->can_queue > 0) atomic_dec(&starget->target_busy); - sbitmap_put(&sdev->budget_map, cmd->budget_token); + if (!blk_mq_is_reserved_rq(scsi_cmd_to_rq(cmd))) + sbitmap_put(&sdev->budget_map, cmd->budget_token); cmd->budget_token = -1; }