summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/porting.rst9
-rw-r--r--Documentation/filesystems/vfs.rst9
-rw-r--r--fs/9p/vfs_dir.c2
-rw-r--r--fs/9p/vfs_file.c2
-rw-r--r--fs/affs/dir.c2
-rw-r--r--fs/affs/file.c2
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/btrfs/file.c2
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/ceph/dir.c2
-rw-r--r--fs/ceph/file.c1
-rw-r--r--fs/cramfs/inode.c2
-rw-r--r--fs/efs/dir.c2
-rw-r--r--fs/erofs/data.c2
-rw-r--r--fs/erofs/dir.c2
-rw-r--r--fs/exfat/dir.c2
-rw-r--r--fs/exfat/file.c2
-rw-r--r--fs/ext2/dir.c2
-rw-r--r--fs/ext2/file.c2
-rw-r--r--fs/ext4/dir.c2
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/f2fs/dir.c2
-rw-r--r--fs/f2fs/file.c2
-rw-r--r--fs/fat/dir.c2
-rw-r--r--fs/fat/file.c2
-rw-r--r--fs/freevxfs/vxfs_lookup.c2
-rw-r--r--fs/fuse/dir.c1
-rw-r--r--fs/gfs2/file.c3
-rw-r--r--fs/isofs/dir.c2
-rw-r--r--fs/jffs2/dir.c2
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/jfs/file.c2
-rw-r--r--fs/jfs/namei.c2
-rw-r--r--fs/libfs.c20
-rw-r--r--fs/locks.c3
-rw-r--r--fs/nfs/dir.c1
-rw-r--r--fs/nfs/file.c1
-rw-r--r--fs/nilfs2/dir.c3
-rw-r--r--fs/nilfs2/file.c2
-rw-r--r--fs/ntfs3/dir.c3
-rw-r--r--fs/ntfs3/file.c3
-rw-r--r--fs/ocfs2/file.c5
-rw-r--r--fs/orangefs/dir.c4
-rw-r--r--fs/orangefs/file.c1
-rw-r--r--fs/overlayfs/file.c2
-rw-r--r--fs/overlayfs/readdir.c2
-rw-r--r--fs/qnx4/dir.c2
-rw-r--r--fs/qnx6/dir.c2
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/smb/client/cifsfs.c1
-rw-r--r--fs/squashfs/dir.c2
-rw-r--r--fs/squashfs/file.c4
-rw-r--r--fs/udf/dir.c2
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/ufs/dir.c2
-rw-r--r--fs/ufs/file.c2
-rw-r--r--fs/vboxsf/dir.c1
-rw-r--r--fs/vboxsf/file.c1
-rw-r--r--fs/xfs/xfs_file.c3
-rw-r--r--include/linux/fs.h1
-rw-r--r--mm/shmem.c2
61 files changed, 116 insertions, 42 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/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/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 <linux/iversion.h>
+#include <linux/filelock.h>
#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 <linux/uio.h>
#include <linux/blkdev.h>
+#include <linux/filelock.h>
#include <linux/mpage.h>
#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 = {
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 <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/errno.h>
+#include <linux/filelock.h>
#include <linux/stat.h>
#include <linux/nls.h>
#include <linux/buffer_head.h>
@@ -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/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 <linux/string.h>
#include <linux/backing-dev.h>
#include <linux/falloc.h>
+#include <linux/filelock.h>
#include <linux/writeback.h>
#include <linux/compat.h>
#include <linux/slab.h>
@@ -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 <linux/bio.h>
#include <linux/blk-cgroup.h>
#include <linux/file.h>
+#include <linux/filelock.h>
#include <linux/fs.h>
#include <linux/fs_struct.h>
#include <linux/pagemap.h>
@@ -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,
};
/*
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/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 <linux/module.h>
#include <linux/fs.h>
#include <linux/file.h>
+#include <linux/filelock.h>
#include <linux/pagemap.h>
#include <linux/ramfs.h>
#include <linux/init.h>
@@ -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 <linux/buffer_head.h>
+#include <linux/filelock.h>
#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/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 <linux/filelock.h>
#include <linux/sched/mm.h>
#include <trace/events/erofs.h>
@@ -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 <linux/filelock.h>
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,
};
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 <linux/compat.h>
#include <linux/bio.h>
#include <linux/buffer_head.h>
+#include <linux/filelock.h>
#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 <linux/security.h>
#include <linux/msdos_fs.h>
#include <linux/writeback.h>
+#include <linux/filelock.h>
#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 = {
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 <linux/buffer_head.h>
+#include <linux/filelock.h>
#include <linux/pagemap.h>
#include <linux/swap.h>
#include <linux/iversion.h>
@@ -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 <linux/time.h>
#include <linux/pagemap.h>
#include <linux/dax.h>
+#include <linux/filelock.h>
#include <linux/quotaops.h>
#include <linux/iomap.h>
#include <linux/uio.h>
@@ -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 = {
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 <linux/fs.h>
#include <linux/buffer_head.h>
+#include <linux/filelock.h>
#include <linux/slab.h>
#include <linux/iversion.h>
#include <linux/unicode.h>
@@ -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 <linux/mount.h>
#include <linux/path.h>
#include <linux/dax.h>
+#include <linux/filelock.h>
#include <linux/quotaops.h>
#include <linux/pagevec.h>
#include <linux/uio.h>
@@ -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 = {
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 <linux/unaligned.h>
#include <linux/fs.h>
#include <linux/f2fs_fs.h>
+#include <linux/filelock.h>
#include <linux/sched/signal.h>
#include <linux/unicode.h>
#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 <linux/writeback.h>
#include <linux/blkdev.h>
#include <linux/falloc.h>
+#include <linux/filelock.h>
#include <linux/types.h>
#include <linux/compat.h>
#include <linux/uaccess.h>
@@ -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,
};
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 <linux/slab.h>
#include <linux/compat.h>
+#include <linux/filelock.h>
#include <linux/uaccess.h>
#include <linux/iversion.h>
#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 <linux/mount.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
+#include <linux/filelock.h>
#include <linux/fsnotify.h>
#include <linux/security.h>
#include <linux/falloc.h>
@@ -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)
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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/time.h>
#include <linux/mm.h>
#include <linux/highmem.h>
@@ -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/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 86376f0dbf3a..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,
};
@@ -1639,5 +1637,6 @@ const struct file_operations gfs2_dir_fops_nolock = {
.release = gfs2_release,
.fsync = gfs2_fsync,
.llseek = default_llseek,
+ .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 <linux/gfp.h>
+#include <linux/filelock.h>
#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/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 <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/crc32.h>
#include <linux/jffs2.h>
#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 <linux/kernel.h>
#include <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/time.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
@@ -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 */
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 <linux/mm.h>
#include <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/posix_acl.h>
#include <linux/quotaops.h>
#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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/namei.h>
#include <linux/ctype.h>
#include <linux/quotaops.h>
@@ -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)
diff --git a/fs/libfs.c b/fs/libfs.c
index 591eb649ebba..f1860dff86f2 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -6,6 +6,7 @@
#include <linux/blkdev.h>
#include <linux/export.h>
+#include <linux/filelock.h>
#include <linux/pagemap.h>
#include <linux/slab.h>
#include <linux/cred.h>
@@ -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)
@@ -1698,24 +1700,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
* @inode: the symlink inode
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);
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/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 <linux/pagemap.h>
+#include <linux/filelock.h>
#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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/mm.h>
#include <linux/writeback.h>
#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 = {
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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/nls.h>
#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 <linux/falloc.h>
#include <linux/fiemap.h>
#include <linux/fileattr.h>
+#include <linux/filelock.h>
#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
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 <linux/mount.h>
#include <linux/writeback.h>
#include <linux/falloc.h>
+#include <linux/filelock.h>
#include <linux/quotaops.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
@@ -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,
};
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 <linux/filelock.h>
#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,
};
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 <linux/cred.h>
#include <linux/file.h>
+#include <linux/filelock.h>
#include <linux/mount.h>
#include <linux/xattr.h>
#include <linux/uio.h>
@@ -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 <linux/slab.h>
#include <linux/namei.h>
#include <linux/file.h>
+#include <linux/filelock.h>
#include <linux/xattr.h>
#include <linux/rbtree.h>
#include <linux/security.h>
@@ -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)
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 <linux/buffer_head.h>
+#include <linux/filelock.h>
#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 <linux/filelock.h>
#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 <linux/compat.h>
#include <linux/mount.h>
#include <linux/fs.h>
+#include <linux/filelock.h>
#include "internal.h"
#include <linux/uaccess.h>
@@ -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);
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/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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/vfs.h>
#include <linux/slab.h>
@@ -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 <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/vfs.h>
#include <linux/kernel.h>
#include <linux/slab.h>
@@ -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,
};
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 <linux/string.h>
#include <linux/errno.h>
+#include <linux/filelock.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/bio.h>
@@ -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 <linux/string.h> /* memset */
#include <linux/capability.h>
#include <linux/errno.h>
+#include <linux/filelock.h>
#include <linux/pagemap.h>
#include <linux/uio.h>
@@ -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,
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 <linux/time.h>
#include <linux/fs.h>
+#include <linux/filelock.h>
#include <linux/swap.h>
#include <linux/iversion.h>
@@ -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 <linux/fs.h>
+#include <linux/filelock.h>
#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,
};
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/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 <linux/mman.h>
#include <linux/fadvise.h>
#include <linux/mount.h>
+#include <linux/filelock.h>
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,
};
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 *);
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 <linux/pagemap.h>
#include <linux/file.h>
#include <linux/fileattr.h>
+#include <linux/filelock.h>
#include <linux/mm.h>
#include <linux/random.h>
#include <linux/sched/signal.h>
@@ -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
};