]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lockd: Use xdrgen XDR functions for the NLMv3 GRANTED_RES procedure
authorChuck Lever <chuck.lever@oracle.com>
Tue, 12 May 2026 18:14:04 +0000 (14:14 -0400)
committerChuck Lever <cel@kernel.org>
Tue, 9 Jun 2026 20:32:59 +0000 (16:32 -0400)
Continue the xdrgen migration by converting NLMv3 GRANTED_RES,
the callback that a remote NLM uses to return async GRANTED
results to this lockd.  The procedure now uses
nlm_svc_decode_nlm_res and nlm_svc_encode_void, generated
from the NLM version 3 protocol specification.

Setting pc_argzero to zero is safe because the generated
decoder fills the argp->xdrgen subfields before the procedure
runs, so the zeroing memset performed by the dispatch layer
is no longer needed.

Setting pc_xdrressize to XDR_void reflects that GRANTED_RES, as
a callback, returns no data; the previous value of St
over-reserved a status word in the reply buffer.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svcproc.c

index f17d3f8d85ecfd054176c9aeef04b5fcdb21d57f..a2ac747e96ce978924bd270767cc9a0f78675b64 100644 (file)
@@ -61,6 +61,7 @@ static_assert(offsetof(struct nlm_lockargs_wrapper, xdrgen) == 0);
 
 struct nlm_res_wrapper {
        struct nlm_res                  xdrgen;
+       struct lockd_cookie             cookie;
 };
 
 static_assert(offsetof(struct nlm_res_wrapper, xdrgen) == 0);
@@ -997,6 +998,30 @@ static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp)
                               __nlmsvc_proc_granted_msg);
 }
 
+/**
+ * nlmsvc_proc_granted_res - GRANTED_RES: Lock Granted result
+ * @rqstp: RPC transaction context
+ *
+ * Returns:
+ *   %rpc_success:             RPC executed successfully.
+ *
+ * RPC synopsis:
+ *   void NLMPROC_GRANTED_RES(nlm_res) = 15;
+ */
+static __be32 nlmsvc_proc_granted_res(struct svc_rqst *rqstp)
+{
+       struct nlm_res_wrapper *argp = rqstp->rq_argp;
+
+       if (!nlmsvc_ops)
+               return rpc_success;
+
+       if (nlm_netobj_to_cookie(&argp->cookie, &argp->xdrgen.cookie))
+               return rpc_success;
+       nlmsvc_grant_reply(&argp->cookie, argp->xdrgen.stat.stat);
+
+       return rpc_success;
+}
+
 /*
  * SHARE: create a DOS share or alter existing share.
  */
@@ -1125,23 +1150,6 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp)
        return rpc_success;
 }
 
-/*
- * client sent a GRANTED_RES, let's remove the associated block
- */
-static __be32
-nlmsvc_proc_granted_res(struct svc_rqst *rqstp)
-{
-       struct lockd_res *argp = rqstp->rq_argp;
-
-       if (!nlmsvc_ops)
-               return rpc_success;
-
-       dprintk("lockd: GRANTED_RES   called\n");
-
-       nlmsvc_grant_reply(&argp->cookie, argp->status);
-       return rpc_success;
-}
-
 static __be32
 nlmsvc_proc_unused(struct svc_rqst *rqstp)
 {
@@ -1310,15 +1318,15 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
                .pc_xdrressize  = XDR_void,
                .pc_name        = "UNLOCK_RES",
        },
-       [NLMPROC_GRANTED_RES] = {
-               .pc_func = nlmsvc_proc_granted_res,
-               .pc_decode = nlmsvc_decode_res,
-               .pc_encode = nlmsvc_encode_void,
-               .pc_argsize = sizeof(struct lockd_res),
-               .pc_argzero = sizeof(struct lockd_res),
-               .pc_ressize = sizeof(struct nlm_void),
-               .pc_xdrressize = St,
-               .pc_name = "GRANTED_RES",
+       [NLM_GRANTED_RES] = {
+               .pc_func        = nlmsvc_proc_granted_res,
+               .pc_decode      = nlm_svc_decode_nlm_res,
+               .pc_encode      = nlm_svc_encode_void,
+               .pc_argsize     = sizeof(struct nlm_res_wrapper),
+               .pc_argzero     = 0,
+               .pc_ressize     = 0,
+               .pc_xdrressize  = XDR_void,
+               .pc_name        = "GRANTED_RES",
        },
        [NLMPROC_NSM_NOTIFY] = {
                .pc_func = nlmsvc_proc_sm_notify,