linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 00/28] vfs, nfsd, nfs: implement directory delegations
@ 2025-06-02 14:01 Jeff Layton
  2025-06-02 14:01 ` [PATCH RFC v2 01/28] filelock: push the S_ISREG check down to ->setlease handlers Jeff Layton
                   ` (27 more replies)
  0 siblings, 28 replies; 34+ messages in thread
From: Jeff Layton @ 2025-06-02 14:01 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Jan Kara, Chuck Lever,
	Alexander Aring, Trond Myklebust, Anna Schumaker, Steve French,
	Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
	Bharath SM, NeilBrown, Olga Kornievskaia, Dai Ngo,
	Jonathan Corbet, Amir Goldstein, Miklos Szeredi
  Cc: linux-fsdevel, linux-kernel, linux-nfs, linux-cifs,
	samba-technical, linux-doc, Jeff Layton

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@kernel.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@kernel.org>


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2025-06-06 10:11 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-02 14:01 [PATCH RFC v2 00/28] vfs, nfsd, nfs: implement directory delegations Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 01/28] filelock: push the S_ISREG check down to ->setlease handlers Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 02/28] filelock: add a lm_may_setlease lease_manager callback Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 03/28] vfs: add try_break_deleg calls for parents to vfs_{link,rename,unlink} Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 04/28] vfs: allow mkdir to wait for delegation break on parent Jeff Layton
2025-06-05 11:19   ` Jan Kara
2025-06-05 11:25     ` Jeff Layton
2025-06-06 10:10       ` Christian Brauner
2025-06-02 14:01 ` [PATCH RFC v2 05/28] vfs: allow rmdir " Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 06/28] vfs: break parent dir delegations in open(..., O_CREAT) codepath Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 07/28] vfs: make vfs_create break delegations on parent directory Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 08/28] vfs: make vfs_mknod " Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 09/28] filelock: lift the ban on directory leases in generic_setlease Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 10/28] nfsd: allow filecache to hold S_IFDIR files Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 11/28] nfsd: allow DELEGRETURN on directories Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 12/28] nfsd: check for delegation conflicts vs. the same client Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 13/28] nfsd: wire up GET_DIR_DELEGATION handling Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 14/28] filelock: rework the __break_lease API to use flags Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 15/28] filelock: add struct delegated_inode Jeff Layton
2025-06-02 14:01 ` [PATCH RFC v2 16/28] filelock: add support for ignoring deleg breaks for dir change events Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 17/28] filelock: add an inode_lease_ignore_mask helper Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 18/28] nfsd: add protocol support for CB_NOTIFY Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 19/28] nfsd: add callback encoding and decoding linkages " Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 20/28] nfsd: add data structures for handling CB_NOTIFY to directory delegation Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 21/28] fsnotify: export fsnotify_recalc_mask() Jeff Layton
2025-06-03 20:13   ` Jan Kara
2025-06-03 20:17     ` Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 22/28] nfsd: update the fsnotify mark when setting or removing a dir delegation Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 23/28] nfsd: make nfsd4_callback_ops->prepare operation bool return Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 24/28] nfsd: add notification handlers for dir events Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 25/28] nfsd: allow nfsd to get a dir lease with an ignore mask Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 26/28] nfsd: add a tracepoint for nfsd_file_fsnotify_handle_dir_event() Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 27/28] nfsd: add support for NOTIFY4_ADD_ENTRY events Jeff Layton
2025-06-02 14:02 ` [PATCH RFC v2 28/28] nfsd: add support for NOTIFY4_RENAME_ENTRY events Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).