Commit bb2a70b6 authored by Chuck Lever's avatar Chuck Lever
Browse files

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: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 5eae0e00
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -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;
+0 −3
Original line number Diff line number Diff line
@@ -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))