Skip to content

Commit d76d8c2

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
lockd: Update the NLMv4 UNLOCK arguments decoder to use struct xdr_stream
Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 1e1f38d commit d76d8c2

File tree

1 file changed

+13
-40
lines changed

1 file changed

+13
-40
lines changed

fs/lockd/xdr4.c

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -131,36 +131,6 @@ nlm4_decode_oh(__be32 *p, struct xdr_netobj *oh)
131131
return xdr_decode_netobj(p, oh);
132132
}
133133

134-
static __be32 *
135-
nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
136-
{
137-
struct file_lock *fl = &lock->fl;
138-
__u64 len, start;
139-
__s64 end;
140-
141-
if (!(p = xdr_decode_string_inplace(p, &lock->caller,
142-
&lock->len, NLM_MAXSTRLEN))
143-
|| !(p = nlm4_decode_fh(p, &lock->fh))
144-
|| !(p = nlm4_decode_oh(p, &lock->oh)))
145-
return NULL;
146-
lock->svid = ntohl(*p++);
147-
148-
locks_init_lock(fl);
149-
fl->fl_flags = FL_POSIX;
150-
fl->fl_type = F_RDLCK; /* as good as anything else */
151-
p = xdr_decode_hyper(p, &start);
152-
p = xdr_decode_hyper(p, &len);
153-
end = start + len - 1;
154-
155-
fl->fl_start = s64_to_loff_t(start);
156-
157-
if (len == 0 || end < 0)
158-
fl->fl_end = OFFSET_MAX;
159-
else
160-
fl->fl_end = s64_to_loff_t(end);
161-
return p;
162-
}
163-
164134
static bool
165135
svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)
166136
{
@@ -311,25 +281,28 @@ nlm4svc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p)
311281
}
312282

313283
int
314-
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
284+
nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p)
315285
{
316-
struct nlm_res *resp = rqstp->rq_resp;
286+
struct xdr_stream *xdr = &rqstp->rq_arg_stream;
287+
struct nlm_args *argp = rqstp->rq_argp;
317288

318-
if (!(p = nlm4_encode_testres(p, resp)))
289+
if (!svcxdr_decode_cookie(xdr, &argp->cookie))
319290
return 0;
320-
return xdr_ressize_check(rqstp, p);
291+
if (!svcxdr_decode_lock(xdr, &argp->lock))
292+
return 0;
293+
argp->lock.fl.fl_type = F_UNLCK;
294+
295+
return 1;
321296
}
322297

323298
int
324-
nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p)
299+
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
325300
{
326-
struct nlm_args *argp = rqstp->rq_argp;
301+
struct nlm_res *resp = rqstp->rq_resp;
327302

328-
if (!(p = nlm4_decode_cookie(p, &argp->cookie))
329-
|| !(p = nlm4_decode_lock(p, &argp->lock)))
303+
if (!(p = nlm4_encode_testres(p, resp)))
330304
return 0;
331-
argp->lock.fl.fl_type = F_UNLCK;
332-
return xdr_argsize_check(rqstp, p);
305+
return xdr_ressize_check(rqstp, p);
333306
}
334307

335308
int

0 commit comments

Comments
 (0)