]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
filelock: allow lease_managers to dictate what qualifies as a conflict
authorJeff Layton <jlayton@kernel.org>
Thu, 4 Dec 2025 13:48:33 +0000 (08:48 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Dec 2025 14:20:33 +0000 (15:20 +0100)
commit12965a190eaea614bb49e22041e8fc0d03d0310f
treedbe3ed4714f1f175c804370716cca79e4107e32d
parent392e317a20c32d45eebe4de8dc24408c6d1765d1
filelock: allow lease_managers to dictate what qualifies as a conflict

Requesting a delegation on a file from the userland fcntl() interface
currently succeeds when there are conflicting opens present.

This is because the lease handling code ignores conflicting opens for
FL_LAYOUT and FL_DELEG leases. This was a hack put in place long ago,
because nfsd already checks for conflicts in its own way. The kernel
needs to perform this check for userland delegations the same way it is
done for leases, however.

Make this dependent on the lease_manager by adding a new
->lm_open_conflict() lease_manager operation and have
generic_add_lease() call that instead of check_conflicting_open().
Morph check_conflicting_open() into a ->lm_open_conflict() op that is
only called for userland leases/delegations. Set the
->lm_open_conflict() operations for nfsd to trivial functions that
always return 0.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20251204-dir-deleg-ro-v2-2-22d37f92ce2c@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Documentation/filesystems/locking.rst
fs/locks.c
fs/nfsd/nfs4layouts.c
fs/nfsd/nfs4state.c
include/linux/filelock.h