vfs, nfsd: implement directory delegations
Get series with b4
b4 am [email protected] change-id 20240215-dir-deleg-e212210ba9d4Versions newest first
- v3 Latest38 patches 17 repliesIn review
- v2 RFC28 patches 5 repliesSuperseded
- v1 RFC24 patches 22 repliesSuperseded
Changes in v3 from the cover letter
- Rework to do minimal work in fsnotify callbacks
- Add support for sending attributes in CB_NOTIFY calls
- Add support for dir attr change notifications
- Link to v2: https://lore.kernel.org/r/[email protected]
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/38 | filelock: push the S_ISREG check down to ->setlease handlersfs/ fs/ fs/ +1 more | +9 | 0 replies | |
| 2/38 | filelock: add a lm_may_setlease lease_manager callbackfs/ include/ | +19 | 0 replies | |
| 3/38 | vfs: add try_break_deleg calls for parents to vfs_{link,rename,unlink}fs/ | +14 | 1 reply | |
| 4/38 | vfs: allow mkdir to wait for delegation break on parentdrivers/ fs/ fs/ +8 more | +28 | 2 replies | |
| 5/38 | vfs: allow rmdir to wait for delegation break on parentfs/ | +34 | 1 reply | |
| 6/38 | vfs: break parent dir delegations in open(..., O_CREAT) codepathfs/ | +18 | 1 reply | |
| 7/38 | vfs: make vfs_create break delegations on parent directoryfs/ | +36 | 3 replies | |
| 8/38 | vfs: make vfs_mknod break delegations on parent directoryfs/ | +35 | 2 replies | |
| 9/38 | filelock: lift the ban on directory leases in generic_setleasefs/ | +3 | 0 replies | |
| 10/38 | nfsd: allow filecache to hold S_IFDIR filesfs/ fs/ fs/ +1 more | +44 | 0 replies | |
| 11/38 | nfsd: allow DELEGRETURN on directoriesfs/ | +2 | 0 replies | |
| 12/38 | nfsd: check for delegation conflicts vs. the same clientfs/ | +28 | 0 replies | |
| 13/38 | nfsd: wire up GET_DIR_DELEGATION handlingfs/ fs/ fs/ | +107 | 0 replies | |
| 14/38 | filelock: rework the __break_lease API to use flagsfs/ include/ | +56 | 0 replies | |
| 15/38 | filelock: add struct delegated_inodefs/ fs/ fs/ +6 more | +116 | 0 replies | |
| 16/38 | filelock: add support for ignoring deleg breaks for dir change eventsfs/ include/ include/ | +67 | 0 replies | |
| 17/38 | filelock: add a tracepoint to start of break_lease()fs/ include/ | +35 | 0 replies | |
| 18/38 | filelock: add an inode_lease_ignore_mask helperfs/ include/ | +33 | 0 replies | |
| 19/38 | nfsd: add protocol support for CB_NOTIFYDocumentation/ fs/ fs/ +4 more | +1061 | 0 replies | |
| 20/38 | nfs_common: add new NOTIFY4_* flags proposed in RFC8881bisDocumentation/ fs/ fs/ +1 more | +29 | 0 replies | |
| 21/38 | nfsd: allow nfsd to get a dir lease with an ignore maskfs/ | +21 | 0 replies | |
| 22/38 | vfs: add fsnotify_modify_mark_mask()fs/ include/ | +30 | 1 reply | |
| 23/38 | nfsd: update the fsnotify mark when setting or removing a dir delegationfs/ | +35 | 0 replies | |
| 24/38 | nfsd: make nfsd4_callback_ops->prepare operation bool returnfs/ fs/ fs/ +1 more | +13 | 0 replies | |
| 25/38 | nfsd: add callback encoding and decoding linkages for CB_NOTIFYfs/ fs/ fs/ | +66 | 0 replies | |
| 26/38 | nfsd: add data structures for handling CB_NOTIFY to directory delegationfs/ fs/ | +149 | 0 replies | |
| 27/38 | nfsd: add notification handlers for dir eventsfs/ fs/ fs/ +3 more | +337 | 1 reply | |
| 28/38 | nfsd: add tracepoint to dir_event handlerfs/ fs/ | +22 | 0 replies | |
| 29/38 | nfsd: apply the notify mask to the delegation when requestedfs/ | +12 | 0 replies | |
| 30/38 | nfsd: add helper to marshal a fattr4 from completed argsfs/ | +26 | 0 replies | |
| 31/38 | nfsd: allow nfsd4_encode_fattr4_change() to work with no exportfs/ | +1 | 0 replies | |
| 32/38 | nfsd: send basic file attributes in CB_NOTIFYfs/ | +45 | 0 replies | |
| 33/38 | nfsd: allow encoding a filehandle into fattr4 without a svc_fhfs/ | +20 | 0 replies | |
| 34/38 | nfsd: add a fi_connectable flag to struct nfs4_filefs/ fs/ | +2 | 0 replies | |
| 35/38 | nfsd: add the filehandle to returned attributes in CB_NOTIFYfs/ | +36 | 0 replies | |
| 36/38 | nfsd: properly track requested child attributesfs/ fs/ fs/ +1 more | +29 | 0 replies | |
| 37/38 | nfsd: track requested dir attributesfs/ fs/ fs/ | +19 | 0 replies | |
| 38/38 | nfsd: add support to CB_NOTIFY for dir attribute changesfs/ fs/ fs/ | +75 | 0 replies |
Reviews trailers per patch
6 of 38 patches have a Reviewed-by or Acked-by.
| Patch | Jan Kara |
|---|---|
| 1/38 | |
| 2/38 | |
| 3/38 | R-b |
| 4/38 | R-b |
| 5/38 | |
| 6/38 | R-b |
| 7/38 | R-b R-b |
| 8/38 | R-b |
| 9/38 | |
| 10/38 | |
| 11/38 | |
| 12/38 | |
| 13/38 | |
| 14/38 | |
| 15/38 | |
| 16/38 | |
| 17/38 | |
| 18/38 | |
| 19/38 | |
| 20/38 | |
| 21/38 | |
| 22/38 | A-b |
| 23/38 | |
| 24/38 | |
| 25/38 | |
| 26/38 | |
| 27/38 | |
| 28/38 | |
| 29/38 | |
| 30/38 | |
| 31/38 | |
| 32/38 | |
| 33/38 | |
| 34/38 | |
| 35/38 | |
| 36/38 | |
| 37/38 | |
| 38/38 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 00/38] vfs, nfsd: implement directory delegations
This patchset is an update to a patchset that I posted in early June this year [1]. This version should be basically feature-complete, with a few caveats.
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 (modulo the case where the client requests notifications of directory changes).
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 that support no notifications. From there it adds VFS support for ignoring certain break_lease() events in directories. It then adds support for basic CB_NOTIFY calls (with names only). Next, support for sending attributes in the notifications is added.
I think that this version should be getting close to merge ready. Anna has graciously agreed to work on the client-side pieces for this. I've mostly been testing using pynfs tests (which I will submit soon).
The main limitation at this point is that callback requests are currently limited to a single page, so we can't send very many in a single CB_NOTIFY call. This will make it easy to "get into the weeds" if you're changing a directory quickly. The server will just recall the delegation in that case, so it's harmless even though it's not ideal.
If this approach looks acceptable I'll see if we can increase that limitation (it seems doable).
If anyone wishes to try this out, it's in the "dir-deleg" branch in my tree at kernel.org [4].
[1]: https://lore.kernel.org/linux-nfs/[email protected]/
[2]: https://www.youtube.com/watch?v=DdFyH3BN5pI
[3]: https://linux-nfs.org/wiki/index.php/CITI_Experience_with_Directory_Delegations
[4]: https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git/
---
Changes in v3:
- Rework to do minimal work in fsnotify callbacks
- Add support for sending attributes in CB_NOTIFY calls
- Add support for dir attr change notifications
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- add support for ignoring certain break_lease() events
- basic support for CB_NOTIFY
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jeff Layton (38):
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 a tracepoint to start of break_lease()
filelock: add an inode_lease_ignore_mask helper
nfsd: add protocol support for CB_NOTIFY
nfs_common: add new NOTIFY4_* flags proposed in RFC8881bis
nfsd: allow nfsd to get a dir lease with an ignore mask
vfs: add fsnotify_modify_mark_mask()
nfsd: update the fsnotify mark when setting or removing a dir delegation
nfsd: make nfsd4_callback_ops->prepare operation bool return
nfsd: add callback encoding and decoding linkages for CB_NOTIFY
nfsd: add data structures for handling CB_NOTIFY to directory delegation
nfsd: add notification handlers for dir events
nfsd: add tracepoint to dir_event handler
nfsd: apply the notify mask to the delegation when requested
nfsd: add helper to marshal a fattr4 from completed args
nfsd: allow nfsd4_encode_fattr4_change() to work with no export
nfsd: send basic file attributes in CB_NOTIFY
nfsd: allow encoding a filehandle into fattr4 without a svc_fh
nfsd: add a fi_connectable flag to struct nfs4_file
nfsd: add the filehandle to returned attributes in CB_NOTIFY
nfsd: properly track requested child attributes
nfsd: track requested dir attributes
nfsd: add support to CB_NOTIFY for dir attribute changes
Documentation/sunrpc/xdr/nfs4_1.x | 267 +++++++++++++++++- drivers/base/devtmpfs.c | 2 +- fs/attr.c | 4 +- fs/cachefiles/namei.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/fuse/dir.c | 1 + fs/init.c | 2 +- fs/locks.c | 122 ++++++-- fs/namei.c | 253 +++++++++++------ fs/nfs/nfs4file.c | 2 + fs/nfsd/filecache.c | 101 +++++-- fs/nfsd/filecache.h | 2 + fs/nfsd/nfs4callback.c | 60 +++- fs/nfsd/nfs4layouts.c | 3 +- fs/nfsd/nfs4proc.c | 36 ++- fs/nfsd/nfs4recover.c | 2 +- fs/nfsd/nfs4state.c | 531 +++++++++++++++++++++++++++++++++-- fs/nfsd/nfs4xdr.c | 298 +++++++++++++++++--- fs/nfsd/nfs4xdr_gen.c | 506 ++++++++++++++++++++++++++++++++- fs/nfsd/nfs4xdr_gen.h | 20 +- fs/nfsd/state.h | 73 ++++- fs/nfsd/trace.h | 21 ++ fs/nfsd/vfs.c | 7 +- fs/nfsd/vfs.h | 2 +- fs/nfsd/xdr4.h | 3 + fs/nfsd/xdr4cb.h | 12 + fs/notify/mark.c | 29 ++ fs/open.c | 8 +- fs/overlayfs/overlayfs.h | 2 +- fs/posix_acl.c | 12 +- fs/smb/client/cifsfs.c | 3 + fs/smb/server/vfs.c | 2 +- fs/utimes.c | 4 +- fs/xattr.c | 16 +- fs/xfs/scrub/orphanage.c | 2 +- include/linux/filelock.h | 143 +++++++--- include/linux/fs.h | 11 +- include/linux/fsnotify_backend.h | 1 + include/linux/nfs4.h | 127 --------- include/linux/sunrpc/xdrgen/nfs4_1.h | 304 +++++++++++++++++++- include/linux/xattr.h | 4 +- include/trace/events/filelock.h | 38 ++- include/uapi/linux/nfs4.h | 2 - 43 files changed, 2636 insertions(+), 406 deletions(-)
---
base-commit: 36c204d169319562eed170f266c58460d5dad635
change-id: 20240215-dir-deleg-e212210ba9d4
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>