From patchwork Wed Jun 8 03:34:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 9163269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41C8060571 for ; Wed, 8 Jun 2016 03:35:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32B81281F9 for ; Wed, 8 Jun 2016 03:35:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2796128372; Wed, 8 Jun 2016 03:35:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EAEB281F9 for ; Wed, 8 Jun 2016 03:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755828AbcFHDfQ (ORCPT ); Tue, 7 Jun 2016 23:35:16 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:34409 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751627AbcFHDfP (ORCPT ); Tue, 7 Jun 2016 23:35:15 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id BFE1A22CAAB; Wed, 8 Jun 2016 03:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1465356865; bh=97QN70px7k933YkqaWDikdfoIUk/KyA YzKle1+e9TgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=JP4tejh4f2YWSxG5aFE39u6EeL9IVtozG6DOm12o66XUI0cEtDbI MfUVqN+8Lf2jxkeac5ReX7ozzn9uEqFrGPmuP2iQR0yZ7XVIRM78hWaftbFWjOGWIMl jKbBJG51yUxi2NE1xvXTzMKLVStQQENoP4GwvFbFlKcbelhFQGi0= From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , linux-nvme , Jens Axboe , Christoph Hellwig , Keith Busch , Jay Freyensee , Martin Petersen , Sagi Grimberg , Hannes Reinecke , Mike Christie , Dave B Minturn , Nicholas Bellinger Subject: [RFC 1/2] nvme-fabrics: Add nvmf_get_default_host helper Date: Wed, 8 Jun 2016 03:34:20 +0000 Message-Id: <1465356861-4321-2-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1465356861-4321-1-git-send-email-nab@linux-iscsi.org> References: <1465356861-4321-1-git-send-email-nab@linux-iscsi.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger This patch adds a nvmf_get_default_host() helper used to setup nvmf_ctrl_options->host to internal nvmf_default_host reference, following existing nvmf_parse_options() code. Note it's required for nvme-loop multi-controller support, in order to drive nvmet_port creation directly via configfs attribute write from in ../nvmet/subsystems/$NQN/ports/$PORT/ group context. Cc: Jens Axboe Cc: Christoph Hellwig Cc: Keith Busch Cc: Jay Freyensee Cc: Martin Petersen Cc: Sagi Grimberg Cc: Hannes Reinecke Cc: Mike Christie Signed-off-by: Nicholas Bellinger --- drivers/nvme/host/fabrics.c | 13 +++++++++++-- drivers/nvme/host/fabrics.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index ee4b7f1..04317be 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -497,6 +497,16 @@ static struct nvmf_transport_ops *nvmf_lookup_transport( return NULL; } +void nvmf_get_default_host(struct nvmf_ctrl_options *opts) +{ + if (opts->host) + return; + + kref_get(&nvmf_default_host->ref); + opts->host = nvmf_default_host; +} +EXPORT_SYMBOL_GPL(nvmf_get_default_host); + static const match_table_t opt_tokens = { { NVMF_OPT_TRANSPORT, "transport=%s" }, { NVMF_OPT_TRADDR, "traddr=%s" }, @@ -686,8 +696,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } if (!opts->host) { - kref_get(&nvmf_default_host->ref); - opts->host = nvmf_default_host; + nvmf_get_default_host(opts); } out: diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index b540674..73ef7a7 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -128,6 +128,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl); int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid); void nvmf_register_transport(struct nvmf_transport_ops *ops); void nvmf_unregister_transport(struct nvmf_transport_ops *ops); +void nvmf_get_default_host(struct nvmf_ctrl_options *opts); void nvmf_free_options(struct nvmf_ctrl_options *opts); const char *nvmf_get_subsysnqn(struct nvme_ctrl *ctrl); int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size);