Re: [PATCH v3] lockd: serialize server host->h_rpcclnt across rebind, async submit, and shutdown

From: Ziheng Wei

Date: Wed Dec 02 2026 - 22:31:27 EST


On Wed, Dec 02, 2026, Chuck Lever wrote:
> Nit: the kernel-doc comment above nlmsvc_lookup_host() still describes it
> as returning a matching host or creating a new one. Could that comment
> mention the NULL returns? Something like:
>
> * Returns NULL if lockd is shutting down in this network namespace,
> * or if a new nlm_host cannot be allocated.

Added in v4.

> After the split, the "Create the NLM RPC client" comment sits on
> nlm_bind_host_locked(), and the nlm_bind_host() wrapper has no comment at
> all. Neither one records that the caller holds h_mutex across a bind that
> can sleep in rpc_create(), or that a server host gets NULL once
> nlm_shutdown_hosts_net() has started on its net. Can both functions get a
> comment that covers the h_mutex requirement and the new NULL return?

Added kernel-doc comments on both nlm_bind_host_locked() and
nlm_bind_host() in v4 covering the h_mutex requirement, sleeping in
rpc_create(), and the NULL return once nlm_shutdown_hosts_net() has
started (or when rpc_create() fails).

> nlm_rebind_host() picks up a similar unstated rule. For a server host it
> now runs only under h_mutex, while the client-side callers still call it
> without the lock. Would a Context: line in its kernel-doc, or a
> lockdep_assert_held() conditioned on host->h_server, capture the rule?

Added both in v4: a Context: line in nlm_rebind_host()'s kernel-doc and
`if (host->h_server) lockdep_assert_held(&host->h_mutex);`.

> Is this rebind still needed? The callback label leads to
>
> nlm_async_call()
> -> __nlm_async_call()
> -> nlm_bind_host_locked()
>
> and nlm_bind_host_locked() calls nlm_rebind_host() under the same h_mutex
> whenever h_rpcclnt is set. h_nextrebind turns whichever call runs second
> into a no-op. Dropping the explicit call and its lock and unlock would
> leave nlm_bind_host_locked() as the one place a server host rebinds. The
> "possibly refreshing the RPC binding" comment could then point at the
> bind path instead.

Agreed. Since block->b_call->a_host is block->b_host, the callback path
always reaches nlm_bind_host_locked() under h_mutex and rebinds there
when h_rpcclnt is already set. v4 drops the explicit nlm_rebind_host()
call in nlmsvc_grant_blocked() and updates the comment to point to
nlm_bind_host_locked().

I'll post v4 shortly.

Thanks,
Ziheng