From patchwork Tue Aug 15 09:52:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9901519 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 DCBE760244 for ; Tue, 15 Aug 2017 09:52:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCF4528816 for ; Tue, 15 Aug 2017 09:52:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C13F628822; Tue, 15 Aug 2017 09:52:38 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 71A8728816 for ; Tue, 15 Aug 2017 09:52:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753423AbdHOJwi (ORCPT ); Tue, 15 Aug 2017 05:52:38 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:33220 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753395AbdHOJwh (ORCPT ); Tue, 15 Aug 2017 05:52:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=May/w6vDyYliRBQ0oTPXqcOAa40KM9ezzU+Gnf4YE94=; b=WEySPAhSFJD1kZCvSIfM9Kjz/ O5/sFJ+jbN4fARhrvcX99HUxMotO2bBhLm1txWJnts1MJNOWcmEBmQ//Mx/SNjtfyrdRlpyqEYD2R b2ww+YDOqRRJ9gZyn6FPFsoKkOtQX1xy0BMaN79stCrud4qoSRba0QYKLx/5uI1I/oqdiueoY2HeM R4cpHuIEpW/qLYNC9BDMPmTk/Lsl/KNpOwkxWc02TlKrMQ0YJGYJH4LtiAFjiHY6CdyTNOjYjPqbO BYcSn46PxAUuxGu4pYX+CKQ8eQlJgMPO3i2vnzUEVeGY8BA0B9SWu3AWmM0zFg6X/wsNqsGsrUnHb KRILU1J0Q==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dhYWZ-0007Bp-0q; Tue, 15 Aug 2017 09:52:35 +0000 From: Sagi Grimberg To: linux-nvme@lists.infradead.org, Christoph Hellwig , Keith Busch Cc: linux-block@vger.kernel.org Subject: [PATCH 03/12] nvme-rdma: split nvme_rdma_alloc_io_queues Date: Tue, 15 Aug 2017 12:52:16 +0300 Message-Id: <1502790745-12569-4-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502790745-12569-1-git-send-email-sagi@grimberg.me> References: <1502790745-12569-1-git-send-email-sagi@grimberg.me> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We're going to call it from the core, so split nr_io_queues setting to the call-sites. Signed-off-by: Sagi Grimberg --- drivers/nvme/host/rdma.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index d94b4df364a5..a0981fd5291c 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -643,12 +643,11 @@ static int nvme_rdma_start_io_queues(struct nvme_rdma_ctrl *ctrl) return ret; } -static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) +static unsigned int nvme_rdma_nr_io_queues(struct nvme_rdma_ctrl *ctrl) { struct nvmf_ctrl_options *opts = ctrl->ctrl.opts; struct ib_device *ibdev = ctrl->device->dev; unsigned int nr_io_queues; - int i, ret; nr_io_queues = min(opts->nr_io_queues, num_online_cpus()); @@ -660,16 +659,12 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) nr_io_queues = min_t(unsigned int, nr_io_queues, ibdev->num_comp_vectors); - ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); - if (ret) - return ret; - - ctrl->ctrl.queue_count = nr_io_queues + 1; - if (ctrl->ctrl.queue_count < 2) - return 0; + return nr_io_queues; +} - dev_info(ctrl->ctrl.device, - "creating %d I/O queues.\n", nr_io_queues); +static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) +{ + int i, ret; for (i = 1; i < ctrl->ctrl.queue_count; i++) { ret = nvme_rdma_alloc_queue(ctrl, i, @@ -838,8 +833,21 @@ static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl, static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) { + unsigned int nr_io_queues; int ret; + nr_io_queues = nvme_rdma_nr_io_queues(ctrl); + ret = nvme_set_queue_count(&ctrl->ctrl, &nr_io_queues); + if (ret) + return ret; + + ctrl->ctrl.queue_count = nr_io_queues + 1; + if (ctrl->ctrl.queue_count < 2) + return 0; + + dev_info(ctrl->ctrl.device, + "creating %d I/O queues.\n", nr_io_queues); + ret = nvme_rdma_alloc_io_queues(ctrl); if (ret) return ret;