]> Git Repo - J-linux.git/commitdiff
Merge patch series "Fixup NLM and kNFSD file lock callbacks"
authorChristian Brauner <[email protected]>
Thu, 12 Sep 2024 12:39:13 +0000 (14:39 +0200)
committerChristian Brauner <[email protected]>
Wed, 2 Oct 2024 05:52:07 +0000 (07:52 +0200)
Benjamin Coddington <[email protected]> says:

Last year both GFS2 and OCFS2 had some work done to make their locking more
robust when exported over NFS.  Unfortunately, part of that work caused both
NLM (for NFS v3 exports) and kNFSD (for NFSv4.1+ exports) to no longer send
lock notifications to clients.

This in itself is not a huge problem because most NFS clients will still
poll the server in order to acquire a conflicted lock, but now that I've
noticed it I can't help but try to fix it because there are big advantages
for setups that might depend on timely lock notifications, and we've
supported that as a feature for a long time.

Its important for NLM and kNFSD that they do not block their kernel threads
inside filesystem's file_lock implementations because that can produce
deadlocks.  We used to make sure of this by only trusting that
posix_lock_file() can correctly handle blocking lock calls asynchronously,
so the lock managers would only setup their file_lock requests for async
callbacks if the filesystem did not define its own lock() file operation.

However, when GFS2 and OCFS2 grew the capability to correctly
handle blocking lock requests asynchronously, they started signalling this
behavior with EXPORT_OP_ASYNC_LOCK, and the check for also trusting
posix_lock_file() was inadvertently dropped, so now most filesystems no
longer produce lock notifications when exported over NFS.

I tried to fix this by simply including the old check for lock(), but the
resulting include mess and layering violations was more than I could accept.
There's a much cleaner way presented here using an fop_flag, which while
potentially flag-greedy, greatly simplifies the problem and grooms the
way for future uses by both filesystems and lock managers alike.

* patches from https://lore.kernel.org/r/cover.1726083391[email protected]:
  exportfs: Remove EXPORT_OP_ASYNC_LOCK
  NLM/NFSD: Fix lock notifications for async-capable filesystems
  gfs2/ocfs2: set FOP_ASYNC_LOCK
  fs: Introduce FOP_ASYNC_LOCK
  NFS: trace: show TIMEDOUT instead of 0x6e
  nfsd: use system_unbound_wq for nfsd_file_gc_worker()
  nfsd: count nfsd_file allocations
  nfsd: fix refcount leak when file is unhashed after being found
  nfsd: remove unneeded EEXIST error check in nfsd_do_file_acquire
  nfsd: add list_head nf_gc to struct nfsd_file

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
1  2 
fs/gfs2/file.c
fs/nfsd/nfs4state.c
fs/ocfs2/file.c
include/linux/filelock.h
include/linux/fs.h

diff --cc fs/gfs2/file.c
Simple merge
Simple merge
diff --cc fs/ocfs2/file.c
Simple merge
Simple merge
index e3c603d01337650d562405500013f5c4cfed8eb6,78221ae589d9d7c90fbc86a0c918c87bd416a28a..d369c582f129204ec5b15490d3aa5cf9f208b000
@@@ -2114,8 -2074,8 +2114,10 @@@ struct file_operations 
  #define FOP_DIO_PARALLEL_WRITE        ((__force fop_flags_t)(1 << 3))
  /* Contains huge pages */
  #define FOP_HUGE_PAGES                ((__force fop_flags_t)(1 << 4))
 -#define FOP_ASYNC_LOCK                ((__force fop_flags_t)(1 << 5))
 +/* Treat loff_t as unsigned (e.g., /dev/mem) */
 +#define FOP_UNSIGNED_OFFSET   ((__force fop_flags_t)(1 << 5))
+ /* Supports asynchronous lock callbacks */
++#define FOP_ASYNC_LOCK                ((__force fop_flags_t)(1 << 6))
  
  /* Wrap a directory iterator that needs exclusive inode access */
  int wrap_directory_iterator(struct file *, struct dir_context *,
This page took 0.132525 seconds and 4 git commands to generate.