]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: add setlease file operation
authorJeff Layton <jlayton@kernel.org>
Thu, 8 Jan 2026 17:12:58 +0000 (12:12 -0500)
committerChristian Brauner <brauner@kernel.org>
Mon, 12 Jan 2026 09:55:45 +0000 (10:55 +0100)
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 <jlayton@kernel.org>
Link: https://patch.msgid.link/20260108-setlease-6-20-v1-3-ea4dec9b67fa@kernel.org
Acked-by: David Sterba <dsterba@suse.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/btrfs/file.c
fs/btrfs/inode.c

index 1abc7ed2990e0e956dc0550cba8b0cfc90109e65..aca2b541e72df3638bdc6cd7551a018ae959039b 100644 (file)
@@ -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)
index d2b302ac6af96af95c646e0f6714f4cd1903834e..d377794b4c9fac49488e1d70c084aba46d1a5fa1 100644 (file)
@@ -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,
 };
 
 /*