diff options
| author | Chuck Lever <chuck.lever@oracle.com> | 2026-05-12 14:13:59 -0400 |
|---|---|---|
| committer | Chuck Lever <cel@kernel.org> | 2026-06-09 16:32:59 -0400 |
| commit | 6c534ad999b6696bca55ded82bb7645fe6c5979e (patch) | |
| tree | f6437894dfed08060e1a0e5dcf1c112d7c9fee99 /fs/lockd | |
| parent | 6a2f89e49b4fb69aa6e04ed1c7cb202f0c38406e (diff) | |
| download | linux-next-6c534ad999b6696bca55ded82bb7645fe6c5979e.tar.gz linux-next-6c534ad999b6696bca55ded82bb7645fe6c5979e.zip | |
lockd: Use xdrgen XDR functions for the NLMv3 GRANTED_MSG procedure
Continue the xdrgen migration by converting NLMv3 GRANTED_MSG,
the async counterpart to GRANTED that a remote NLM uses to tell
this lockd that a previously blocked client lock request has
become available. The procedure now uses
nlm_svc_decode_nlm_testargs and nlm_svc_encode_void, generated
from the NLM version 3 protocol specification. The procedure
handler reaches the xdrgen types through the
nlm_testargs_wrapper structure, which bridges between generated
code and the legacy lockd_lock representation.
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 not
needed. The lock member of the wrapper is populated explicitly
in __nlmsvc_proc_granted_msg() by nlm_lock_to_lockd_lock()
rather than relying on zero-initialization.
The NLM async callback mechanism uses client-side functions
which continue to take legacy results like struct lockd_res,
preventing GRANTED and GRANTED_MSG from sharing code for now.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/lockd')
| -rw-r--r-- | fs/lockd/svcproc.c | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index d059accfdebd..21a363450d59 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -594,23 +594,6 @@ out: rpc_drop_reply : rpc_success; } -/* - * GRANTED: A server calls us to tell that a process' lock request - * was granted - */ -static __be32 -__nlmsvc_proc_granted(struct svc_rqst *rqstp, struct lockd_res *resp) -{ - struct lockd_args *argp = rqstp->rq_argp; - - resp->cookie = argp->cookie; - - dprintk("lockd: GRANTED called\n"); - resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock); - dprintk("lockd: GRANTED status %d\n", ntohl(resp->status)); - return rpc_success; -} - /** * nlmsvc_proc_granted - GRANTED: Blocked lock has been granted * @rqstp: RPC transaction context @@ -966,19 +949,52 @@ static __be32 nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp) __nlmsvc_proc_unlock_msg); } +static __be32 +__nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct lockd_res *resp) +{ + struct nlm_testargs_wrapper *argp = rqstp->rq_argp; + + resp->status = nlm_lck_denied; + if (nlm_netobj_to_cookie(&resp->cookie, &argp->xdrgen.cookie)) + goto out; + + if (nlm_lock_to_lockd_lock(&argp->lock, &argp->xdrgen.alock)) + goto out; + + resp->status = nlmclnt_grant(svc_addr(rqstp), &argp->lock); + +out: + return rpc_success; +} + +/** + * nlmsvc_proc_granted_msg - GRANTED_MSG: Blocked lock has been granted + * @rqstp: RPC transaction context + * + * Returns: + * %rpc_success: RPC executed successfully. + * %rpc_garbage_args: The request arguments are malformed. + * %rpc_system_err: RPC execution failed. + * + * RPC synopsis: + * void NLMPROC_GRANTED_MSG(nlm_testargs) = 10; + * + * The response to this request is delivered via the GRANTED_RES procedure. + */ static __be32 nlmsvc_proc_granted_msg(struct svc_rqst *rqstp) { - struct lockd_args *argp = rqstp->rq_argp; - struct nlm_host *host; + struct nlm_testargs_wrapper *argp = rqstp->rq_argp; + struct nlm_host *host; - dprintk("lockd: GRANTED_MSG called\n"); + if (argp->xdrgen.cookie.len > NLM_MAXCOOKIELEN) + return rpc_garbage_args; - host = nlmsvc_lookup_host(rqstp, argp->lock.caller, argp->lock.len); + host = nlm3svc_lookup_host(rqstp, argp->xdrgen.alock.caller_name, false); if (!host) return rpc_system_err; return nlmsvc_callback(rqstp, host, NLMPROC_GRANTED_RES, - __nlmsvc_proc_granted); + __nlmsvc_proc_granted_msg); } /* @@ -1244,15 +1260,15 @@ static const struct svc_procedure nlmsvc_procedures[24] = { .pc_xdrressize = XDR_void, .pc_name = "UNLOCK_MSG", }, - [NLMPROC_GRANTED_MSG] = { - .pc_func = nlmsvc_proc_granted_msg, - .pc_decode = nlmsvc_decode_testargs, - .pc_encode = nlmsvc_encode_void, - .pc_argsize = sizeof(struct lockd_args), - .pc_argzero = sizeof(struct lockd_args), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "GRANTED_MSG", + [NLM_GRANTED_MSG] = { + .pc_func = nlmsvc_proc_granted_msg, + .pc_decode = nlm_svc_decode_nlm_testargs, + .pc_encode = nlm_svc_encode_void, + .pc_argsize = sizeof(struct nlm_testargs_wrapper), + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "GRANTED_MSG", }, [NLMPROC_TEST_RES] = { .pc_func = nlmsvc_proc_null, |
