From 94415b06eb8aed13481646026dc995f04a3a534a Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 7 Jul 2020 09:28:05 -0400 Subject: nfsd4: a client's own opens needn't prevent delegations We recently fixed lease breaking so that a client's actions won't break its own delegations. But we still have an unnecessary self-conflict when granting delegations: a client's own write opens will prevent us from handing out a read delegation even when no other client has the file open for write. Fix that by turning off the checks for conflicting opens under vfs_setlease, and instead performing those checks in the nfsd code. We don't depend much on locks here: instead we acquire the delegation, then check for conflicts, and drop the delegation again if we find any. The check beforehand is an optimization of sorts, just to avoid acquiring the delegation unnecessarily. There's a race where the first check could cause us to deny the delegation when we could have granted it. But, that's OK, delegation grants are optional (and probably not even a good idea in that case). Signed-off-by: J. Bruce Fields Signed-off-by: Chuck Lever --- fs/locks.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/locks.c') diff --git a/fs/locks.c b/fs/locks.c index 7df0f9fa66f4..d5de9039dbd7 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1807,6 +1807,9 @@ check_conflicting_open(struct file *filp, const long arg, int flags) if (flags & FL_LAYOUT) return 0; + if (flags & FL_DELEG) + /* We leave these checks to the caller. */ + return 0; if (arg == F_RDLCK) return inode_is_open_for_write(inode) ? -EAGAIN : 0; -- cgit v1.2.3-70-g09d2