diff mbox series

[RFC,09/24] filelock: lift the ban on directory leases in generic_setlease

Message ID 20240315-dir-deleg-v1-9-a1d6209a3654@kernel.org
State New
Headers show
Series vfs, nfsd, nfs: implement directory delegations | expand

Commit Message

Jeff Layton March 15, 2024, 4:53 p.m. UTC
With the addition of the try_break_lease calls in directory changing
operations, allow generic_setlease to hand them out.

Note that this also makes directory leases available to userland via
fcntl(). I don't see a real reason to prevent userland from acquiring
one, but we could reinstate the prohibition if that's preferable.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/locks.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/locks.c b/fs/locks.c
index 415cca8e9565..ba6b6f9ea4c7 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1930,7 +1930,9 @@  static int generic_delete_lease(struct file *filp, void *owner)
 int generic_setlease(struct file *filp, int arg, struct file_lease **flp,
 			void **priv)
 {
-	if (!S_ISREG(file_inode(filp)->i_mode))
+	struct inode *inode = file_inode(filp);
+
+	if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
 		return -EINVAL;
 
 	switch (arg) {