Skip to content

NFSv4: fix blocking lock stalls under a delegation

Olga Kornievskaia linux-nfs 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2NFSv4: wake blocking lock waiters when a delegated lock is releasedfs/nfs/nfs4proc.c+16 -30 replies
2/2NFSv4: remember that the server may send CB_NOTIFY_LOCKfs/nfs/nfs4proc.c include/linux/nfs_fs_sb.h+3 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] NFSv4: fix blocking lock stalls under a delegation

A test on a single client runs two processes that repeatedly acquire and release a POSIX lock on the same file on an NFSv4.1 mount, so that they compete for it, and measures how long each acquisition takes. When the open is granted a delegation, some acquisitions take unexpectedly long - almost exactly 1, 3 or 7 seconds - although the holder releases the lock within microseconds.

Over 20s and 2.4M acquisitions the slowest five were 3119404us, 3119248us, 1040679us, 1040288us and 1040212us. When the server grants no delegation, nothing exceeds 12ms.

The delegation case breaks the notification of waiters on the unlock path, in two independent places:

- NFS_STATE_MAY_NOTIFY_LOCK can only be learned from an OPEN reply, and an open satisfied from a delegation produces none. The waiter is therefore not on clp->cl_lock_waitq at all, and polls instead with a doubling 1s/2s/4s backoff - which is where the 1, 3 and 7 second acquisitions come from.

- Nothing wakes cl_lock_waitq when such a lock is released, since the server never saw it and cannot send a CB_NOTIFY_LOCK. A waiter that does reach that queue sleeps out the full 30s NFS4_LOCK_MAXTIMEOUT.

Both need fixing: one puts the waiter somewhere reachable, the other reaches it. They are ordered so that no halfway point regresses - the wake comes first, since adding it alone is harmless, whereas routing waiters onto the queue first would turn the 1-7s stalls into 30s ones.

With both applied the same test shows no acquisition over 2476us, total throughput up 23%, and the two processes splitting the work evenly (1464283/1464448, against 1029148/1355029 before).

Olga Kornievskaia (2):
NFSv4: wake blocking lock waiters when a delegated lock is released
NFSv4: remember that the server may send CB_NOTIFY_LOCK

 fs/nfs/nfs4proc.c         | 21 ++++++++++++++++++---
 include/linux/nfs_fs_sb.h |  1 +
 2 files changed, 19 insertions(+), 3 deletions(-)
Signature · 1 line
2.52.0