Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2265185ybl; Thu, 15 Aug 2019 09:03:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV6kAZePASMXXmo78mUFThFqi2kReD2YPLMfI0voAPd7Vcv2szG0CNm2qJvMGxvuTSnUes X-Received: by 2002:a17:90a:3aaf:: with SMTP id b44mr2943314pjc.87.1565885035675; Thu, 15 Aug 2019 09:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565885035; cv=none; d=google.com; s=arc-20160816; b=RleqtZZnGLd9lOtsbZl9CiKR90wqhPGleeLR+NRD+Km4rIxF7N4B8JJ2TGDn7+GMpY KbHpK/OV00ll3kNQKzwYVLmfNk0tcCKAfgE7uCC+mIUJ51tMbpz7bI8rjK+5TR3Uw4Hj qWV9eQ1JbMXt20SltiLmB3BgEeCOEsoeADIKnmB5+7GuPsTB9/XCjwvHsIIf681rl8Em I1+iLVivRCir6ZIY/Y/CJtV38A1v9FOgV1vJvX4LNCas9jTdoZiJrgAm6lWvvf330Jik dEhpAZeg+OvkLYqOhHOKJaMCDmS2f4QFqTyBoJjsbC8Z+X+ECCbv5kI7v9OU5fsLyKKB SxCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=b9W7k8oNR+l+Cl5RfKQ9Z9h0Sy2oW4eECDztnWUG6fc=; b=X+WZFfhOGm9Nq1evRVHi5FEhcPClgK8yoBZUt55oZhoJyxq58x2uxXbxvUCBPCn7sO Fi1zwa8T8C2jUFT52mAsxQnszcOFLa7jfMG9TIrtJ2N0XVAID5ieYIRGYdM2ecz4XGRC M3oaK0GiBDxVGlHZg9oXGIxq+ce54WQ/aWt7WYlvqeISzMWs7Fdox6nhhy8epYJ7kjTO HlTvsmWbUehhlcDbLlRPC31HDO8nEZQrvImRKC+5ekiVgCXrH2SHfELk64iEnJUstLiD YpbgxpmC//jislF77BzPFDq1tJ/eKIKwu7JNsAoPWfgnzym+0tg4dPCjs0q+D3ot9h88 +wYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c62si2041813pga.441.2019.08.15.09.03.38; Thu, 15 Aug 2019 09:03:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729427AbfHOP77 (ORCPT + 99 others); Thu, 15 Aug 2019 11:59:59 -0400 Received: from ale.deltatee.com ([207.54.116.67]:59178 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728886AbfHOP77 (ORCPT ); Thu, 15 Aug 2019 11:59:59 -0400 Received: from s0106ac1f6bb1ecac.cg.shawcable.net ([70.73.163.230] helo=[192.168.11.155]) by ale.deltatee.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hyIAB-0000kk-MY; Thu, 15 Aug 2019 09:59:44 -0600 To: Max Gurtovoy , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig , Sagi Grimberg , Keith Busch , Jens Axboe , Chaitanya Kulkarni , Stephen Bates References: <20190801234514.7941-1-logang@deltatee.com> <20190801234514.7941-2-logang@deltatee.com> <563baec2-61f6-5705-d751-1eee75370e66@mellanox.com> From: Logan Gunthorpe Message-ID: <3dc99450-bd6d-b994-4b4c-1af225565c2f@deltatee.com> Date: Thu, 15 Aug 2019 09:59:39 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <563baec2-61f6-5705-d751-1eee75370e66@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 70.73.163.230 X-SA-Exim-Rcpt-To: sbates@raithlin.com, Chaitanya.Kulkarni@wdc.com, axboe@fb.com, kbusch@kernel.org, sagi@grimberg.me, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, maxg@mellanox.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v7 01/14] nvme-core: introduce nvme_ctrl_get_by_path() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-08-15 5:46 a.m., Max Gurtovoy wrote: > > On 8/2/2019 2:45 AM, Logan Gunthorpe wrote: >> nvme_ctrl_get_by_path() is analagous to blkdev_get_by_path() except it >> gets a struct nvme_ctrl from the path to its char dev (/dev/nvme0). >> It makes use of filp_open() to open the file and uses the private >> data to obtain a pointer to the struct nvme_ctrl. If the fops of the >> file do not match, -EINVAL is returned. >> >> The purpose of this function is to support NVMe-OF target passthru. >> >> Signed-off-by: Logan Gunthorpe >> --- >>   drivers/nvme/host/core.c | 24 ++++++++++++++++++++++++ >>   drivers/nvme/host/nvme.h |  2 ++ >>   2 files changed, 26 insertions(+) >> >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c >> index e6ee6f2a3da6..f72334f34a30 100644 >> --- a/drivers/nvme/host/core.c >> +++ b/drivers/nvme/host/core.c >> @@ -2817,6 +2817,30 @@ static const struct file_operations >> nvme_dev_fops = { >>       .compat_ioctl    = nvme_dev_ioctl, >>   }; >>   +struct nvme_ctrl *nvme_ctrl_get_by_path(const char *path) >> +{ >> +    struct nvme_ctrl *ctrl; >> +    struct file *f; >> + >> +    f = filp_open(path, O_RDWR, 0); >> +    if (IS_ERR(f)) >> +        return ERR_CAST(f); >> + >> +    if (f->f_op != &nvme_dev_fops) { >> +        ctrl = ERR_PTR(-EINVAL); >> +        goto out_close; >> +    } > > Logan, > > this means that the PT is for nvme-pci and also nvme-fabrics as well. > > Is this the intention ? or we want to restrict it to pci only. Yes, in theory, someone could passthru an nvme-fabrics controller or they could passthru a passthru'd passthru'd nvme-fabrics controller. This probably isn't a good idea but I don't know that we need to specifically reject it. If you think we should I could figure out a way to filter by pci controllers only. Logan