[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250602-dir-deleg-v2-0-a7919700de86@kernel.org>
Date: Mon, 02 Jun 2025 10:01:43 -0400
From: Jeff Layton <jlayton@...nel.org>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Chuck Lever <chuck.lever@...cle.com>,
Alexander Aring <alex.aring@...il.com>,
Trond Myklebust <trondmy@...nel.org>, Anna Schumaker <anna@...nel.org>,
Steve French <sfrench@...ba.org>, Paulo Alcantara <pc@...guebit.com>,
Ronnie Sahlberg <ronniesahlberg@...il.com>,
Shyam Prasad N <sprasad@...rosoft.com>, Tom Talpey <tom@...pey.com>,
Bharath SM <bharathsm@...rosoft.com>, NeilBrown <neil@...wn.name>,
Olga Kornievskaia <okorniev@...hat.com>, Dai Ngo <Dai.Ngo@...cle.com>,
Jonathan Corbet <corbet@....net>, Amir Goldstein <amir73il@...il.com>,
Miklos Szeredi <miklos@...redi.hu>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-nfs@...r.kernel.org, linux-cifs@...r.kernel.org,
samba-technical@...ts.samba.org, linux-doc@...r.kernel.org,
Jeff Layton <jlayton@...nel.org>
Subject: [PATCH RFC v2 00/28] vfs, nfsd, nfs: implement directory
delegations
This patchset is an update to a patchset that I posted just over a year
ago [1]. That version had client and server patches. This one is just
the server-side patches.
NFSv4.1 adds a GET_DIR_DELEGATION operation, to allow clients
to request a delegation on a directory. If the client holds a directory
delegation, then it knows that nothing will change the dentries in it
until it has been recalled.
In 2023, Rick Macklem gave a talk at the NFS Bakeathon on his
implementation of directory delegations for FreeBSD [2], and showed that
it can greatly improve LOOKUP-heavy workloads. There is also some
earlier work by CITI [3] that showed similar results. The SMB protocol
also has a similar sort of construct, and they have also seen large
performance improvements on certain workloads.
This version also starts with support for trivial directory delegations.
>From there it adds VFS support for ignoring certain break_lease() events
on on directories. The server can then request leases that ignore
certain events (like a create or delete) and set its fsnotify mask to
receive a callback after that event occurs. That allows it to avoid
breaking the lease.
When a fsnotify callback comes in, the server will encode the
information directly as XDR in a buffer attached to the delegation. The
CB_NOTIFY callback is then queued, which will scoop up that buffer and
allocate another to start gathering more events. If it runs out of
space to spool events, it will give up and trigger a recall of the
delegation.
This is still a work-in-progress however:
The main thing missing at this point is support for sending attributes
in the CB_NOTIFY, particularly on ADD events. The right set of fattrs
would allow the client to instantiate a dentry and inode without having
to contact the server.
Still, it's getting close to the point where the server side is somewhat
functional so it's a good time to post what I have so far.
Anna has graciously agreed to work on the client-side pieces. I do have
some patches, but that piece is still pretty rough:
https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git/log/?h=dir-deleg-clnt
In a nutshell, the client-side GDD4 support is still simplistic, and
there is no support for CB_NOTIFY yet.
I also have a MR up for wireshark [4], and I have patches for some basic
pynfs tests that I've been using to drive the server (to be posted
soon).
At this point I'm mainly interested in feedback on the VFS bits,
particularly the delegated_inode changes. Also, I should make special
mention of atomic_open since Al pointed it out in the last set:
I think we can't reasonably support dir delegations on filesystems that
support atomic_open. When we do a create on those filesystems, we don't
know whether the file exists or not, so we can't know whether we need to
break a dir delegation.
It would be nice to have a compile-time check for that, but I'm not sure
how we could reasonably do it. For now, I've settled for disabling
directory leases in FUSE, NFS and CIFS, which should work around the
potential problem.
[1]: https://lore.kernel.org/linux-nfs/20240315-dir-deleg-v1-0-a1d6209a3654@kernel.org/
[2]: https://www.youtube.com/watch?v=DdFyH3BN5pI
[3]: https://linux-nfs.org/wiki/index.php/CITI_Experience_with_Directory_Delegations
[4]: https://gitlab.com/wireshark/wireshark/-/merge_requests/20048
Signed-off-by: Jeff Layton <jlayton@...nel.org>
---
Changes in v2:
- add support for ignoring certain break_lease() events
- basic support for CB_NOTIFY
- Link to v1: https://lore.kernel.org/r/20240315-dir-deleg-v1-0-a1d6209a3654@kernel.org
---
Jeff Layton (28):
filelock: push the S_ISREG check down to ->setlease handlers
filelock: add a lm_may_setlease lease_manager callback
vfs: add try_break_deleg calls for parents to vfs_{link,rename,unlink}
vfs: allow mkdir to wait for delegation break on parent
vfs: allow rmdir to wait for delegation break on parent
vfs: break parent dir delegations in open(..., O_CREAT) codepath
vfs: make vfs_create break delegations on parent directory
vfs: make vfs_mknod break delegations on parent directory
filelock: lift the ban on directory leases in generic_setlease
nfsd: allow filecache to hold S_IFDIR files
nfsd: allow DELEGRETURN on directories
nfsd: check for delegation conflicts vs. the same client
nfsd: wire up GET_DIR_DELEGATION handling
filelock: rework the __break_lease API to use flags
filelock: add struct delegated_inode
filelock: add support for ignoring deleg breaks for dir change events
filelock: add an inode_lease_ignore_mask helper
nfsd: add protocol support for CB_NOTIFY
nfsd: add callback encoding and decoding linkages for CB_NOTIFY
nfsd: add data structures for handling CB_NOTIFY to directory delegation
fsnotify: export fsnotify_recalc_mask()
nfsd: update the fsnotify mark when setting or removing a dir delegation
nfsd: make nfsd4_callback_ops->prepare operation bool return
nfsd: add notification handlers for dir events
nfsd: allow nfsd to get a dir lease with an ignore mask
nfsd: add a tracepoint for nfsd_file_fsnotify_handle_dir_event()
nfsd: add support for NOTIFY4_ADD_ENTRY events
nfsd: add support for NOTIFY4_RENAME_ENTRY events
Documentation/sunrpc/xdr/nfs4_1.x | 252 ++++++++++++++++-
fs/attr.c | 4 +-
fs/fuse/dir.c | 1 +
fs/locks.c | 120 ++++++--
fs/namei.c | 296 ++++++++++++-------
fs/nfs/nfs4file.c | 2 +
fs/nfsd/filecache.c | 103 +++++--
fs/nfsd/filecache.h | 2 +
fs/nfsd/nfs4callback.c | 60 +++-
fs/nfsd/nfs4layouts.c | 3 +-
fs/nfsd/nfs4proc.c | 24 +-
fs/nfsd/nfs4state.c | 535 +++++++++++++++++++++++++++++++++--
fs/nfsd/nfs4xdr_gen.c | 506 ++++++++++++++++++++++++++++++++-
fs/nfsd/nfs4xdr_gen.h | 17 +-
fs/nfsd/state.h | 47 ++-
fs/nfsd/trace.h | 26 +-
fs/nfsd/vfs.c | 5 +-
fs/nfsd/vfs.h | 2 +-
fs/nfsd/xdr4cb.h | 11 +
fs/notify/mark.c | 1 +
fs/open.c | 8 +-
fs/posix_acl.c | 12 +-
fs/smb/client/cifsfs.c | 3 +
fs/utimes.c | 4 +-
fs/xattr.c | 16 +-
include/linux/filelock.h | 143 +++++++---
include/linux/fs.h | 9 +-
include/linux/nfs4.h | 127 ---------
include/linux/sunrpc/xdrgen/nfs4_1.h | 293 ++++++++++++++++++-
include/linux/xattr.h | 4 +-
include/uapi/linux/nfs4.h | 2 -
31 files changed, 2249 insertions(+), 389 deletions(-)
---
base-commit: 22b71eb34051a70c39c86997657de92722ec1838
change-id: 20240215-dir-deleg-e212210ba9d4
Best regards,
--
Jeff Layton <jlayton@...nel.org>
Powered by blists - more mailing lists