From patchwork Wed Nov 16 14:35:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 695605 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3tJmz62V6Cz9s2Q; Thu, 17 Nov 2016 01:36:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="J44LlQsi"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1c71Jv-0005c3-57; Wed, 16 Nov 2016 14:36:15 +0000 Received: from mail-pg0-f53.google.com ([74.125.83.53]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1c71Jn-0005aK-7y for kernel-team@lists.ubuntu.com; Wed, 16 Nov 2016 14:36:07 +0000 Received: by mail-pg0-f53.google.com with SMTP id f188so79584015pgc.3 for ; Wed, 16 Nov 2016 06:36:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=lw9xfFDgRokhyu/hyV1KwwvabMF09stMsq219scKRoI=; b=J44LlQsimiPeVmOrTiFOrMxEJwIxe7r4uDm4lpEqUmEYKMCxAibt2pI0GVjmHRb3EW Xv+PPOJutKd26yTlrz/BgEOq5mSZHDXhQ9iHvNtMU2BEHTa4Cdn5+JI2lJPHRxRxGsa5 nf66aJAclqCeeob+pdkWmWcO6iB5+5RkRZpcC5+VmLr4t8wQefoB48mqooi6ymfZ2/VH GcL4y9OoUdYXmWshZ3s+MMcblISOYhzOGgg5cCxl+yZj4CAeODzHp556jGOq3n4RtZN1 Iw8xYwbq8nRt4iiesIg0UmyFsgO3uVH2dKRuZslz67O+qO8OkSXMi9fe6kopdPuBu2nq iFOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=lw9xfFDgRokhyu/hyV1KwwvabMF09stMsq219scKRoI=; b=FNixXLrTnizEspR4bJrKd5z9fJl5qFjU2Gw/3swbIAqIw5k/01uZHa+czfplzbJFcD 1BH9ZUs8WRpo58AnCK7W9btp6/2myQiCGiGY/t/xEvWV41mhKyr+rB/egwPySD8fh4MS BwqOYy0OC6RLkl+D2PyobrjNbh2OtAAUPd65EFl+7cRrPGcPk6kwaJw/cxxcAzTKQWI9 vxrKbZR9HINwd3C8oF66fbWQrw3vK9poIveuVvabUjQNukrm2NdyeM5YkfcrYPxqVIL2 FeTMDpMfFwP2Avf5CYQh67dOtZAq7oFIMc6ZaYoxrUmrK9rlDpEFIHClGouOHTmTw/ok c9hw== X-Gm-Message-State: ABUngvd2tQ6MTSLif1/gIziiE2FRbrEi0aFkaTO4blTJemQmVrgVvZpcrArEp8G3Vn/z8Pdl X-Received: by 10.99.136.194 with SMTP id l185mr8980298pgd.106.1479306965585; Wed, 16 Nov 2016 06:36:05 -0800 (PST) Received: from localhost.localdomain (host-174-45-44-32.hln-mt.client.bresnan.net. [174.45.44.32]) by smtp.gmail.com with ESMTPSA id a24sm2078728pfh.57.2016.11.16.06.36.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 06:36:05 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/5] blk-mq: add blk_mq_alloc_request_hctx Date: Wed, 16 Nov 2016 07:35:52 -0700 Message-Id: <1479306956-10292-2-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479306956-10292-1-git-send-email-tim.gardner@canonical.com> References: <1479306956-10292-1-git-send-email-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Ming Lin BugLink: http://bugs.launchpad.net/bugs/1637565 For some protocols like NVMe over Fabrics we need to be able to send initialization commands to a specific queue. Based on an earlier patch from Christoph Hellwig . Signed-off-by: Ming Lin [hch: disallow sleeping allocation, req_op fixes] Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Signed-off-by: Jens Axboe (back ported from commit 1f5bd336b9150560458b03460cbcfcfbcf8995b1) Signed-off-by: Tim Gardner Conflict: block/blk-mq.c --- block/blk-mq.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/blk-mq.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index ceb94c3..34bc82b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -266,6 +266,45 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, } EXPORT_SYMBOL(blk_mq_alloc_request); +struct request *blk_mq_alloc_request_hctx(struct request_queue *q, int rw, + unsigned int flags, unsigned int hctx_idx) +{ + struct blk_mq_hw_ctx *hctx; + struct blk_mq_ctx *ctx; + struct request *rq; + struct blk_mq_alloc_data alloc_data; + int ret; + + /* + * If the tag allocator sleeps we could get an allocation for a + * different hardware context. No need to complicate the low level + * allocator for this for the rare use case of a command tied to + * a specific queue. + */ + if (WARN_ON_ONCE(!(flags & BLK_MQ_REQ_NOWAIT))) + return ERR_PTR(-EINVAL); + + if (hctx_idx >= q->nr_hw_queues) + return ERR_PTR(-EIO); + + ret = blk_queue_enter(q, true); + if (ret) + return ERR_PTR(ret); + + hctx = q->queue_hw_ctx[hctx_idx]; + ctx = __blk_mq_get_ctx(q, cpumask_first(hctx->cpumask)); + + blk_mq_set_alloc_data(&alloc_data, q, flags, ctx, hctx); + rq = __blk_mq_alloc_request(&alloc_data, rw); + if (!rq) { + blk_queue_exit(q); + return ERR_PTR(-EWOULDBLOCK); + } + + return rq; +} +EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); + static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx, struct request *rq) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index a8756cd..fc20161 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -196,6 +196,8 @@ enum { struct request *blk_mq_alloc_request(struct request_queue *q, int rw, unsigned int flags); +struct request *blk_mq_alloc_request_hctx(struct request_queue *q, int op, + unsigned int flags, unsigned int hctx_idx); struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag); struct cpumask *blk_mq_tags_cpumask(struct blk_mq_tags *tags);