]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lockd: Hoist file_lock init out of nlm4svc_decode_shareargs()
authorChuck Lever <chuck.lever@oracle.com>
Tue, 17 Feb 2026 22:07:13 +0000 (17:07 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Mar 2026 01:25:09 +0000 (21:25 -0400)
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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svc4proc.c
fs/lockd/xdr4.c

index b4ed77125f68aac24b55eda4040b3d6552a154eb..6dd9afc595518d0c3e601476fd82302dab108b01 100644 (file)
@@ -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;
index dbbb2dfcb81bc58f6d4c80e5ba61543c285050e8..308aac92a94e8996fb659c2a8dfcef64a4dadcb7 100644 (file)
@@ -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))