From patchwork Mon Aug 9 14:29:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 493880 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp2977513jap; Mon, 9 Aug 2021 07:38:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxWkadfWSYYumwRKIwb6pBGtbeNQxlugeceWH2K97MqiIUcsZie5XZ4D7rzVny1bdISa38 X-Received: by 2002:a05:6e02:106d:: with SMTP id q13mr138768ilj.164.1628519907512; Mon, 09 Aug 2021 07:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628519907; cv=none; d=google.com; s=arc-20160816; b=HKiBJEGvZldLTycd+i2IkWjP5PVYo0eKfFW4Cg7NUXoUD8HhbMMyENtUpyzlJrpKYG U1OU/s3+XWgf5+V0srU4dwms+VHkA3ZrcVpY9EYciYl+Cv9xnYCHU42wKUlw01p9kKA7 8F7OxWBBkgc4/Y2pam0R+LwbLJGdCZ7FLvYh1kDHtmzQ/mq8uG1Rv3QPftdydSXiu0gG 12RnVzXRdZ5KNwAcYDuUPPnWsUxNrDJ2OYu7StHpVeyHkMI2djK2ecnk0We9gk44NtX2 rDiSJ43PIZfeIix8AD0wNEeR3Ws3p+8D7esAB2xK8lKKuRxS1gWIISxAQWLnVZPq0V6h ZhjQ== 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=JT4/G9xcBdWi2ed/wqG19e0BBmYGdZ+ZC3pCUKXstAY=; b=t+P65KXQ/Jc/kfs1wL4zDC3Au7/u1tRRqJfsZYJMxI05K18RWUSAzpMbYFkXKb/Cpq NRWjlgTN0k1OGpT5rY5+6mQ5G1hxVCMQNVFWM14DKBcEC0oZko/bR8RHpVrycZ0Gl3Co 0T63DefL7bA03aEpkZXdyt4Hu/FIbtqntV1+SBLdu07+YzJ922EYPupyOVxd5jhOf7NG EHr9okf5G9BRJEZkwnFcez1NOuvZWH+c1/lwNdwu2lz/fuHbGT5ook1cwToRgMUoma1z G5xb83s1YZbQIOLP1e0GQE7ylrwUOZrovEy3ARta27kbpSMJ4davQOKKgxNxjBD9fDoI bavw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si61292iln.134.2021.08.09.07.38.27 for ; Mon, 09 Aug 2021 07:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235374AbhHIOio (ORCPT ); Mon, 9 Aug 2021 10:38:44 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3614 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235267AbhHIOgR (ORCPT ); Mon, 9 Aug 2021 10:36:17 -0400 Received: from fraeml712-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Gjz9k5j6mz6CB0X; Mon, 9 Aug 2021 22:34:18 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml712-chm.china.huawei.com (10.206.15.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 9 Aug 2021 16:34:48 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 9 Aug 2021 15:34:45 +0100 From: John Garry To: , , CC: , , , , , , John Garry Subject: [PATCH v2 08/11] blk-mq: Add blk_mq_ops.init_request_no_hctx() Date: Mon, 9 Aug 2021 22:29:35 +0800 Message-ID: <1628519378-211232-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1628519378-211232-1-git-send-email-john.garry@huawei.com> References: <1628519378-211232-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add a variant of the init_request function which does not pass a hctx_idx arg. This is important for shared sbitmap support, as it needs to be ensured for introducing shared static rqs that the LLDD cannot think that requests are associated with a specific HW queue. Signed-off-by: John Garry --- block/blk-mq.c | 15 ++++++++++----- include/linux/blk-mq.h | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) -- 2.26.2 diff --git a/block/blk-mq.c b/block/blk-mq.c index f14cc2705f9b..4d6723cfa582 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2427,13 +2427,15 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, static int blk_mq_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, int node) { - int ret; + int ret = 0; - if (set->ops->init_request) { + if (set->ops->init_request) ret = set->ops->init_request(set, rq, hctx_idx, node); - if (ret) - return ret; - } + else if (set->ops->init_request_no_hctx) + ret = set->ops->init_request_no_hctx(set, rq, node); + + if (ret) + return ret; WRITE_ONCE(rq->state, MQ_RQ_IDLE); return 0; @@ -3487,6 +3489,9 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) if (!set->ops->get_budget ^ !set->ops->put_budget) return -EINVAL; + if (set->ops->init_request && set->ops->init_request_no_hctx) + return -EINVAL; + if (set->queue_depth > BLK_MQ_MAX_DEPTH) { pr_info("blk-mq: reduced tag depth to %u\n", BLK_MQ_MAX_DEPTH); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 22215db36122..c838b24944c2 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -357,6 +357,13 @@ struct blk_mq_ops { */ int (*init_request)(struct blk_mq_tag_set *set, struct request *, unsigned int, unsigned int); + + /** + * @init_request: Same as init_request, except no hw queue index is passed + */ + int (*init_request_no_hctx)(struct blk_mq_tag_set *set, struct request *, + unsigned int); + /** * @exit_request: Ditto for exit/teardown. */