Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11672338ybi; Thu, 25 Jul 2019 21:31:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqycgPavvVmPevJ4L+YGp8cUbkEXsPdOqgb/QqleKvpy20KIXV4n+ZChxytcdx6+N1dxDv1a X-Received: by 2002:aa7:8108:: with SMTP id b8mr20506682pfi.197.1564115500801; Thu, 25 Jul 2019 21:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564115500; cv=none; d=google.com; s=arc-20160816; b=D8efeXyWStzbP9lpj8OcIlA++xRrqqxNxtap0FVwbYmcoG5NHJsqkIPg5jQyItOR87 +2Gzun2YmHuLvN9vrpwBws2u8bkE33DddwxwPlQsJdP308te4NmCJTifcMuKUsPep1qe KUClCrD7b/pdQqIvxEQzu/PpxOmMmYROU/6ooQUgHLh2mQZn8nCsqW3VAPsuWO1jLPyW hi+X17QwYQ7fXMASG9JkZM+ahFDYvaU/O1edqrOLaY0oWDJQmeFHUX7BAX8CVyjuDAGs K2BNP1spvReLSm6BTXrO6uqTOW08HRodIY2ELmaKxzjT8jN0pZ2PtU6U2Zz5Iuo28Xlw enaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rIhtYBAd0ZZLe9n3b3Z0c0rQPCJrZwUCsuW99j3TPW0=; b=jkF+gkQjyeZvlCYJSxDiXoiFjH0v2n7W2NwnHAWA4ODOw26Jq9fB2PerE1LLfagdjX 24U4SSFvJcaZCm96h9lNQSk27DkFewrKuM1E4mIs1tSeyhSE99w0tWd5X0CWzMi9JHOG ARwW8K7HlFjWDLao6C+p1Y3K5S2XrdyOjfETj9cg03y46Wd3uXJs3sxFVLBlnX/66EMl 3ZHA1EhVtqtQOI2SkCEBwVG81aGdZbdEene6NwE1RCxWWd+pLtaLcDjshED9wY53Ndu3 efFu7mxpoeDfbC7NYinafhwVlEFiYX/3EA4V96Evue9EucTfuK8wQ6az85GKBsSYLNP2 uPxQ== 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 f96si19881455plb.339.2019.07.25.21.31.25; Thu, 25 Jul 2019 21:31:40 -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 S1726086AbfGZE3n (ORCPT + 99 others); Fri, 26 Jul 2019 00:29:43 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42368 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbfGZE3n (ORCPT ); Fri, 26 Jul 2019 00:29:43 -0400 Received: by mail-pl1-f195.google.com with SMTP id ay6so24281363plb.9; Thu, 25 Jul 2019 21:29:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rIhtYBAd0ZZLe9n3b3Z0c0rQPCJrZwUCsuW99j3TPW0=; b=mxV7PiMoJwWfGsfJthExu2EHCQn7FkBbwSjEc5iaRGNbbiL/9osbhwaFm884EucjGy dTF8PEKlWrhW4rShPHy8XHGnyONrttwha9r/Gxwk8XfEzhFOkz9r9XgjJvnJsHdKjnaH goBBOaXer60ebpmxdW3j3dVXpEDWc2F4pHqUXcWvJhZsIl6v/aKmFKsi8QpnOakCHxSF Dc4p0yo2mb6JBJ4RAqn7wiHRsKbQTw+ZfvLqfW3SVRYhDsDdKEHYWxF3Dl2Ia4RQ/1dF WPdyUlTrfG5cM96KR1hvFEQPHNmWVNc6RNsk68TicHUN2/8r7EDCY/Tbi3XLWj1fH6k6 OEqw== X-Gm-Message-State: APjAAAXPH4rUDkxRP4YovkArZkiMFjz6mQWp3ytIz4WupZT9ys4a3E1k me+nQFZI9CdJxuildc+w/2o= X-Received: by 2002:a17:902:3081:: with SMTP id v1mr96243822plb.169.1564115382626; Thu, 25 Jul 2019 21:29:42 -0700 (PDT) Received: from ?IPv6:2601:647:4800:973f:9c9c:d9b0:80ed:96d1? ([2601:647:4800:973f:9c9c:d9b0:80ed:96d1]) by smtp.gmail.com with ESMTPSA id l44sm45186630pje.29.2019.07.25.21.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 21:29:41 -0700 (PDT) Subject: Re: [PATCH v6 02/16] chardev: introduce cdev_get_by_path() To: Al Viro , Logan Gunthorpe Cc: Matthew Wilcox , Greg Kroah-Hartman , Jens Axboe , Chaitanya Kulkarni , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Stephen Bates , linux-block@vger.kernel.org, Keith Busch , linux-fsdevel@vger.kernel.org, Max Gurtovoy , Christoph Hellwig References: <20190725172335.6825-3-logang@deltatee.com> <20190725174032.GA27818@kroah.com> <682ff89f-04e0-7a94-5aeb-895ac65ee7c9@deltatee.com> <20190725180816.GA32305@kroah.com> <20190725182701.GA11547@kroah.com> <20190725190024.GD30641@bombadil.infradead.org> <27943e06-a503-162e-356b-abb9e106ab2e@grimberg.me> <20190725191124.GE30641@bombadil.infradead.org> <425dd2ac-333d-a8c4-ce49-870c8dadf436@deltatee.com> <20190725235502.GJ1131@ZenIV.linux.org.uk> From: Sagi Grimberg Message-ID: <7f48a40c-6e0f-2545-a939-45fc10862dfd@grimberg.me> Date: Thu, 25 Jul 2019 21:29:40 -0700 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: <20190725235502.GJ1131@ZenIV.linux.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>>>> NVMe-OF is configured using configfs. The target is specified by the >>>>>>> user writing a path to a configfs attribute. This is the way it works >>>>>>> today but with blkdev_get_by_path()[1]. For the passthru code, we need >>>>>>> to get a nvme_ctrl instead of a block_device, but the principal is the same. >>>>>> >>>>>> Why isn't a fd being passed in there instead of a random string? >>>>> >>>>> I suppose we could echo a string of the file descriptor number there, >>>>> and look up the fd in the process' file descriptor table ... >>>> >>>> Assuming that there is a open handle somewhere out there... >> >> Yes, that would be a step backwards from an interface. The user would >> then need a special process to open the fd and pass it through configfs. >> They couldn't just do it with basic bash commands. > > First of all, they can, but... WTF not have filp_open() done right there? > Yes, by name. With permission checks done. And pick your object from the > sodding struct file you'll get. > > What's the problem? Why do you need cdev lookups, etc., when you are > dealing with files under your full control? Just open them and use > ->private_data or whatever you set in ->open() to access the damn thing. > All there is to it... Oh this is so much simpler. There is really no point in using anything else. Just need to remember to compare f->f_op to what we expect to make sure that it is indeed the same device class.