Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp88559ybi; Fri, 24 May 2019 00:14:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdm/VcB2VFmF1H8ZJ6TUQydC5VuuF+H6pqERkPcxNP8TapOwm23Lprf8d4P5uAGcR3/V+a X-Received: by 2002:a17:90a:480a:: with SMTP id a10mr7035499pjh.57.1558682052811; Fri, 24 May 2019 00:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558682052; cv=none; d=google.com; s=arc-20160816; b=GJSWVNAQ+zhGhnIDBs01LyjeD9Qrpzi8E+UzWrc5+p3syn7bj7xP6X8w+UC79R98A1 xFjj59OkMIjHcb80owGEMvcTd8+0ILC/qlL9KOU0Y4btVhKibfQ+18KrDH+DCwwRo62V OcVQsaysFuO92+DZlUWcoESSazXtLKgpkjAiiN/irN5c5qJtdYEoWmcunXybu+rcVDOM b12WSfI2SePN038RCspBLMvsOah/095uf7RLSoM7RQjQ+bL2AGJ3q03/enxeBEevpfB0 u7QhonhDjyr+/oEYK/euijQtPCjWviZuorfmHT/ZrQmquCuaXT9JAdvpHUOSovyIuzwV vQFQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=05vAoVeOrdstEB55Nwy8Ge/6GUU8fE9/JUAdAnQMoes=; b=cXAvCliy9VZDh+ywtxPPrLxJdPCsMobS2hS9JFQIR2NkeuV6owz9y6o8ePGfydreGh 0AgPM3odVSIRWcTxEPWny0KXt4WMJxsyAzVo1dO9RDr9nGIsNKZOlEQNIQ7fhzMvTAe9 o4thtEZ/GS+mTpX0pkdzrFEojtU7/b+bA3RulNeohyDKY7kSReDuh0kou1gOQhBoq9Ak Bn96WLaTT/sCn5WJ9cN3Sk3jUYvffdSSa6ui5S9d3/g2E3IIQr1fd4iiOwtQQfwLMl0+ u+vf9JZ6SjrGxZO5mkZQKhhKD07SwSIGaY4AgioB47Fy9owR1aoRgLOP537jl4eY1I5f cIWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2cBl0zf; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si3049755pgm.92.2019.05.24.00.13.38; Fri, 24 May 2019 00:14:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2cBl0zf; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389057AbfEXHMX (ORCPT + 99 others); Fri, 24 May 2019 03:12:23 -0400 Received: from mail-yb1-f171.google.com ([209.85.219.171]:41745 "EHLO mail-yb1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389017AbfEXHMX (ORCPT ); Fri, 24 May 2019 03:12:23 -0400 Received: by mail-yb1-f171.google.com with SMTP id d2so3243570ybh.8 for ; Fri, 24 May 2019 00:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=05vAoVeOrdstEB55Nwy8Ge/6GUU8fE9/JUAdAnQMoes=; b=l2cBl0zfxxMlrf8C6Fr2VJYVqCQe/2pi4SHlvlxJgaJqxbEjmvhKlSIXP9g2gFlykn TKq9Z+nJmKkVUyJ66Gkp1x7hRXjpDtcaefPFm8/uN5A8oPJYf+u7bLJJexvum2sBMopv JRI2G7Nw8QVc6i8HzdKHZSUC0I2LKGsm+bHLLtZJgfxQvC7/OFYeLMGci1aF/b2eWXdI mlsH95DI5gnl6tAzQx+X3iercDqlhDz10WPDSLRO2hELAtRo8DUIE78QF4dlEpD5/vAG NFlZybNL37qyoYankw2SjXAOt2gUi48ZVihMNvXMhfsasoPLrF2JszF2OagqODMOuvtv V0UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=05vAoVeOrdstEB55Nwy8Ge/6GUU8fE9/JUAdAnQMoes=; b=kxdVAKE4Zqr+G7gePHLHvFGuUM+Jwkoppi3vPx0z3vZHrth7BQ7iZEoz/NOwLrBRft J2QZ55lHEwAoRc6MnSkVxreAvYoesbYn8uNdn6QLDnbIzVBNeNlK5dI6EAC+JI15CpSS Z+osznP1jvMy1oIbmTLCFGKVwpBYrsYAjXvRXhzijpOBnnV+Fu31wKNTOHeGznaLd99l e+jEny6qqi4CqK9bnzy5Q24wTf2ppajgqUvd9/M9q7wF1EgqfdjwxgE9QMVZbuV2wIDW z1Quq7o5Br8m1sEEO8Lo22v6/G/2zVHDvQ804ui6wwzo9dDSZXKKHtdpFa+1JevyAadC kUjA== X-Gm-Message-State: APjAAAXbdRuFS1aLmrCKCcVpwT0kJsu/nLmtqtmqAso7UGNO4Riw0Qxa MgVaLlhd0AvXj0d9R0MragYpC4w/jkdh2GJ+izU= X-Received: by 2002:a25:c983:: with SMTP id z125mr44014196ybf.45.1558681942222; Fri, 24 May 2019 00:12:22 -0700 (PDT) MIME-Version: 1.0 References: <379106947f859bdf5db4c6f9c4ab8c44f7423c08.camel@kernel.org> <20190208155052.GB20573@fieldses.org> <20190208221239.GA199180@jra3> <20190214210652.GC9216@fieldses.org> <20190305214748.GD27437@fieldses.org> <20190306151150.GC2426@fieldses.org> <1ade4724a4e505baf7b7c23a76e44d58b931da1f.camel@kernel.org> <20190306210743.GE19279@jra3> <5ebdb58b-26d9-c0f2-bd67-883bc4678ac7@samba.org> In-Reply-To: From: Amir Goldstein Date: Fri, 24 May 2019 10:12:10 +0300 Message-ID: Subject: Re: Better interop for NFS/SMB file share mode/reservation To: Stefan Metzmacher Cc: =?UTF-8?B?UmFscGggQsO2aG1l?= , Jeremy Allison , Linux NFS Mailing List , Volker.Lendecke@sernet.de, devel@lists.nfs-ganesha.org, Jeff Layton , samba-technical , "J. Bruce Fields" , Trond Myklebust Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org [dropping linux-fsdevel] On Thu, Apr 25, 2019 at 9:11 PM Amir Goldstein wrote: > > On Thu, Mar 7, 2019 at 1:04 PM Stefan Metzmacher wrote: > > > > Am 06.03.19 um 22:25 schrieb Ralph B=C3=B6hme via samba-technical: > > > > > > Jeremy Allison wrote: > > >> On Wed, Mar 06, 2019 at 03:31:08PM -0500, Jeff Layton wrote: > > >>> On Wed, 2019-03-06 at 10:11 -0500, J. Bruce Fields wrote: > > >>>> > > >>>> Jeff, wasn't there some work (on Ceph maybe?) on a userspace deleg= ation > > >>>> API? Is that close to what's needed? > > >>>> > > >>> > > >>> Here's the C headers for that stuff: > > >>> > > >>> https://github.com/ceph/ceph/blob/7ba6bece4187eda5d05a9b84211fe6= ba8dd287bd/src/include/cephfs/libcephfs.h#L1734 > > >>> > > >>> It's simple enough and works for us in ganesha, and I think we can > > >>> probably adapt it to samba without too much difficulty. The callbac= k > > >>> doesn't seem like it'll do for a kernel API though -- you'd almost > > >>> certainly need to do something different there (signals? inotify?). > > >> > > >> SMB3 leases have R/RW and Handle-based leases. > > > > > > Just to be precise: SMB2.1+ has R, RH, RW and RWH leases. > > > > > >> Handle leases allow multiple opens of the same pathname > > >> that get different handles to share the lease, allowing > > >> a client redirector to delay opens or closes locally > > >> so long as it has a handle lease. > > > > > > That'a a propertly of leases in general, not just H-leases. The clien= t provides a lease key which is a GUID with each lease request > > > > > >> > > >> Here are the semantics: > > >> > > >> https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2= /d8df943d-6ad7-4b30-9f58-96ae90fc6204 > > >> > > >> I'm not sure a simple file-descriptor based API is > > >> enough for us. Can he have a uuid or token based > > >> API instead where the server can chose what fd's > > >> to cover with a token ? > > > > > > Yes, that would be ideal. > > Getting back to this. > Thanks all for the valuable inputs. > > Next week is LSF/MM and I was assigned a 30 minute slot on filesystems tr= ack > to discuss "NFS/SMB file share". > > So let me try to echo what I read on this thread and how I understand wha= t APIs > samba needs from the kernel. > > > > > If we want to design an useful API, we also need to think about > > all features: > > - file oplock/leases > > Kernel can have a flavor of leases which are not broken > by opens from threads of the process holding the lease. > Bruce has some patches along those lines for knfsd and SMB R/RW > leases could use this flavor if it was exported to userspace? > > For SMB RH/RWH leases and Ganesha delegations, server > could keep track of its own handles/clients and break leases within the > same process without involving the kernel. > Am I wrong? > > > - directory leases > > I have WIP on fsnotify directory pre modification hooks. > There is opposition from fsnotify maintainer to add new userspace > APIs that can create kernel->user->kernel deadlocks, like the > deadlocks currently reported with fanotify permission events. > > Need to see if we can find a middle ground between > "post modification notifications" and "pre modification permission" > API, somewhere along the lines of regular file lease breaking API. > > > - share modes > > Volker told me he thinks samba can enforce share modes by > a single daemon policing all opens in the system with fanotify. > I think he is right. If anyone thinks differently please speak up. > > > - disconnected handles (for durable and persistent handles), > > which exists within the kernel for a while and can be reattached > > to process, using some kind of cookie and the same euid > > So this interface exists in the kernel. > Nothing more required from the kernel API. Right? > > > - the API needs ways to use epoll in order to do async opens > > and lease breaks. For opens the model of async socket connects > > could be used. Leases could have a signalfd-style api. > > I should hope that the new AIO API (http://kernel.dk/io_uring.pdf) > would solve those problems as well as other issues that > samba has w.r.t dispatching AIO. > > > > > We may not need everything at once, but we should have the full picture > > in mind. And we need working code in kernel and userspace that passes > > all tests (we may need to add additional test). Otherwise the kernel > > creates new syscalls, which wouldn't be used by Samba in the end. > > > > Tested interfaces - good idea ;-) > > If anyone has any comments about my view of required new interfaces, > or important things that I missed, please say so before Tuesday! > Hello Samba-team, Some of you may have already seen the reports from my session at LSF/MM on Samba/NFS interop: https://lwn.net/Articles/788335/ It should not be a surprise to anyone here to know that I have had interest= ing and productive conversations with NFS folks about improving samba interop. It should not be a surprise to anyone here to know that the rest of the aud= ience was, generally speaking, uninterested in the problem. Which provides a re-enforcement to the point I was trying to make in sessio= n - The path of least resistance for NFS-Samba interop is the communicate with each other (both human and software wise) and try to leave VFS out of the discussion for as much as possible (hence dropping linux-fsdevel from this thread). An idea that has already been thrown around is to use some samba daemon as an arbitrator for opening files and locks. Of course, this would be an opt-in feature for NFS servers. For example, can we use fanotify permission hooks to delegate access contro= l checks from knfsd to a daemon? Right now, the information in permission events is rather minimal, but as an fanotify developer, I can assure you, that we can enrich the information passed by knfsd on open permission events if that is deemed use= ful. I will be attending SambaXP, so if any of the Samba guys would like to, we = could find a slot in the Hallway track or at a local bar to discuss those options= . Thanks, Amir.