Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+12 -7
+12 -4
fs/lockd/svc4proc.c
··· 1049 1049 { 1050 1050 struct nlm_args *argp = rqstp->rq_argp; 1051 1051 struct nlm_res *resp = rqstp->rq_resp; 1052 + struct nlm_lock *lock = &argp->lock; 1052 1053 struct nlm_host *host; 1053 1054 struct nlm_file *file; 1054 1055 ··· 1064 1063 } 1065 1064 1066 1065 /* Obtain client and file */ 1067 - if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 1066 + locks_init_lock(&lock->fl); 1067 + lock->svid = ~(u32)0; 1068 + resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file); 1069 + if (resp->status) 1068 1070 return resp->status == nlm__int__drop_reply ? 1069 1071 rpc_drop_reply : rpc_success; 1070 1072 ··· 1075 1071 resp->status = nlmsvc_share_file(host, file, argp); 1076 1072 1077 1073 dprintk("lockd: SHARE status %d\n", ntohl(resp->status)); 1078 - nlmsvc_release_lockowner(&argp->lock); 1074 + nlmsvc_release_lockowner(lock); 1079 1075 nlmsvc_release_host(host); 1080 1076 nlm_release_file(file); 1081 1077 return rpc_success; ··· 1089 1085 { 1090 1086 struct nlm_args *argp = rqstp->rq_argp; 1091 1087 struct nlm_res *resp = rqstp->rq_resp; 1088 + struct nlm_lock *lock = &argp->lock; 1092 1089 struct nlm_host *host; 1093 1090 struct nlm_file *file; 1094 1091 ··· 1104 1099 } 1105 1100 1106 1101 /* Obtain client and file */ 1107 - if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) 1102 + locks_init_lock(&lock->fl); 1103 + lock->svid = ~(u32)0; 1104 + resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file); 1105 + if (resp->status) 1108 1106 return resp->status == nlm__int__drop_reply ? 1109 1107 rpc_drop_reply : rpc_success; 1110 1108 ··· 1115 1107 resp->status = nlmsvc_unshare_file(host, file, argp); 1116 1108 1117 1109 dprintk("lockd: UNSHARE status %d\n", ntohl(resp->status)); 1118 - nlmsvc_release_lockowner(&argp->lock); 1110 + nlmsvc_release_lockowner(lock); 1119 1111 nlmsvc_release_host(host); 1120 1112 nlm_release_file(file); 1121 1113 return rpc_success;
-3
fs/lockd/xdr4.c
··· 257 257 struct nlm_args *argp = rqstp->rq_argp; 258 258 struct nlm_lock *lock = &argp->lock; 259 259 260 - locks_init_lock(&lock->fl); 261 - lock->svid = ~(u32)0; 262 - 263 260 if (!svcxdr_decode_cookie(xdr, &argp->cookie)) 264 261 return false; 265 262 if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len))