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 <jlayton@kernel.org>
Link: https://patch.msgid.link/20260108-setlease-6-20-v1-1-ea4dec9b67fa@kernel.org
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Jeff Layton 2026-01-08 12:12:56 -05:00 committed by Christian Brauner
parent 7d42f2b1cc
commit ca4388bf1d
No known key found for this signature in database
GPG key ID: 91C61BC06578DCA2
8 changed files with 16 additions and 0 deletions

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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 = {

View file

@ -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,
};

View file

@ -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,
};
/*

View file

@ -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 =

View file

@ -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 = {

View file

@ -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);