Skip to content

Commit 2b10994

Browse files
jtlaytonbrauner
authored andcommitted
filelock: default to returning -EINVAL when ->setlease operation is NULL
Now that most filesystems where we expect to need lease support have their ->setlease() operations explicitly set, change kernel_setlease() to return -EINVAL when the setlease is a NULL pointer. Also update the Documentation/ with info about this change. Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260108-setlease-6-20-v1-23-ea4dec9b67fa@kernel.org Acked-by: Al Viro <viro@zeniv.linux.org.uk> Acked-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6163b5d commit 2b10994

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Documentation/filesystems/porting.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,3 +1334,12 @@ end_creating() and the parent will be unlocked precisely when necessary.
13341334

13351335
kill_litter_super() is gone; convert to DCACHE_PERSISTENT use (as all
13361336
in-tree filesystems have done).
1337+
1338+
---
1339+
1340+
**mandatory**
1341+
1342+
The ->setlease() file_operation must now be explicitly set in order to provide
1343+
support for leases. When set to NULL, the kernel will now return -EINVAL to
1344+
attempts to set a lease. Filesystems that wish to use the kernel-internal lease
1345+
implementation should set it to generic_setlease().

Documentation/filesystems/vfs.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,12 @@ otherwise noted.
11801180
method is used by the splice(2) system call
11811181

11821182
``setlease``
1183-
called by the VFS to set or release a file lock lease. setlease
1184-
implementations should call generic_setlease to record or remove
1185-
the lease in the inode after setting it.
1183+
called by the VFS to set or release a file lock lease. Local
1184+
filesystems that wish to use the kernel-internal lease implementation
1185+
should set this to generic_setlease(). Other setlease implementations
1186+
should call generic_setlease() to record or remove the lease in the inode
1187+
after setting it. When set to NULL, attempts to set or remove a lease will
1188+
return -EINVAL.
11861189

11871190
``fallocate``
11881191
called by the VFS to preallocate blocks or punch a hole.

fs/locks.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,8 +2019,7 @@ kernel_setlease(struct file *filp, int arg, struct file_lease **lease, void **pr
20192019
setlease_notifier(arg, *lease);
20202020
if (filp->f_op->setlease)
20212021
return filp->f_op->setlease(filp, arg, lease, priv);
2022-
else
2023-
return generic_setlease(filp, arg, lease, priv);
2022+
return -EINVAL;
20242023
}
20252024
EXPORT_SYMBOL_GPL(kernel_setlease);
20262025

0 commit comments

Comments
 (0)