Skip to content

Commit aa2a0fc

Browse files
committed
Merge tag 'vfs-7.0-rc1.leases' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs lease updates from Christian Brauner: "This contains updates for lease support to require filesystems to explicitly opt-in to lease support Currently kernel_setlease() falls through to generic_setlease() when a a filesystem does not define ->setlease(), silently granting lease support to every filesystem regardless of whether it is prepared for it. This is a poor default: most filesystems never intended to support leases, and the silent fallthrough makes it impossible to distinguish "supports leases" from "never thought about it". This inverts the default. It adds explicit .setlease = generic_setlease; assignments to every in-tree filesystem that should retain lease support, then changes kernel_setlease() to return -EINVAL when ->setlease is NULL. With the new default in place, simple_nosetlease() is redundant and is removed along with all references to it" * tag 'vfs-7.0-rc1.leases' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (25 commits) fuse: add setlease file operation fs: remove simple_nosetlease() filelock: default to returning -EINVAL when ->setlease operation is NULL xfs: add setlease file operation ufs: add setlease file operation udf: add setlease file operation tmpfs: add setlease file operation squashfs: add setlease file operation overlayfs: add setlease file operation orangefs: add setlease file operation ocfs2: add setlease file operation ntfs3: add setlease file operation nilfs2: add setlease file operation jfs: add setlease file operation jffs2: add setlease file operation gfs2: add a setlease file operation fat: add setlease file operation f2fs: add setlease file operation exfat: add setlease file operation ext4: add setlease file operation ...
2 parents 7455425 + 056a96e commit aa2a0fc

62 files changed

Lines changed: 117 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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
@@ -1187,9 +1187,12 @@ otherwise noted.
11871187
method is used by the splice(2) system call
11881188

11891189
``setlease``
1190-
called by the VFS to set or release a file lock lease. setlease
1191-
implementations should call generic_setlease to record or remove
1192-
the lease in the inode after setting it.
1190+
called by the VFS to set or release a file lock lease. Local
1191+
filesystems that wish to use the kernel-internal lease implementation
1192+
should set this to generic_setlease(). Other setlease implementations
1193+
should call generic_setlease() to record or remove the lease in the inode
1194+
after setting it. When set to NULL, attempts to set or remove a lease will
1195+
return -EINVAL.
11931196

11941197
``fallocate``
11951198
called by the VFS to preallocate blocks or punch a hole.

fs/9p/vfs_dir.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ const struct file_operations v9fs_dir_operations = {
242242
.iterate_shared = v9fs_dir_readdir,
243243
.open = v9fs_file_open,
244244
.release = v9fs_dir_release,
245-
.setlease = simple_nosetlease,
246245
};
247246

248247
const struct file_operations v9fs_dir_operations_dotl = {
@@ -252,5 +251,4 @@ const struct file_operations v9fs_dir_operations_dotl = {
252251
.open = v9fs_file_open,
253252
.release = v9fs_dir_release,
254253
.fsync = v9fs_file_fsync_dotl,
255-
.setlease = simple_nosetlease,
256254
};

fs/9p/vfs_file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ const struct file_operations v9fs_file_operations = {
517517
.splice_read = v9fs_file_splice_read,
518518
.splice_write = iter_file_splice_write,
519519
.fsync = v9fs_file_fsync,
520-
.setlease = simple_nosetlease,
521520
};
522521

523522
const struct file_operations v9fs_file_operations_dotl = {
@@ -532,5 +531,4 @@ const struct file_operations v9fs_file_operations_dotl = {
532531
.splice_read = v9fs_file_splice_read,
533532
.splice_write = iter_file_splice_write,
534533
.fsync = v9fs_file_fsync_dotl,
535-
.setlease = simple_nosetlease,
536534
};

fs/affs/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include <linux/iversion.h>
18+
#include <linux/filelock.h>
1819
#include "affs.h"
1920

2021
struct affs_dir_data {
@@ -55,6 +56,7 @@ const struct file_operations affs_dir_operations = {
5556
.iterate_shared = affs_readdir,
5657
.fsync = affs_file_fsync,
5758
.release = affs_dir_release,
59+
.setlease = generic_setlease,
5860
};
5961

6062
/*

fs/affs/file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <linux/uio.h>
1717
#include <linux/blkdev.h>
18+
#include <linux/filelock.h>
1819
#include <linux/mpage.h>
1920
#include "affs.h"
2021

@@ -1008,6 +1009,7 @@ const struct file_operations affs_file_operations = {
10081009
.release = affs_file_release,
10091010
.fsync = affs_file_fsync,
10101011
.splice_read = filemap_splice_read,
1012+
.setlease = generic_setlease,
10111013
};
10121014

10131015
const struct inode_operations affs_file_inode_operations = {

fs/befs/linuxvfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/fs_context.h>
1515
#include <linux/fs_parser.h>
1616
#include <linux/errno.h>
17+
#include <linux/filelock.h>
1718
#include <linux/stat.h>
1819
#include <linux/nls.h>
1920
#include <linux/buffer_head.h>
@@ -79,6 +80,7 @@ static const struct file_operations befs_dir_operations = {
7980
.read = generic_read_dir,
8081
.iterate_shared = befs_readdir,
8182
.llseek = generic_file_llseek,
83+
.setlease = generic_setlease,
8284
};
8385

8486
static const struct inode_operations befs_dir_inode_operations = {

fs/btrfs/file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/string.h>
1111
#include <linux/backing-dev.h>
1212
#include <linux/falloc.h>
13+
#include <linux/filelock.h>
1314
#include <linux/writeback.h>
1415
#include <linux/compat.h>
1516
#include <linux/slab.h>
@@ -3867,6 +3868,7 @@ const struct file_operations btrfs_file_operations = {
38673868
.remap_file_range = btrfs_remap_file_range,
38683869
.uring_cmd = btrfs_uring_cmd,
38693870
.fop_flags = FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC,
3871+
.setlease = generic_setlease,
38703872
};
38713873

38723874
int btrfs_fdatawrite_range(struct btrfs_inode *inode, loff_t start, loff_t end)

fs/btrfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/bio.h>
99
#include <linux/blk-cgroup.h>
1010
#include <linux/file.h>
11+
#include <linux/filelock.h>
1112
#include <linux/fs.h>
1213
#include <linux/fs_struct.h>
1314
#include <linux/pagemap.h>
@@ -10610,6 +10611,7 @@ static const struct file_operations btrfs_dir_file_operations = {
1061010611
#endif
1061110612
.release = btrfs_release_file,
1061210613
.fsync = btrfs_sync_file,
10614+
.setlease = generic_setlease,
1061310615
};
1061410616

1061510617
/*

fs/ceph/dir.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,15 +2214,13 @@ const struct file_operations ceph_dir_fops = {
22142214
.fsync = ceph_fsync,
22152215
.lock = ceph_lock,
22162216
.flock = ceph_flock,
2217-
.setlease = simple_nosetlease,
22182217
};
22192218

22202219
const struct file_operations ceph_snapdir_fops = {
22212220
.iterate_shared = shared_ceph_readdir,
22222221
.llseek = ceph_dir_llseek,
22232222
.open = ceph_open,
22242223
.release = ceph_release,
2225-
.setlease = simple_nosetlease,
22262224
};
22272225

22282226
const struct inode_operations ceph_dir_iops = {

0 commit comments

Comments
 (0)