From ca4388bf1d9e1daa849ea0550b83a6566e65502a Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:12:56 -0500 Subject: [PATCH 01/25] fs: add setlease to generic_ro_fops and read-only filesystem directory operations Add the setlease file_operation to generic_ro_fops, which covers file operations for several read-only filesystems (BEFS, EFS, ISOFS, QNX4, QNX6, CRAMFS, FREEVXFS). Also add setlease to the directory file_operations for these filesystems. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on these filesystems. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-1-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/befs/linuxvfs.c | 2 ++ fs/cramfs/inode.c | 2 ++ fs/efs/dir.c | 2 ++ fs/freevxfs/vxfs_lookup.c | 2 ++ fs/isofs/dir.c | 2 ++ fs/qnx4/dir.c | 2 ++ fs/qnx6/dir.c | 2 ++ fs/read_write.c | 2 ++ 8 files changed, 16 insertions(+) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 9fcfdd6b8189..d7c5d9270387 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ static const struct file_operations befs_dir_operations = { .read = generic_read_dir, .iterate_shared = befs_readdir, .llseek = generic_file_llseek, + .setlease = generic_setlease, }; static const struct inode_operations befs_dir_inode_operations = { diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index e54ebe402df7..41b1a869cf13 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -938,6 +939,7 @@ static const struct file_operations cramfs_directory_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = cramfs_readdir, + .setlease = generic_setlease, }; static const struct inode_operations cramfs_dir_inode_operations = { diff --git a/fs/efs/dir.c b/fs/efs/dir.c index f892ac7c2a35..35ad0092c115 100644 --- a/fs/efs/dir.c +++ b/fs/efs/dir.c @@ -6,6 +6,7 @@ */ #include +#include #include "efs.h" static int efs_readdir(struct file *, struct dir_context *); @@ -14,6 +15,7 @@ const struct file_operations efs_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = efs_readdir, + .setlease = generic_setlease, }; const struct inode_operations efs_dir_inode_operations = { diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index 1b0bca8b4cc6..138e08de976e 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c @@ -8,6 +8,7 @@ * Veritas filesystem driver - lookup and other directory related code. */ #include +#include #include #include #include @@ -36,6 +37,7 @@ const struct file_operations vxfs_dir_operations = { .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = vxfs_readdir, + .setlease = generic_setlease, }; diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index 09df40b612fb..2ca16c3fe5ef 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c @@ -12,6 +12,7 @@ * isofs directory handling functions */ #include +#include #include "isofs.h" int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode) @@ -271,6 +272,7 @@ const struct file_operations isofs_dir_operations = .llseek = generic_file_llseek, .read = generic_read_dir, .iterate_shared = isofs_readdir, + .setlease = generic_setlease, }; /* diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c index 42a529e26bd6..6402715ab377 100644 --- a/fs/qnx4/dir.c +++ b/fs/qnx4/dir.c @@ -13,6 +13,7 @@ */ #include +#include #include "qnx4.h" static int qnx4_readdir(struct file *file, struct dir_context *ctx) @@ -71,6 +72,7 @@ const struct file_operations qnx4_dir_operations = .read = generic_read_dir, .iterate_shared = qnx4_readdir, .fsync = generic_file_fsync, + .setlease = generic_setlease, }; const struct inode_operations qnx4_dir_inode_operations = diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c index b4d10e45f2e4..ae0c9846833d 100644 --- a/fs/qnx6/dir.c +++ b/fs/qnx6/dir.c @@ -11,6 +11,7 @@ * */ +#include #include "qnx6.h" static unsigned qnx6_lfile_checksum(char *name, unsigned size) @@ -275,6 +276,7 @@ const struct file_operations qnx6_dir_operations = { .read = generic_read_dir, .iterate_shared = qnx6_readdir, .fsync = generic_file_fsync, + .setlease = generic_setlease, }; const struct inode_operations qnx6_dir_inode_operations = { diff --git a/fs/read_write.c b/fs/read_write.c index 833bae068770..50bff7edc91f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "internal.h" #include @@ -30,6 +31,7 @@ const struct file_operations generic_ro_fops = { .read_iter = generic_file_read_iter, .mmap_prepare = generic_file_readonly_mmap_prepare, .splice_read = filemap_splice_read, + .setlease = generic_setlease, }; EXPORT_SYMBOL(generic_ro_fops); From 663cdef61a27bf593e48cedc37f28ed5cfbf8c11 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:12:57 -0500 Subject: [PATCH 02/25] affs: add setlease file operation Add the setlease file_operation to affs_file_operations and affs_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-2-ea4dec9b67fa@kernel.org Acked-by: David Sterba Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/affs/dir.c | 2 ++ fs/affs/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/affs/dir.c b/fs/affs/dir.c index bd40d5f08810..fe18caaf4d65 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -15,6 +15,7 @@ */ #include +#include #include "affs.h" struct affs_dir_data { @@ -55,6 +56,7 @@ const struct file_operations affs_dir_operations = { .iterate_shared = affs_readdir, .fsync = affs_file_fsync, .release = affs_dir_release, + .setlease = generic_setlease, }; /* diff --git a/fs/affs/file.c b/fs/affs/file.c index 765c3443663e..6c9258359ddb 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -15,6 +15,7 @@ #include #include +#include #include #include "affs.h" @@ -1008,6 +1009,7 @@ const struct file_operations affs_file_operations = { .release = affs_file_release, .fsync = affs_file_fsync, .splice_read = filemap_splice_read, + .setlease = generic_setlease, }; const struct inode_operations affs_file_inode_operations = { From f9688474e413f607f1a4e047d970b50dc268c84c Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:12:58 -0500 Subject: [PATCH 03/25] btrfs: add setlease file operation Add the setlease file_operation to btrfs_file_operations and btrfs_dir_file_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-3-ea4dec9b67fa@kernel.org Acked-by: David Sterba Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/btrfs/file.c | 2 ++ fs/btrfs/inode.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 1abc7ed2990e..aca2b541e72d 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -3867,6 +3868,7 @@ const struct file_operations btrfs_file_operations = { .remap_file_range = btrfs_remap_file_range, .uring_cmd = btrfs_uring_cmd, .fop_flags = FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC, + .setlease = generic_setlease, }; int btrfs_fdatawrite_range(struct btrfs_inode *inode, loff_t start, loff_t end) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d2b302ac6af9..d377794b4c9f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -10596,6 +10597,7 @@ static const struct file_operations btrfs_dir_file_operations = { #endif .release = btrfs_release_file, .fsync = btrfs_sync_file, + .setlease = generic_setlease, }; /* From f8902d3df8930099f0adec2cc4dd6d8cd3ebcbe7 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:12:59 -0500 Subject: [PATCH 04/25] erofs: add setlease file operation Add the setlease file_operation to erofs_file_fops and erofs_dir_fops, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-4-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Chao Yu Signed-off-by: Christian Brauner --- fs/erofs/data.c | 2 ++ fs/erofs/dir.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index bb13c4cb8455..e2941b471561 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -5,6 +5,7 @@ * Copyright (C) 2021, Alibaba Cloud */ #include "internal.h" +#include #include #include @@ -483,4 +484,5 @@ const struct file_operations erofs_file_fops = { .mmap_prepare = erofs_file_mmap_prepare, .get_unmapped_area = thp_get_unmapped_area, .splice_read = filemap_splice_read, + .setlease = generic_setlease, }; diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c index 32b4f5aa60c9..e5132575b9d3 100644 --- a/fs/erofs/dir.c +++ b/fs/erofs/dir.c @@ -5,6 +5,7 @@ * Copyright (C) 2022, Alibaba Cloud */ #include "internal.h" +#include static int erofs_fill_dentries(struct inode *dir, struct dir_context *ctx, void *dentry_blk, struct erofs_dirent *de, @@ -127,4 +128,5 @@ const struct file_operations erofs_dir_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = erofs_compat_ioctl, #endif + .setlease = generic_setlease, }; From ccdc2e0569f5ff83cd1c6a5c7bb214e33e21bdec Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:00 -0500 Subject: [PATCH 05/25] ext2: add setlease file operation Add the setlease file_operation to ext2_file_operations and ext2_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-5-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/ext2/dir.c | 2 ++ fs/ext2/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index b07b3b369710..395fc36c089b 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -24,6 +24,7 @@ #include "ext2.h" #include +#include #include #include #include @@ -734,4 +735,5 @@ const struct file_operations ext2_dir_operations = { .compat_ioctl = ext2_compat_ioctl, #endif .fsync = ext2_fsync, + .setlease = generic_setlease, }; diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 76bddce462fc..ebe356a38b18 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -325,6 +326,7 @@ const struct file_operations ext2_file_operations = { .get_unmapped_area = thp_get_unmapped_area, .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, + .setlease = generic_setlease, }; const struct inode_operations ext2_file_inode_operations = { From 20747a2a29c6a7ccc54fd3f3159bcfe86a0dae6e Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:01 -0500 Subject: [PATCH 06/25] ext4: add setlease file operation Add the setlease file_operation to ext4_file_operations and ext4_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-6-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/ext4/dir.c | 2 ++ fs/ext4/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 256fe2c1d4c1..00c4b3c82b65 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -690,4 +691,5 @@ const struct file_operations ext4_dir_operations = { #endif .fsync = ext4_sync_file, .release = ext4_release_dir, + .setlease = generic_setlease, }; diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 7a8b30932189..534cf864101f 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -980,6 +981,7 @@ const struct file_operations ext4_file_operations = { .fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC | FOP_DIO_PARALLEL_WRITE | FOP_DONTCACHE, + .setlease = generic_setlease, }; const struct inode_operations ext4_file_inode_operations = { From b8ca026675520441bebc2be3c1d35cc106c3c0ff Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:02 -0500 Subject: [PATCH 07/25] exfat: add setlease file operation Add the setlease file_operation to exfat_file_operations and exfat_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-7-ea4dec9b67fa@kernel.org Acked-by: Namjae Jeon Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/exfat/dir.c | 2 ++ fs/exfat/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 3045a58e124a..2dbf335eafef 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "exfat_raw.h" #include "exfat_fs.h" @@ -298,6 +299,7 @@ const struct file_operations exfat_dir_operations = { .compat_ioctl = exfat_compat_ioctl, #endif .fsync = exfat_file_fsync, + .setlease = generic_setlease, }; int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 536c8078f0c1..b60ee0e1bec9 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "exfat_raw.h" #include "exfat_fs.h" @@ -772,6 +773,7 @@ const struct file_operations exfat_file_operations = { .fsync = exfat_file_fsync, .splice_read = exfat_splice_read, .splice_write = iter_file_splice_write, + .setlease = generic_setlease, }; const struct inode_operations exfat_file_inode_operations = { From 9e2ac6ddb397408a77781b0de8525068f51a81cd Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:03 -0500 Subject: [PATCH 08/25] f2fs: add setlease file operation Add the setlease file_operation to f2fs_file_operations and f2fs_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-8-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Chao Yu Signed-off-by: Christian Brauner --- fs/f2fs/dir.c | 2 ++ fs/f2fs/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 48f4f98afb01..be70dfb3b152 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "f2fs.h" @@ -1136,4 +1137,5 @@ const struct file_operations f2fs_dir_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = f2fs_compat_ioctl, #endif + .setlease = generic_setlease, }; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index d7047ca6b98d..cd4b1d3c90ab 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -5457,4 +5458,5 @@ const struct file_operations f2fs_file_operations = { .splice_write = iter_file_splice_write, .fadvise = f2fs_file_fadvise, .fop_flags = FOP_BUFFER_RASYNC, + .setlease = generic_setlease, }; From a9acc8422ffbaa018337a4bcb6fabbddb6b9e18c Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:04 -0500 Subject: [PATCH 09/25] fat: add setlease file operation Add the setlease file_operation to fat_file_operations and fat_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-9-ea4dec9b67fa@kernel.org Acked-by: OGAWA Hirofumi Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/fat/dir.c | 2 ++ fs/fat/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 92b091783966..807bc8b1bc14 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include "fat.h" @@ -876,6 +877,7 @@ const struct file_operations fat_dir_operations = { .compat_ioctl = fat_compat_dir_ioctl, #endif .fsync = fat_file_fsync, + .setlease = generic_setlease, }; static int fat_get_short_entry(struct inode *dir, loff_t *pos, diff --git a/fs/fat/file.c b/fs/fat/file.c index 4fc49a614fb8..d50a6d8bfaae 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -212,6 +213,7 @@ const struct file_operations fat_file_operations = { .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .fallocate = fat_fallocate, + .setlease = generic_setlease, }; static int fat_cont_expand(struct inode *inode, loff_t size) From 3b514c333390746ce6dd1ebaa130dc534bda3b80 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:05 -0500 Subject: [PATCH 10/25] gfs2: add a setlease file operation gfs2_file_fops_nolock() already has this explicitly set, so it's only necessary to set this in gfs2_dir_fops_nolock(). A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-10-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/gfs2/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 86376f0dbf3a..6daa96d815e1 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1639,5 +1639,6 @@ const struct file_operations gfs2_dir_fops_nolock = { .release = gfs2_release, .fsync = gfs2_fsync, .llseek = default_llseek, + .setlease = generic_setlease, }; From c275e6e7c085d9f1e9be01a05d984a8c2cba5b34 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:06 -0500 Subject: [PATCH 11/25] jffs2: add setlease file operation Add the setlease file_operation to jffs2_file_operations and jffs2_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-11-ea4dec9b67fa@kernel.org Acked-by: Richard Weinberger Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/jffs2/dir.c | 2 ++ fs/jffs2/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index dd91f725ded6..2b38ce1fd8e8 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "jffs2_fs_i.h" @@ -48,6 +49,7 @@ const struct file_operations jffs2_dir_operations = .unlocked_ioctl=jffs2_ioctl, .fsync = jffs2_fsync, .llseek = generic_file_llseek, + .setlease = generic_setlease, }; diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index b697f3c259ef..5e1ef4bc009b 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -60,6 +61,7 @@ const struct file_operations jffs2_file_operations = .fsync = jffs2_fsync, .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, + .setlease = generic_setlease, }; /* jffs2_file_inode_operations */ From 7dd596bb35e579916576677b51c15171012a7854 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:07 -0500 Subject: [PATCH 12/25] jfs: add setlease file operation Add the setlease file_operation to jfs_file_operations and jfs_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-12-ea4dec9b67fa@kernel.org Acked-by: Richard Weinberger Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Dave Kleikamp Signed-off-by: Christian Brauner --- fs/jfs/file.c | 2 ++ fs/jfs/namei.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 87ad042221e7..246568cb9a6e 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include "jfs_incore.h" @@ -153,4 +154,5 @@ const struct file_operations jfs_file_operations = { .release = jfs_release, .unlocked_ioctl = jfs_ioctl, .compat_ioctl = compat_ptr_ioctl, + .setlease = generic_setlease, }; diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 65a218eba8fa..f7e2ae7a4c37 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -1545,6 +1546,7 @@ const struct file_operations jfs_dir_operations = { .unlocked_ioctl = jfs_ioctl, .compat_ioctl = compat_ptr_ioctl, .llseek = generic_file_llseek, + .setlease = generic_setlease, }; static int jfs_ci_hash(const struct dentry *dir, struct qstr *this) From f46bb13dc5d94471507ff9aed7a62a04d406b8b8 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:08 -0500 Subject: [PATCH 13/25] nilfs2: add setlease file operation Add the setlease file_operation to nilfs_file_operations and nilfs_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-13-ea4dec9b67fa@kernel.org Acked-by: Ryusuke Konishi Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/nilfs2/dir.c | 3 ++- fs/nilfs2/file.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 6ca3d74be1e1..b243199036df 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -30,6 +30,7 @@ */ #include +#include #include "nilfs.h" #include "page.h" @@ -661,5 +662,5 @@ const struct file_operations nilfs_dir_operations = { .compat_ioctl = nilfs_compat_ioctl, #endif /* CONFIG_COMPAT */ .fsync = nilfs_sync_file, - + .setlease = generic_setlease, }; diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 1b8d754db44d..f93b68c4877c 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include "nilfs.h" @@ -150,6 +151,7 @@ const struct file_operations nilfs_file_operations = { .fsync = nilfs_sync_file, .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, + .setlease = generic_setlease, }; const struct inode_operations nilfs_file_inode_operations = { From 6aaa1d6337b5721ede04385444e5796392419241 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:09 -0500 Subject: [PATCH 14/25] ntfs3: add setlease file operation Add the setlease file_operation to ntfs_file_operations, ntfs_legacy_file_operations, ntfs_dir_operations, and ntfs_legacy_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-14-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/ntfs3/dir.c | 3 +++ fs/ntfs3/file.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index b98e95d6b4d9..b66438e34bbb 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "debug.h" @@ -630,6 +631,7 @@ const struct file_operations ntfs_dir_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = ntfs_compat_ioctl, #endif + .setlease = generic_setlease, }; #if IS_ENABLED(CONFIG_NTFS_FS) @@ -638,6 +640,7 @@ const struct file_operations ntfs_legacy_dir_operations = { .read = generic_read_dir, .iterate_shared = ntfs_readdir, .open = ntfs_file_open, + .setlease = generic_setlease, }; #endif // clang-format on diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 2e7b2e566ebe..6cb4479072a6 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "debug.h" #include "ntfs.h" @@ -1477,6 +1478,7 @@ const struct file_operations ntfs_file_operations = { .fsync = ntfs_file_fsync, .fallocate = ntfs_fallocate, .release = ntfs_file_release, + .setlease = generic_setlease, }; #if IS_ENABLED(CONFIG_NTFS_FS) @@ -1486,6 +1488,7 @@ const struct file_operations ntfs_legacy_file_operations = { .splice_read = ntfs_file_splice_read, .open = ntfs_file_open, .release = ntfs_file_release, + .setlease = generic_setlease, }; #endif // clang-format on From f15d3150279d6c54a97eaac0c8f3c438c525c2f2 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:10 -0500 Subject: [PATCH 15/25] ocfs2: add setlease file operation Add the setlease file_operation to ocfs2_fops, ocfs2_dops, ocfs2_fops_no_plocks, and ocfs2_dops_no_plocks, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-15-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/ocfs2/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 732c61599159..ed961a854983 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2823,6 +2824,7 @@ const struct file_operations ocfs2_fops = { .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, .fop_flags = FOP_ASYNC_LOCK, + .setlease = generic_setlease, }; WRAP_DIR_ITER(ocfs2_readdir) // FIXME! @@ -2840,6 +2842,7 @@ const struct file_operations ocfs2_dops = { .lock = ocfs2_lock, .flock = ocfs2_flock, .fop_flags = FOP_ASYNC_LOCK, + .setlease = generic_setlease, }; /* @@ -2871,6 +2874,7 @@ const struct file_operations ocfs2_fops_no_plocks = { .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, .remap_file_range = ocfs2_remap_file_range, + .setlease = generic_setlease, }; const struct file_operations ocfs2_dops_no_plocks = { @@ -2885,4 +2889,5 @@ const struct file_operations ocfs2_dops_no_plocks = { .compat_ioctl = ocfs2_compat_ioctl, #endif .flock = ocfs2_flock, + .setlease = generic_setlease, }; From 136b43aa4b16563c8010c90c53303b745340d70f Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:11 -0500 Subject: [PATCH 16/25] orangefs: add setlease file operation Add the setlease file_operation to orangefs_file_operations and orangefs_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-16-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/orangefs/dir.c | 4 +++- fs/orangefs/file.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c index 6d1fbeca9d81..3c32bf9f1296 100644 --- a/fs/orangefs/dir.c +++ b/fs/orangefs/dir.c @@ -3,6 +3,7 @@ * Copyright 2017 Omnibond Systems, L.L.C. */ +#include #include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h" @@ -392,5 +393,6 @@ const struct file_operations orangefs_dir_operations = { .read = generic_read_dir, .iterate_shared = orangefs_dir_iterate, .open = orangefs_dir_open, - .release = orangefs_dir_release + .release = orangefs_dir_release, + .setlease = generic_setlease, }; diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index 919f99b16834..afd610a3fc68 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -583,4 +583,5 @@ const struct file_operations orangefs_file_operations = { .flush = orangefs_flush, .release = orangefs_file_release, .fsync = orangefs_fsync, + .setlease = generic_setlease, }; From 94a3f60af5dca72fffc041a64d4c3de5a066f98e Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:12 -0500 Subject: [PATCH 17/25] overlayfs: add setlease file operation Add the setlease file_operation to ovl_file_operations and ovl_dir_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-17-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/overlayfs/file.c | 2 ++ fs/overlayfs/readdir.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index cbae89457234..8269431ba3c6 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -647,4 +648,5 @@ const struct file_operations ovl_file_operations = { .copy_file_range = ovl_copy_file_range, .remap_file_range = ovl_remap_file_range, + .setlease = generic_setlease, }; diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index 160960bb0ad0..7fd415d7471e 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1070,6 +1071,7 @@ const struct file_operations ovl_dir_operations = { .llseek = ovl_dir_llseek, .fsync = ovl_dir_fsync, .release = ovl_dir_release, + .setlease = generic_setlease, }; int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list) From dfd8676efe436859300f22a6b7a445e7448321b6 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:13 -0500 Subject: [PATCH 18/25] squashfs: add setlease file operation Add the setlease file_operation pointing to generic_setlease to the squashfs file_operations structures. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-18-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/squashfs/dir.c | 2 ++ fs/squashfs/file.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c index a2ade63eccdf..cd3598bd034f 100644 --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -220,4 +221,5 @@ const struct file_operations squashfs_dir_ops = { .read = generic_read_dir, .iterate_shared = squashfs_readdir, .llseek = generic_file_llseek, + .setlease = generic_setlease, }; diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index 1582e0637a7e..4be92206e755 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c @@ -28,6 +28,7 @@ */ #include +#include #include #include #include @@ -775,5 +776,6 @@ const struct file_operations squashfs_file_operations = { .llseek = squashfs_llseek, .read_iter = generic_file_read_iter, .mmap_prepare = generic_file_readonly_mmap_prepare, - .splice_read = filemap_splice_read + .splice_read = filemap_splice_read, + .setlease = generic_setlease, }; From f5a3446be277f70ee330e214546e354be639ab01 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:14 -0500 Subject: [PATCH 19/25] tmpfs: add setlease file operation Add the setlease file_operation pointing to generic_setlease to the tmpfs file_operations structures. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-19-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/libfs.c | 2 ++ mm/shmem.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 591eb649ebba..697c6d5fc127 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -570,6 +571,7 @@ const struct file_operations simple_offset_dir_operations = { .iterate_shared = offset_readdir, .read = generic_read_dir, .fsync = noop_fsync, + .setlease = generic_setlease, }; struct dentry *find_next_child(struct dentry *parent, struct dentry *prev) diff --git a/mm/shmem.c b/mm/shmem.c index ec6c01378e9d..88ef1fd5cd38 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -5219,6 +5220,7 @@ static const struct file_operations shmem_file_operations = { .splice_read = shmem_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = shmem_fallocate, + .setlease = generic_setlease, #endif }; From dbe8d57d148327a39dc4921aa1d3434ea259945e Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:15 -0500 Subject: [PATCH 20/25] udf: add setlease file operation Add the setlease file_operation pointing to generic_setlease to the udf file_operations structures. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-20-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/udf/dir.c | 2 ++ fs/udf/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/udf/dir.c b/fs/udf/dir.c index 5023dfe191e8..5bf75638f352 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -157,4 +158,5 @@ const struct file_operations udf_dir_operations = { .iterate_shared = udf_readdir, .unlocked_ioctl = udf_ioctl, .fsync = generic_file_fsync, + .setlease = generic_setlease, }; diff --git a/fs/udf/file.c b/fs/udf/file.c index 0d76c4f37b3e..32ae7cfd72c5 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -28,6 +28,7 @@ #include /* memset */ #include #include +#include #include #include @@ -208,6 +209,7 @@ const struct file_operations udf_file_operations = { .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, .llseek = generic_file_llseek, + .setlease = generic_setlease, }; static int udf_setattr(struct mnt_idmap *idmap, struct dentry *dentry, From 545b4144d804604126c369dd5bd66ff1e668c7d9 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:16 -0500 Subject: [PATCH 21/25] ufs: add setlease file operation Add the setlease file_operation pointing to generic_setlease to the ufs file_operations structures. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-21-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/ufs/dir.c | 2 ++ fs/ufs/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 0388a1bae326..43f1578ab866 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -653,4 +654,5 @@ const struct file_operations ufs_dir_operations = { .iterate_shared = ufs_readdir, .fsync = generic_file_fsync, .llseek = ufs_dir_llseek, + .setlease = generic_setlease, }; diff --git a/fs/ufs/file.c b/fs/ufs/file.c index c2a391c17df7..809c7a4603f8 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -25,6 +25,7 @@ */ #include +#include #include "ufs_fs.h" #include "ufs.h" @@ -43,4 +44,5 @@ const struct file_operations ufs_file_operations = { .fsync = generic_file_fsync, .splice_read = filemap_splice_read, .splice_write = iter_file_splice_write, + .setlease = generic_setlease, }; From 6163b5da2f5eff5fdad6bad9fa1ca37c7d2d0d5d Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:17 -0500 Subject: [PATCH 22/25] xfs: add setlease file operation Add the setlease file_operation pointing to generic_setlease to the xfs file_operations structures. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-22-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Signed-off-by: Christian Brauner --- fs/xfs/xfs_file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 7874cf745af3..ecd7bf42446b 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -36,6 +36,7 @@ #include #include #include +#include static const struct vm_operations_struct xfs_file_vm_ops; @@ -2007,6 +2008,7 @@ const struct file_operations xfs_file_operations = { .fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC | FOP_DIO_PARALLEL_WRITE | FOP_DONTCACHE, + .setlease = generic_setlease, }; const struct file_operations xfs_dir_file_operations = { @@ -2019,4 +2021,5 @@ const struct file_operations xfs_dir_file_operations = { .compat_ioctl = xfs_file_compat_ioctl, #endif .fsync = xfs_dir_fsync, + .setlease = generic_setlease, }; From 2b10994be716b07d881ad0f966d6a4bb13b20750 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:18 -0500 Subject: [PATCH 23/25] 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 Link: https://patch.msgid.link/20260108-setlease-6-20-v1-23-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- Documentation/filesystems/porting.rst | 9 +++++++++ Documentation/filesystems/vfs.rst | 9 ++++++--- fs/locks.c | 3 +-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst index 3397937ed838..c0f7103628ab 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1334,3 +1334,12 @@ end_creating() and the parent will be unlocked precisely when necessary. kill_litter_super() is gone; convert to DCACHE_PERSISTENT use (as all in-tree filesystems have done). + +--- + +**mandatory** + +The ->setlease() file_operation must now be explicitly set in order to provide +support for leases. When set to NULL, the kernel will now return -EINVAL to +attempts to set a lease. Filesystems that wish to use the kernel-internal lease +implementation should set it to generic_setlease(). diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst index 670ba66b60e4..21dc8921dd9e 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -1180,9 +1180,12 @@ otherwise noted. method is used by the splice(2) system call ``setlease`` - called by the VFS to set or release a file lock lease. setlease - implementations should call generic_setlease to record or remove - the lease in the inode after setting it. + called by the VFS to set or release a file lock lease. Local + filesystems that wish to use the kernel-internal lease implementation + should set this to generic_setlease(). Other setlease implementations + should call generic_setlease() to record or remove the lease in the inode + after setting it. When set to NULL, attempts to set or remove a lease will + return -EINVAL. ``fallocate`` called by the VFS to preallocate blocks or punch a hole. diff --git a/fs/locks.c b/fs/locks.c index 7ea949d7ff45..cf1968b01bcb 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2019,8 +2019,7 @@ kernel_setlease(struct file *filp, int arg, struct file_lease **lease, void **pr setlease_notifier(arg, *lease); if (filp->f_op->setlease) return filp->f_op->setlease(filp, arg, lease, priv); - else - return generic_setlease(filp, arg, lease, priv); + return -EINVAL; } EXPORT_SYMBOL_GPL(kernel_setlease); From 51e49111c00bee76ca403adf7cd617b71a9a0da4 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Thu, 8 Jan 2026 12:13:19 -0500 Subject: [PATCH 24/25] fs: remove simple_nosetlease() Setting ->setlease() to a NULL pointer now has the same effect as setting it to simple_nosetlease(). Remove all of the setlease file_operations that are set to simple_nosetlease, and the function itself. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260108-setlease-6-20-v1-24-ea4dec9b67fa@kernel.org Acked-by: Al Viro Acked-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/9p/vfs_dir.c | 2 -- fs/9p/vfs_file.c | 2 -- fs/ceph/dir.c | 2 -- fs/ceph/file.c | 1 - fs/fuse/dir.c | 1 - fs/gfs2/file.c | 2 -- fs/libfs.c | 18 ------------------ fs/nfs/dir.c | 1 - fs/nfs/file.c | 1 - fs/smb/client/cifsfs.c | 1 - fs/vboxsf/dir.c | 1 - fs/vboxsf/file.c | 1 - include/linux/fs.h | 1 - 13 files changed, 34 deletions(-) diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index af7f72abbb76..e0d34e4e9076 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -242,7 +242,6 @@ const struct file_operations v9fs_dir_operations = { .iterate_shared = v9fs_dir_readdir, .open = v9fs_file_open, .release = v9fs_dir_release, - .setlease = simple_nosetlease, }; const struct file_operations v9fs_dir_operations_dotl = { @@ -252,5 +251,4 @@ const struct file_operations v9fs_dir_operations_dotl = { .open = v9fs_file_open, .release = v9fs_dir_release, .fsync = v9fs_file_fsync_dotl, - .setlease = simple_nosetlease, }; diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 6f3880208587..c5e73c37baea 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -517,7 +517,6 @@ const struct file_operations v9fs_file_operations = { .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync, - .setlease = simple_nosetlease, }; const struct file_operations v9fs_file_operations_dotl = { @@ -532,5 +531,4 @@ const struct file_operations v9fs_file_operations_dotl = { .splice_read = v9fs_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, - .setlease = simple_nosetlease, }; diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 804588524cd5..86d7aa594ea9 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -2214,7 +2214,6 @@ const struct file_operations ceph_dir_fops = { .fsync = ceph_fsync, .lock = ceph_lock, .flock = ceph_flock, - .setlease = simple_nosetlease, }; const struct file_operations ceph_snapdir_fops = { @@ -2222,7 +2221,6 @@ const struct file_operations ceph_snapdir_fops = { .llseek = ceph_dir_llseek, .open = ceph_open, .release = ceph_release, - .setlease = simple_nosetlease, }; const struct inode_operations ceph_dir_iops = { diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 983390069f73..31b691b2aea2 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -3169,7 +3169,6 @@ const struct file_operations ceph_file_fops = { .mmap_prepare = ceph_mmap_prepare, .fsync = ceph_fsync, .lock = ceph_lock, - .setlease = simple_nosetlease, .flock = ceph_flock, .splice_read = ceph_splice_read, .splice_write = iter_file_splice_write, diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 64b29db52cf4..7c183ec496bf 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -2430,7 +2430,6 @@ static const struct file_operations fuse_dir_operations = { .fsync = fuse_dir_fsync, .unlocked_ioctl = fuse_dir_ioctl, .compat_ioctl = fuse_dir_compat_ioctl, - .setlease = simple_nosetlease, }; static const struct inode_operations fuse_common_inode_operations = { diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 6daa96d815e1..3e061e8115ec 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1593,7 +1593,6 @@ const struct file_operations gfs2_file_fops = { .flock = gfs2_flock, .splice_read = copy_splice_read, .splice_write = gfs2_file_splice_write, - .setlease = simple_nosetlease, .fallocate = gfs2_fallocate, .fop_flags = FOP_ASYNC_LOCK, }; @@ -1608,7 +1607,6 @@ const struct file_operations gfs2_dir_fops = { .lock = gfs2_lock, .flock = gfs2_flock, .llseek = default_llseek, - .setlease = simple_nosetlease, .fop_flags = FOP_ASYNC_LOCK, }; diff --git a/fs/libfs.c b/fs/libfs.c index 697c6d5fc127..f1860dff86f2 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1699,24 +1699,6 @@ struct inode *alloc_anon_inode(struct super_block *s) } EXPORT_SYMBOL(alloc_anon_inode); -/** - * simple_nosetlease - generic helper for prohibiting leases - * @filp: file pointer - * @arg: type of lease to obtain - * @flp: new lease supplied for insertion - * @priv: private data for lm_setup operation - * - * Generic helper for filesystems that do not wish to allow leases to be set. - * All arguments are ignored and it just returns -EINVAL. - */ -int -simple_nosetlease(struct file *filp, int arg, struct file_lease **flp, - void **priv) -{ - return -EINVAL; -} -EXPORT_SYMBOL(simple_nosetlease); - /** * simple_get_link - generic helper to get the target of "fast" symlinks * @dentry: not used here diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 71df279febf7..23a78a742b61 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -66,7 +66,6 @@ const struct file_operations nfs_dir_operations = { .open = nfs_opendir, .release = nfs_closedir, .fsync = nfs_fsync_dir, - .setlease = simple_nosetlease, }; const struct address_space_operations nfs_dir_aops = { diff --git a/fs/nfs/file.c b/fs/nfs/file.c index d020aab40c64..9d2695619618 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -962,7 +962,6 @@ const struct file_operations nfs_file_operations = { .splice_read = nfs_file_splice_read, .splice_write = iter_file_splice_write, .check_flags = nfs_check_flags, - .setlease = simple_nosetlease, .fop_flags = FOP_DONTCACHE, }; EXPORT_SYMBOL_GPL(nfs_file_operations); diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index a3dc7cb1ab54..8015df1f711e 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1709,7 +1709,6 @@ const struct file_operations cifs_dir_ops = { .remap_file_range = cifs_remap_file_range, .llseek = generic_file_llseek, .fsync = cifs_dir_fsync, - .setlease = simple_nosetlease, }; static void diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c index 230d7589d15c..42bedc4ec7af 100644 --- a/fs/vboxsf/dir.c +++ b/fs/vboxsf/dir.c @@ -186,7 +186,6 @@ const struct file_operations vboxsf_dir_fops = { .release = vboxsf_dir_release, .read = generic_read_dir, .llseek = generic_file_llseek, - .setlease = simple_nosetlease, }; /* diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c index 4bebd947314a..111752010edb 100644 --- a/fs/vboxsf/file.c +++ b/fs/vboxsf/file.c @@ -218,7 +218,6 @@ const struct file_operations vboxsf_reg_fops = { .release = vboxsf_file_release, .fsync = noop_fsync, .splice_read = filemap_splice_read, - .setlease = simple_nosetlease, }; const struct inode_operations vboxsf_reg_iops = { diff --git a/include/linux/fs.h b/include/linux/fs.h index f5c9cf28c4dc..e46e8aad9339 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3217,7 +3217,6 @@ extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *name, const struct inode *context_inode); -extern int simple_nosetlease(struct file *, int, struct file_lease **, void **); extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); From 056a96e65f3e2a3293b99a336de92376407af5fa Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 12 Jan 2026 08:01:21 -0500 Subject: [PATCH 25/25] fuse: add setlease file operation Add the setlease file_operation to fuse_file_operations, pointing to generic_setlease. A future patch will change the default behavior to reject lease attempts with -EINVAL when there is no setlease file operation defined. Add generic_setlease to retain the ability to set leases on this filesystem. Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260112130121.25965-1-jlayton@kernel.org Signed-off-by: Christian Brauner --- fs/fuse/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 01bc894e9c2b..2956f6cb598d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3177,6 +3177,7 @@ static const struct file_operations fuse_file_operations = { .poll = fuse_file_poll, .fallocate = fuse_file_fallocate, .copy_file_range = fuse_copy_file_range, + .setlease = generic_setlease, }; static const struct address_space_operations fuse_file_aops = {