Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: wake blocked file lock waiters before sending callback

When a blocked NFS lock is "awoken" we send a callback to the server and
then wake any hosts waiting on it. If a client attempts to get a lock
and then drops off the net, we could end up waiting for a long time
until we end up waking locks blocked on that request.

So, wake any other waiting lock requests before sending the callback.
Do this by calling locks_delete_block in a new "prepare" phase for
CB_NOTIFY_LOCK callbacks.

URL: https://bugzilla.kernel.org/show_bug.cgi?id=203363
Fixes: 16306a61d3b7 ("fs/locks: always delete_block after waiting.")
Reported-by: Slawomir Pryczek <slawek1211@gmail.com>
Cc: Neil Brown <neilb@suse.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Jeff Layton and committed by
J. Bruce Fields
f456458e 6aaafc43

+9
+9
fs/nfsd/nfs4state.c
··· 298 298 } 299 299 } 300 300 301 + static void 302 + nfsd4_cb_notify_lock_prepare(struct nfsd4_callback *cb) 303 + { 304 + struct nfsd4_blocked_lock *nbl = container_of(cb, 305 + struct nfsd4_blocked_lock, nbl_cb); 306 + locks_delete_block(&nbl->nbl_lock); 307 + } 308 + 301 309 static int 302 310 nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task) 303 311 { ··· 333 325 } 334 326 335 327 static const struct nfsd4_callback_ops nfsd4_cb_notify_lock_ops = { 328 + .prepare = nfsd4_cb_notify_lock_prepare, 336 329 .done = nfsd4_cb_notify_lock_done, 337 330 .release = nfsd4_cb_notify_lock_release, 338 331 };