From: Chuck Lever Date: Tue, 17 Feb 2026 22:07:13 +0000 (-0500) Subject: lockd: Hoist file_lock init out of nlm4svc_decode_shareargs() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb2a70b610810874838f176a0d157d5cd0226c18;p=thirdparty%2Flinux.git lockd: Hoist file_lock init out of nlm4svc_decode_shareargs() The xdrgen-generated XDR decoders cannot initialize the file_lock structure because it is an internal kernel type, not part of the wire protocol. To prepare for converting SHARE and UNSHARE procedures to use xdrgen, the file_lock initialization must be moved from nlm4svc_decode_shareargs() into the procedure handlers themselves. This change removes one more dependency on the "struct nlm_lock::fl" field in fs/lockd/xdr4.c, allowing the XDR decoder to focus solely on unmarshalling wire data. Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index b4ed77125f68..6dd9afc59551 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -1049,6 +1049,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp) { struct nlm_args *argp = rqstp->rq_argp; struct nlm_res *resp = rqstp->rq_resp; + struct nlm_lock *lock = &argp->lock; struct nlm_host *host; struct nlm_file *file; @@ -1063,7 +1064,10 @@ nlm4svc_proc_share(struct svc_rqst *rqstp) } /* Obtain client and file */ - if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) + locks_init_lock(&lock->fl); + lock->svid = ~(u32)0; + resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file); + if (resp->status) return resp->status == nlm__int__drop_reply ? rpc_drop_reply : rpc_success; @@ -1071,7 +1075,7 @@ nlm4svc_proc_share(struct svc_rqst *rqstp) resp->status = nlmsvc_share_file(host, file, argp); dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); - nlmsvc_release_lockowner(&argp->lock); + nlmsvc_release_lockowner(lock); nlmsvc_release_host(host); nlm_release_file(file); return rpc_success; @@ -1085,6 +1089,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp) { struct nlm_args *argp = rqstp->rq_argp; struct nlm_res *resp = rqstp->rq_resp; + struct nlm_lock *lock = &argp->lock; struct nlm_host *host; struct nlm_file *file; @@ -1099,7 +1104,10 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp) } /* Obtain client and file */ - if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) + locks_init_lock(&lock->fl); + lock->svid = ~(u32)0; + resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file); + if (resp->status) return resp->status == nlm__int__drop_reply ? rpc_drop_reply : rpc_success; @@ -1107,7 +1115,7 @@ nlm4svc_proc_unshare(struct svc_rqst *rqstp) resp->status = nlmsvc_unshare_file(host, file, argp); dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); - nlmsvc_release_lockowner(&argp->lock); + nlmsvc_release_lockowner(lock); nlmsvc_release_host(host); nlm_release_file(file); return rpc_success; diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c index dbbb2dfcb81b..308aac92a94e 100644 --- a/fs/lockd/xdr4.c +++ b/fs/lockd/xdr4.c @@ -257,9 +257,6 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) struct nlm_args *argp = rqstp->rq_argp; struct nlm_lock *lock = &argp->lock; - locks_init_lock(&lock->fl); - lock->svid = ~(u32)0; - if (!svcxdr_decode_cookie(xdr, &argp->cookie)) return false; if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))