Skip to contentSkip to conversation

nfsd: wake waiters blocked on file_lock before deleting it

PATCH Superseded Jeff Layton 1 participant 2 messages Apr 20, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH 1/1 nfsd: wake waiters blocked on file_lock before deleting it

After a blocked nfsd file_lock request is deleted, knfsd will send a callback to the client and then free the request. Commit 16306a61d3b7 ("fs/locks: always delete_block after waiting.") changed it such that locks_delete_block is always called on a request after it is awoken, but that patch missed fixing up blocked nfsd request handling.

Call locks_delete_block on the block to wake up any locks still blocked on the nfsd lock request before sending the callback.

URL: https://bugzilla.kernel.org/show_bug.cgi?id=203363

Fixes 16306a61d3b7 ("fs/locks: always delete_block after waiting.")
Cc Neil Brown <[email protected]>
---
 fs/nfsd/nfs4state.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/nfsd/nfs4state.c +9 -0
index 6a45fb00c5fc..1960e8fd9ad1 100644
@@ -298,6 +298,14 @@ remove_blocked_locks(struct nfs4_lockowner *lo)
 	}
 }
 
+static void
+nfsd4_cb_notify_lock_prepare(struct nfsd4_callback *cb)
+{
+	struct nfsd4_blocked_lock	*nbl = container_of(cb,
+						struct nfsd4_blocked_lock, nbl_cb);
+	locks_delete_block(&nbl->nbl_lock);
+}
+
 static int
 nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task)
 {
@@ -325,6 +333,7 @@ nfsd4_cb_notify_lock_release(struct nfsd4_callback *cb)
 }
 
 static const struct nfsd4_callback_ops nfsd4_cb_notify_lock_ops = {
+	.prepare	= nfsd4_cb_notify_lock_prepare,
 	.done		= nfsd4_cb_notify_lock_done,
 	.release	= nfsd4_cb_notify_lock_release,
 };
Signature · 1 line
2.20.1
author maintainer
#1 lore raw
Quoted 47 lines · Jeff Layton

After a blocked nfsd file_lock request is deleted, knfsd will send a callback to the client and then free the request. Commit 16306a61d3b7 ("fs/locks: always delete_block after waiting.") changed it such that locks_delete_block is always called on a request after it is awoken, but that patch missed fixing up blocked nfsd request handling.

Call locks_delete_block on the block to wake up any locks still blocked on the nfsd lock request before sending the callback.

URL: https://bugzilla.kernel.org/show_bug.cgi?id=203363

Fixes 16306a61d3b7 ("fs/locks: always delete_block after waiting.")
Cc Neil Brown <[email protected]>
---
 fs/nfsd/nfs4state.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/nfsd/nfs4state.c +9 -1
index 6a45fb00c5fc..1960e8fd9ad1 100644
@@ -298,6 +298,14 @@ remove_blocked_locks(struct nfs4_lockowner *lo)
        }
 }
 
+static void
+nfsd4_cb_notify_lock_prepare(struct nfsd4_callback *cb)
+{
+       struct nfsd4_blocked_lock       *nbl = container_of(cb,
+                                               struct nfsd4_blocked_lock, nbl_cb);
+       locks_delete_block(&nbl->nbl_lock);
+}
+
 static int
 nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task)
 {
@@ -325,6 +333,7 @@ nfsd4_cb_notify_lock_release(struct nfsd4_callback *cb)
 }
 
 static const struct nfsd4_callback_ops nfsd4_cb_notify_lock_ops = {
+       .prepare        = nfsd4_cb_notify_lock_prepare,
        .done           = nfsd4_cb_notify_lock_done,
        .release        = nfsd4_cb_notify_lock_release,
 };
--
Quoted 2 lines

2.20.1

This should also go to stable I think. If you end up picking this up, can you add the Cc: for stable as well?

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>