From: Chuck Lever Date: Tue, 12 May 2026 18:14:13 +0000 (-0400) Subject: lockd: Unify cast_status X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b8d52328e0d37a51d1a4b11cf0f118a59dc4239;p=thirdparty%2Fkernel%2Flinux.git lockd: Unify cast_status cast_status folds internal lock-daemon sentinels into NLMv1/v3 wire status codes for the v3 reply path. Two variants have existed since the original kernel import: a strict allowlist under CONFIG_LOCKD_V4 and a sentinel-translation form for the !CONFIG_LOCKD_V4 build. The split was never grounded in a behavioural difference -- nlmsvc_testlock and nlmsvc_lock, which feed cast_status, return the same set of values in both configurations -- and recent xdrgen conversions have narrowed the caller set further: nlm__int__stale_fh and nlm__int__failed are now translated at their point of origin in nlm3svc_lookup_file, and the cast_status wraps around nlmsvc_cancel_blocked and nlmsvc_unlock have been dropped because those functions return only wire codes. Collapse the two variants into one. The unified form keeps the CONFIG_LOCKD_V4 arm's allowlist, retains the nlm__int__deadlock translation, and folds anything else to nlm_lck_denied_nolocks after a pr_warn_once so an unexpected sentinel from a future refactor remains visible in the kernel log instead of being silently passed to the wire encoder. Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index f62b0b39c5e98..4836887f11ef0 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -203,7 +203,6 @@ nlm3svc_lookup_file(struct svc_rqst *rqstp, struct nlm_host *host, return nlm_granted; } -#ifdef CONFIG_LOCKD_V4 static inline __be32 cast_status(__be32 status) { switch (status) { @@ -218,31 +217,13 @@ static inline __be32 cast_status(__be32 status) status = nlm_lck_denied; break; default: + pr_warn_once("lockd: unhandled internal status %u\n", + be32_to_cpu(status)); status = nlm_lck_denied_nolocks; - } - - return status; -} -#else -static inline __be32 cast_status(__be32 status) -{ - switch (status) { - case nlm__int__deadlock: - status = nlm_lck_denied; - break; - case nlm__int__stale_fh: - case nlm__int__failed: - status = nlm_lck_denied_nolocks; - break; - default: - if (be32_to_cpu(status) > be32_to_cpu(nlm__int__drop_reply)) - pr_warn_once("lockd: unhandled internal status %u\n", - be32_to_cpu(status)); break; } return status; } -#endif /** * nlmsvc_proc_null - NULL: Test for presence of service