]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lockd: Unify cast_status
authorChuck Lever <chuck.lever@oracle.com>
Tue, 12 May 2026 18:14:13 +0000 (14:14 -0400)
committerChuck Lever <cel@kernel.org>
Tue, 9 Jun 2026 20:32:59 +0000 (16:32 -0400)
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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svcproc.c

index f62b0b39c5e98e6c017dcbadc10587c139703d59..4836887f11ef003a9c5ac0eba38bf552802d4dcf 100644 (file)
@@ -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