- From d88c616aa24581241ffb6af0ab32c8e361a099a9 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 28 Aug 2025 13:45:38 +0200
- Subject: [PATCH] sys: Prevent endless retry loop in
- |nfs41_UpcallWaitForReply()| in case of many APCs or thread termination
- Prevent endless retry loop in |nfs41_UpcallWaitForReply()| in case of many
- APCs or thread termination.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_updowncall.c | 30 ++++++++++++++++++++++--------
- 1 file changed, 22 insertions(+), 8 deletions(-)
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index cf9e4cf..badb38c 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -524,8 +524,14 @@ NTSTATUS nfs41_UpcallWaitForReply(
- if (entry->async_op)
- goto out;
- + const ULONG tickIncrement = KeQueryTimeIncrement();
- +
- + LARGE_INTEGER startTicks, currTicks;
- + KeQueryTickCount(&startTicks);
- +
- LARGE_INTEGER timeout;
- timeout.QuadPart = RELATIVE(SECONDS(secs));
- +
- retry_wait:
- status = KeWaitForSingleObject(&entry->cond, Executive,
- UserMode, FALSE, &timeout);
- @@ -542,14 +548,22 @@ retry_wait:
- break;
- case STATUS_USER_APC:
- case STATUS_ALERTED:
- - DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
- - "returned status(=0x%lx), "
- - "retry waiting for '%s' entry=0x%p xid=%lld\n",
- - (long)status,
- - ENTRY_OPCODE2STRING(entry),
- - entry,
- - (entry?entry->xid:-1LL));
- - if (entry) {
- + /*
- + * Check for timeout here, because |KeWaitForSingleObject()| does not
- + * decrement the timout value.
- + * This prevents endless retry loops in case of APC storms or
- + * that the calling thread is in the process of being terminated.
- + */
- + KeQueryTickCount(&currTicks);
- + if (((currTicks.QuadPart - startTicks.QuadPart) * tickIncrement) <=
- + SECONDS(secs)) {
- + DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
- + "returned status(=0x%lx), "
- + "retry waiting for '%s' entry=0x%p xid=%lld\n",
- + (long)status,
- + ENTRY_OPCODE2STRING(entry),
- + entry,
- + entry->xid);
- goto retry_wait;
- }
- /* fall-through */
- --
- 2.45.1
msnfs41client: Fix endless retry loop waiting for an upcall, 2025-08-28
Posted by Anonymous on Fri 29th Aug 2025 11:58
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.