]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - fs/nfsd/nfs3xdr.c
Merge tag 'rtc-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[mirror_ubuntu-hirsute-kernel.git] / fs / nfsd / nfs3xdr.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4 2/*
1da177e4
LT
3 * XDR support for nfsd/protocol version 3.
4 *
5 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
6 *
7 * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()!
8 */
9
1da177e4 10#include <linux/namei.h>
b9c0ef85 11#include <linux/sunrpc/svc_xprt.h>
9a74af21 12#include "xdr3.h"
2e8138a2 13#include "auth.h"
b9c0ef85 14#include "netns.h"
3dadecce 15#include "vfs.h"
1da177e4
LT
16
17#define NFSDDBG_FACILITY NFSDDBG_XDR
18
1da177e4
LT
19
20/*
21 * Mapping of S_IF* types to NFS file types
22 */
23static u32 nfs3_ftypes[] = {
24 NF3NON, NF3FIFO, NF3CHR, NF3BAD,
25 NF3DIR, NF3BAD, NF3BLK, NF3BAD,
26 NF3REG, NF3BAD, NF3LNK, NF3BAD,
27 NF3SOCK, NF3BAD, NF3LNK, NF3BAD,
28};
29
27c438f5 30
1da177e4
LT
31/*
32 * XDR functions for basic NFS types
33 */
3ee6f61c 34static __be32 *
92c5e469 35encode_time3(__be32 *p, struct timespec64 *time)
1da177e4
LT
36{
37 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
38 return p;
39}
40
3ee6f61c 41static __be32 *
92c5e469 42decode_time3(__be32 *p, struct timespec64 *time)
1da177e4
LT
43{
44 time->tv_sec = ntohl(*p++);
45 time->tv_nsec = ntohl(*p++);
46 return p;
47}
48
3ee6f61c 49static __be32 *
91f07168 50decode_fh(__be32 *p, struct svc_fh *fhp)
1da177e4
LT
51{
52 unsigned int size;
53 fh_init(fhp, NFS3_FHSIZE);
54 size = ntohl(*p++);
55 if (size > NFS3_FHSIZE)
56 return NULL;
57
58 memcpy(&fhp->fh_handle.fh_base, p, size);
59 fhp->fh_handle.fh_size = size;
60 return p + XDR_QUADLEN(size);
61}
62
a257cdd0 63/* Helper function for NFSv3 ACL code */
91f07168 64__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
a257cdd0
AG
65{
66 return decode_fh(p, fhp);
67}
68
3ee6f61c 69static __be32 *
91f07168 70encode_fh(__be32 *p, struct svc_fh *fhp)
1da177e4
LT
71{
72 unsigned int size = fhp->fh_handle.fh_size;
73 *p++ = htonl(size);
74 if (size) p[XDR_QUADLEN(size)-1]=0;
75 memcpy(p, &fhp->fh_handle.fh_base, size);
76 return p + XDR_QUADLEN(size);
77}
78
79/*
80 * Decode a file name and make sure that the path contains
81 * no slashes or null bytes.
82 */
3ee6f61c 83static __be32 *
ee1a95b3 84decode_filename(__be32 *p, char **namp, unsigned int *lenp)
1da177e4
LT
85{
86 char *name;
ee1a95b3 87 unsigned int i;
1da177e4
LT
88
89 if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS3_MAXNAMLEN)) != NULL) {
90 for (i = 0, name = *namp; i < *lenp; i++, name++) {
91 if (*name == '\0' || *name == '/')
92 return NULL;
93 }
94 }
95
96 return p;
97}
98
3ee6f61c 99static __be32 *
e45d1a18 100decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns)
1da177e4
LT
101{
102 u32 tmp;
103
104 iap->ia_valid = 0;
105
106 if (*p++) {
107 iap->ia_valid |= ATTR_MODE;
108 iap->ia_mode = ntohl(*p++);
109 }
110 if (*p++) {
e45d1a18 111 iap->ia_uid = make_kuid(userns, ntohl(*p++));
458878a7
EB
112 if (uid_valid(iap->ia_uid))
113 iap->ia_valid |= ATTR_UID;
1da177e4
LT
114 }
115 if (*p++) {
e45d1a18 116 iap->ia_gid = make_kgid(userns, ntohl(*p++));
458878a7
EB
117 if (gid_valid(iap->ia_gid))
118 iap->ia_valid |= ATTR_GID;
1da177e4
LT
119 }
120 if (*p++) {
121 u64 newsize;
122
123 iap->ia_valid |= ATTR_SIZE;
124 p = xdr_decode_hyper(p, &newsize);
3c7aa15d 125 iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX);
1da177e4
LT
126 }
127 if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
128 iap->ia_valid |= ATTR_ATIME;
129 } else if (tmp == 2) { /* set to client time */
130 iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET;
131 iap->ia_atime.tv_sec = ntohl(*p++);
132 iap->ia_atime.tv_nsec = ntohl(*p++);
133 }
134 if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
135 iap->ia_valid |= ATTR_MTIME;
136 } else if (tmp == 2) { /* set to client time */
137 iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
138 iap->ia_mtime.tv_sec = ntohl(*p++);
139 iap->ia_mtime.tv_nsec = ntohl(*p++);
140 }
141 return p;
142}
143
af6a4e28
N
144static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp)
145{
146 u64 f;
147 switch(fsid_source(fhp)) {
148 default:
149 case FSIDSOURCE_DEV:
150 p = xdr_encode_hyper(p, (u64)huge_encode_dev
fc64005c 151 (fhp->fh_dentry->d_sb->s_dev));
af6a4e28
N
152 break;
153 case FSIDSOURCE_FSID:
154 p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
155 break;
156 case FSIDSOURCE_UUID:
157 f = ((u64*)fhp->fh_export->ex_uuid)[0];
158 f ^= ((u64*)fhp->fh_export->ex_uuid)[1];
159 p = xdr_encode_hyper(p, f);
160 break;
161 }
162 return p;
163}
164
3ee6f61c 165static __be32 *
91f07168 166encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
a334de28 167 struct kstat *stat)
1da177e4 168{
e45d1a18 169 struct user_namespace *userns = nfsd_user_namespace(rqstp);
a334de28 170 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
6e14b46b 171 *p++ = htonl((u32) (stat->mode & S_IALLUGO));
a334de28 172 *p++ = htonl((u32) stat->nlink);
e45d1a18
TM
173 *p++ = htonl((u32) from_kuid_munged(userns, stat->uid));
174 *p++ = htonl((u32) from_kgid_munged(userns, stat->gid));
a334de28 175 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
1da177e4
LT
176 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
177 } else {
a334de28 178 p = xdr_encode_hyper(p, (u64) stat->size);
1da177e4 179 }
a334de28
DS
180 p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
181 *p++ = htonl((u32) MAJOR(stat->rdev));
182 *p++ = htonl((u32) MINOR(stat->rdev));
af6a4e28 183 p = encode_fsid(p, fhp);
40ee5dc6 184 p = xdr_encode_hyper(p, stat->ino);
92c5e469
AB
185 p = encode_time3(p, &stat->atime);
186 p = encode_time3(p, &stat->mtime);
187 p = encode_time3(p, &stat->ctime);
1da177e4
LT
188
189 return p;
190}
191
3ee6f61c 192static __be32 *
91f07168 193encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
1da177e4 194{
1da177e4
LT
195 /* Attributes to follow */
196 *p++ = xdr_one;
40ee5dc6 197 return encode_fattr3(rqstp, p, fhp, &fhp->fh_post_attr);
1da177e4
LT
198}
199
200/*
201 * Encode post-operation attributes.
202 * The inode may be NULL if the call failed because of a stale file
203 * handle. In this case, no attributes are returned.
204 */
91f07168
AV
205static __be32 *
206encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
1da177e4
LT
207{
208 struct dentry *dentry = fhp->fh_dentry;
daab110e 209 if (!fhp->fh_no_wcc && dentry && d_really_is_positive(dentry)) {
3dadecce 210 __be32 err;
a334de28
DS
211 struct kstat stat;
212
3dadecce 213 err = fh_getattr(fhp, &stat);
a334de28
DS
214 if (!err) {
215 *p++ = xdr_one; /* attributes follow */
2b0143b5 216 lease_get_mtime(d_inode(dentry), &stat.mtime);
a334de28
DS
217 return encode_fattr3(rqstp, p, fhp, &stat);
218 }
1da177e4
LT
219 }
220 *p++ = xdr_zero;
221 return p;
222}
223
a257cdd0 224/* Helper for NFSv3 ACLs */
91f07168
AV
225__be32 *
226nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
a257cdd0
AG
227{
228 return encode_post_op_attr(rqstp, p, fhp);
229}
230
1da177e4
LT
231/*
232 * Enocde weak cache consistency data
233 */
91f07168
AV
234static __be32 *
235encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
1da177e4
LT
236{
237 struct dentry *dentry = fhp->fh_dentry;
238
2b0143b5 239 if (dentry && d_really_is_positive(dentry) && fhp->fh_post_saved) {
1da177e4
LT
240 if (fhp->fh_pre_saved) {
241 *p++ = xdr_one;
242 p = xdr_encode_hyper(p, (u64) fhp->fh_pre_size);
243 p = encode_time3(p, &fhp->fh_pre_mtime);
244 p = encode_time3(p, &fhp->fh_pre_ctime);
245 } else {
246 *p++ = xdr_zero;
247 }
248 return encode_saved_post_attr(rqstp, p, fhp);
249 }
250 /* no pre- or post-attrs */
251 *p++ = xdr_zero;
252 return encode_post_op_attr(rqstp, p, fhp);
253}
254
39ca1bf6
AG
255/*
256 * Fill in the pre_op attr for the wcc data
257 */
258void fill_pre_wcc(struct svc_fh *fhp)
259{
260 struct inode *inode;
261 struct kstat stat;
942b20dc 262 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
39ca1bf6
AG
263 __be32 err;
264
daab110e 265 if (fhp->fh_no_wcc || fhp->fh_pre_saved)
39ca1bf6 266 return;
39ca1bf6
AG
267 inode = d_inode(fhp->fh_dentry);
268 err = fh_getattr(fhp, &stat);
269 if (err) {
270 /* Grab the times from inode anyway */
271 stat.mtime = inode->i_mtime;
272 stat.ctime = inode->i_ctime;
273 stat.size = inode->i_size;
274 }
942b20dc
BF
275 if (v4)
276 fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);
39ca1bf6 277
92c5e469
AB
278 fhp->fh_pre_mtime = stat.mtime;
279 fhp->fh_pre_ctime = stat.ctime;
39ca1bf6 280 fhp->fh_pre_size = stat.size;
39ca1bf6
AG
281 fhp->fh_pre_saved = true;
282}
283
40ee5dc6
PS
284/*
285 * Fill in the post_op attr for the wcc data
286 */
287void fill_post_wcc(struct svc_fh *fhp)
288{
942b20dc
BF
289 bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
290 struct inode *inode = d_inode(fhp->fh_dentry);
3dadecce 291 __be32 err;
40ee5dc6 292
daab110e
JL
293 if (fhp->fh_no_wcc)
294 return;
295
40ee5dc6
PS
296 if (fhp->fh_post_saved)
297 printk("nfsd: inode locked twice during operation.\n");
298
3dadecce 299 err = fh_getattr(fhp, &fhp->fh_post_attr);
c1ac3ffc 300 if (err) {
aaf91ec1 301 fhp->fh_post_saved = false;
942b20dc 302 fhp->fh_post_attr.ctime = inode->i_ctime;
c1ac3ffc 303 } else
aaf91ec1 304 fhp->fh_post_saved = true;
942b20dc
BF
305 if (v4)
306 fhp->fh_post_change =
307 nfsd4_change_attribute(&fhp->fh_post_attr, inode);
40ee5dc6 308}
1da177e4
LT
309
310/*
311 * XDR decode functions
312 */
dcc46991 313
1da177e4 314int
026fec7e 315nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
1da177e4 316{
026fec7e
CH
317 struct nfsd_fhandle *args = rqstp->rq_argp;
318
d40aa337
BT
319 p = decode_fh(p, &args->fh);
320 if (!p)
1da177e4
LT
321 return 0;
322 return xdr_argsize_check(rqstp, p);
323}
324
325int
026fec7e 326nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 327{
026fec7e
CH
328 struct nfsd3_sattrargs *args = rqstp->rq_argp;
329
d40aa337
BT
330 p = decode_fh(p, &args->fh);
331 if (!p)
1da177e4 332 return 0;
e45d1a18 333 p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
1da177e4
LT
334
335 if ((args->check_guard = ntohl(*p++)) != 0) {
92c5e469 336 struct timespec64 time;
1da177e4
LT
337 p = decode_time3(p, &time);
338 args->guardtime = time.tv_sec;
339 }
340
341 return xdr_argsize_check(rqstp, p);
342}
343
344int
026fec7e 345nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 346{
026fec7e
CH
347 struct nfsd3_diropargs *args = rqstp->rq_argp;
348
1da177e4
LT
349 if (!(p = decode_fh(p, &args->fh))
350 || !(p = decode_filename(p, &args->name, &args->len)))
351 return 0;
352
353 return xdr_argsize_check(rqstp, p);
354}
355
356int
026fec7e 357nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 358{
026fec7e
CH
359 struct nfsd3_accessargs *args = rqstp->rq_argp;
360
d40aa337
BT
361 p = decode_fh(p, &args->fh);
362 if (!p)
1da177e4
LT
363 return 0;
364 args->access = ntohl(*p++);
365
366 return xdr_argsize_check(rqstp, p);
367}
368
369int
026fec7e 370nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 371{
026fec7e 372 struct nfsd3_readargs *args = rqstp->rq_argp;
1da177e4 373 unsigned int len;
afc59400 374 int v;
7adae489 375 u32 max_blocksize = svc_max_payload(rqstp);
1da177e4 376
d40aa337
BT
377 p = decode_fh(p, &args->fh);
378 if (!p)
1da177e4 379 return 0;
072f62ed 380 p = xdr_decode_hyper(p, &args->offset);
51f56777 381
9512a16b 382 args->count = ntohl(*p++);
3c7aa15d 383 len = min(args->count, max_blocksize);
1da177e4
LT
384
385 /* set up the kvec */
386 v=0;
387 while (len > 0) {
afc59400
BF
388 struct page *p = *(rqstp->rq_next_page++);
389
390 rqstp->rq_vec[v].iov_base = page_address(p);
3c7aa15d 391 rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
3cc03b16 392 len -= rqstp->rq_vec[v].iov_len;
1da177e4
LT
393 v++;
394 }
395 args->vlen = v;
9512a16b 396 return xdr_argsize_check(rqstp, p);
1da177e4
LT
397}
398
399int
026fec7e 400nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 401{
026fec7e 402 struct nfsd3_writeargs *args = rqstp->rq_argp;
8154ef27 403 unsigned int len, hdr, dlen;
7adae489 404 u32 max_blocksize = svc_max_payload(rqstp);
db44bac4
BF
405 struct kvec *head = rqstp->rq_arg.head;
406 struct kvec *tail = rqstp->rq_arg.tail;
1da177e4 407
d40aa337
BT
408 p = decode_fh(p, &args->fh);
409 if (!p)
1da177e4 410 return 0;
072f62ed 411 p = xdr_decode_hyper(p, &args->offset);
1da177e4
LT
412
413 args->count = ntohl(*p++);
414 args->stable = ntohl(*p++);
415 len = args->len = ntohl(*p++);
13bf9fbf
BF
416 if ((void *)p > head->iov_base + head->iov_len)
417 return 0;
f34b9568
PS
418 /*
419 * The count must equal the amount of data passed.
420 */
421 if (args->count != args->len)
422 return 0;
1da177e4 423
f34b9568
PS
424 /*
425 * Check to make sure that we got the right number of
426 * bytes.
f34b9568 427 */
db44bac4
BF
428 hdr = (void*)p - head->iov_base;
429 dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr;
f34b9568
PS
430 /*
431 * Round the length of the data which was specified up to
432 * the next multiple of XDR units and then compare that
433 * against the length which was actually received.
ba67a39e
N
434 * Note that when RPCSEC/GSS (for example) is used, the
435 * data buffer can be padded so dlen might be larger
436 * than required. It must never be smaller.
f34b9568 437 */
ba67a39e 438 if (dlen < XDR_QUADLEN(len)*4)
1da177e4
LT
439 return 0;
440
f34b9568
PS
441 if (args->count > max_blocksize) {
442 args->count = max_blocksize;
443 len = args->len = max_blocksize;
444 }
8154ef27
CL
445
446 args->first.iov_base = (void *)p;
447 args->first.iov_len = head->iov_len - hdr;
f34b9568 448 return 1;
1da177e4
LT
449}
450
451int
026fec7e 452nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 453{
026fec7e
CH
454 struct nfsd3_createargs *args = rqstp->rq_argp;
455
1da177e4
LT
456 if (!(p = decode_fh(p, &args->fh))
457 || !(p = decode_filename(p, &args->name, &args->len)))
458 return 0;
459
460 switch (args->createmode = ntohl(*p++)) {
461 case NFS3_CREATE_UNCHECKED:
462 case NFS3_CREATE_GUARDED:
e45d1a18 463 p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
1da177e4
LT
464 break;
465 case NFS3_CREATE_EXCLUSIVE:
466 args->verf = p;
467 p += 2;
468 break;
469 default:
470 return 0;
471 }
472
473 return xdr_argsize_check(rqstp, p);
474}
026fec7e 475
1da177e4 476int
026fec7e 477nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 478{
026fec7e
CH
479 struct nfsd3_createargs *args = rqstp->rq_argp;
480
072f62ed
N
481 if (!(p = decode_fh(p, &args->fh)) ||
482 !(p = decode_filename(p, &args->name, &args->len)))
1da177e4 483 return 0;
e45d1a18 484 p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
1da177e4
LT
485
486 return xdr_argsize_check(rqstp, p);
487}
488
489int
026fec7e 490nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 491{
026fec7e 492 struct nfsd3_symlinkargs *args = rqstp->rq_argp;
38a70315
CL
493 char *base = (char *)p;
494 size_t dlen;
1da177e4 495
072f62ed 496 if (!(p = decode_fh(p, &args->ffh)) ||
38a70315 497 !(p = decode_filename(p, &args->fname, &args->flen)))
1da177e4 498 return 0;
e45d1a18 499 p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
072f62ed 500
38a70315 501 args->tlen = ntohl(*p++);
1da177e4 502
38a70315
CL
503 args->first.iov_base = p;
504 args->first.iov_len = rqstp->rq_arg.head[0].iov_len;
505 args->first.iov_len -= (char *)p - base;
506
507 dlen = args->first.iov_len + rqstp->rq_arg.page_len +
508 rqstp->rq_arg.tail[0].iov_len;
509 if (dlen < XDR_QUADLEN(args->tlen) << 2)
510 return 0;
1da177e4
LT
511 return 1;
512}
513
514int
026fec7e 515nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 516{
026fec7e
CH
517 struct nfsd3_mknodargs *args = rqstp->rq_argp;
518
1da177e4
LT
519 if (!(p = decode_fh(p, &args->fh))
520 || !(p = decode_filename(p, &args->name, &args->len)))
521 return 0;
522
523 args->ftype = ntohl(*p++);
524
525 if (args->ftype == NF3BLK || args->ftype == NF3CHR
072f62ed 526 || args->ftype == NF3SOCK || args->ftype == NF3FIFO)
e45d1a18 527 p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
1da177e4
LT
528
529 if (args->ftype == NF3BLK || args->ftype == NF3CHR) {
530 args->major = ntohl(*p++);
531 args->minor = ntohl(*p++);
532 }
533
534 return xdr_argsize_check(rqstp, p);
535}
536
537int
026fec7e 538nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 539{
026fec7e
CH
540 struct nfsd3_renameargs *args = rqstp->rq_argp;
541
1da177e4
LT
542 if (!(p = decode_fh(p, &args->ffh))
543 || !(p = decode_filename(p, &args->fname, &args->flen))
544 || !(p = decode_fh(p, &args->tfh))
545 || !(p = decode_filename(p, &args->tname, &args->tlen)))
546 return 0;
547
548 return xdr_argsize_check(rqstp, p);
549}
550
551int
026fec7e 552nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 553{
026fec7e
CH
554 struct nfsd3_readlinkargs *args = rqstp->rq_argp;
555
d40aa337
BT
556 p = decode_fh(p, &args->fh);
557 if (!p)
1da177e4 558 return 0;
afc59400 559 args->buffer = page_address(*(rqstp->rq_next_page++));
1da177e4 560
9512a16b 561 return xdr_argsize_check(rqstp, p);
1da177e4
LT
562}
563
564int
026fec7e 565nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 566{
026fec7e
CH
567 struct nfsd3_linkargs *args = rqstp->rq_argp;
568
1da177e4
LT
569 if (!(p = decode_fh(p, &args->ffh))
570 || !(p = decode_fh(p, &args->tfh))
571 || !(p = decode_filename(p, &args->tname, &args->tlen)))
572 return 0;
573
574 return xdr_argsize_check(rqstp, p);
575}
576
577int
026fec7e 578nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 579{
026fec7e 580 struct nfsd3_readdirargs *args = rqstp->rq_argp;
3c86794a 581 int len;
f875a792
N
582 u32 max_blocksize = svc_max_payload(rqstp);
583
d40aa337
BT
584 p = decode_fh(p, &args->fh);
585 if (!p)
1da177e4
LT
586 return 0;
587 p = xdr_decode_hyper(p, &args->cookie);
588 args->verf = p; p += 2;
589 args->dircount = ~0;
590 args->count = ntohl(*p++);
3c86794a
MZ
591 len = args->count = min_t(u32, args->count, max_blocksize);
592
593 while (len > 0) {
594 struct page *p = *(rqstp->rq_next_page++);
595 if (!args->buffer)
596 args->buffer = page_address(p);
597 len -= PAGE_SIZE;
598 }
1da177e4 599
9512a16b 600 return xdr_argsize_check(rqstp, p);
1da177e4
LT
601}
602
603int
026fec7e 604nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 605{
026fec7e 606 struct nfsd3_readdirargs *args = rqstp->rq_argp;
afc59400 607 int len;
7adae489 608 u32 max_blocksize = svc_max_payload(rqstp);
1da177e4 609
d40aa337
BT
610 p = decode_fh(p, &args->fh);
611 if (!p)
1da177e4
LT
612 return 0;
613 p = xdr_decode_hyper(p, &args->cookie);
614 args->verf = p; p += 2;
615 args->dircount = ntohl(*p++);
616 args->count = ntohl(*p++);
617
3c7aa15d 618 len = args->count = min(args->count, max_blocksize);
1da177e4 619 while (len > 0) {
afc59400 620 struct page *p = *(rqstp->rq_next_page++);
1da177e4 621 if (!args->buffer)
afc59400 622 args->buffer = page_address(p);
1da177e4
LT
623 len -= PAGE_SIZE;
624 }
9512a16b
BF
625
626 return xdr_argsize_check(rqstp, p);
1da177e4
LT
627}
628
629int
026fec7e 630nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p)
1da177e4 631{
026fec7e 632 struct nfsd3_commitargs *args = rqstp->rq_argp;
d40aa337
BT
633 p = decode_fh(p, &args->fh);
634 if (!p)
1da177e4
LT
635 return 0;
636 p = xdr_decode_hyper(p, &args->offset);
637 args->count = ntohl(*p++);
638
639 return xdr_argsize_check(rqstp, p);
640}
641
642/*
643 * XDR encode functions
644 */
cc028a10 645
1da177e4
LT
646/* GETATTR */
647int
63f8de37 648nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p)
1da177e4 649{
63f8de37
CH
650 struct nfsd3_attrstat *resp = rqstp->rq_resp;
651
cc028a10 652 *p++ = resp->status;
40ee5dc6 653 if (resp->status == 0) {
2b0143b5 654 lease_get_mtime(d_inode(resp->fh.fh_dentry),
40ee5dc6 655 &resp->stat.mtime);
a334de28 656 p = encode_fattr3(rqstp, p, &resp->fh, &resp->stat);
40ee5dc6 657 }
1da177e4
LT
658 return xdr_ressize_check(rqstp, p);
659}
660
661/* SETATTR, REMOVE, RMDIR */
662int
63f8de37 663nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p)
1da177e4 664{
63f8de37
CH
665 struct nfsd3_attrstat *resp = rqstp->rq_resp;
666
cc028a10 667 *p++ = resp->status;
1da177e4
LT
668 p = encode_wcc_data(rqstp, p, &resp->fh);
669 return xdr_ressize_check(rqstp, p);
670}
671
672/* LOOKUP */
673int
63f8de37 674nfs3svc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 675{
63f8de37
CH
676 struct nfsd3_diropres *resp = rqstp->rq_resp;
677
cc028a10 678 *p++ = resp->status;
1da177e4
LT
679 if (resp->status == 0) {
680 p = encode_fh(p, &resp->fh);
681 p = encode_post_op_attr(rqstp, p, &resp->fh);
682 }
683 p = encode_post_op_attr(rqstp, p, &resp->dirfh);
684 return xdr_ressize_check(rqstp, p);
685}
686
687/* ACCESS */
688int
63f8de37 689nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 690{
63f8de37
CH
691 struct nfsd3_accessres *resp = rqstp->rq_resp;
692
cc028a10 693 *p++ = resp->status;
1da177e4
LT
694 p = encode_post_op_attr(rqstp, p, &resp->fh);
695 if (resp->status == 0)
696 *p++ = htonl(resp->access);
697 return xdr_ressize_check(rqstp, p);
698}
699
700/* READLINK */
701int
63f8de37 702nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 703{
63f8de37 704 struct nfsd3_readlinkres *resp = rqstp->rq_resp;
76e5492b 705 struct kvec *head = rqstp->rq_res.head;
63f8de37 706
cc028a10 707 *p++ = resp->status;
1da177e4
LT
708 p = encode_post_op_attr(rqstp, p, &resp->fh);
709 if (resp->status == 0) {
710 *p++ = htonl(resp->len);
711 xdr_ressize_check(rqstp, p);
712 rqstp->rq_res.page_len = resp->len;
713 if (resp->len & 3) {
714 /* need to pad the tail */
1da177e4
LT
715 rqstp->rq_res.tail[0].iov_base = p;
716 *p = 0;
717 rqstp->rq_res.tail[0].iov_len = 4 - (resp->len&3);
718 }
76e5492b
CL
719 if (svc_encode_result_payload(rqstp, head->iov_len, resp->len))
720 return 0;
1da177e4
LT
721 return 1;
722 } else
723 return xdr_ressize_check(rqstp, p);
724}
725
726/* READ */
727int
63f8de37 728nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 729{
63f8de37 730 struct nfsd3_readres *resp = rqstp->rq_resp;
76e5492b 731 struct kvec *head = rqstp->rq_res.head;
63f8de37 732
cc028a10 733 *p++ = resp->status;
1da177e4
LT
734 p = encode_post_op_attr(rqstp, p, &resp->fh);
735 if (resp->status == 0) {
736 *p++ = htonl(resp->count);
737 *p++ = htonl(resp->eof);
738 *p++ = htonl(resp->count); /* xdr opaque count */
739 xdr_ressize_check(rqstp, p);
25985edc 740 /* now update rqstp->rq_res to reflect data as well */
1da177e4
LT
741 rqstp->rq_res.page_len = resp->count;
742 if (resp->count & 3) {
743 /* need to pad the tail */
1da177e4
LT
744 rqstp->rq_res.tail[0].iov_base = p;
745 *p = 0;
746 rqstp->rq_res.tail[0].iov_len = 4 - (resp->count & 3);
747 }
76e5492b
CL
748 if (svc_encode_result_payload(rqstp, head->iov_len,
749 resp->count))
750 return 0;
1da177e4
LT
751 return 1;
752 } else
753 return xdr_ressize_check(rqstp, p);
754}
755
756/* WRITE */
757int
63f8de37 758nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 759{
63f8de37 760 struct nfsd3_writeres *resp = rqstp->rq_resp;
b9c0ef85 761
cc028a10 762 *p++ = resp->status;
1da177e4
LT
763 p = encode_wcc_data(rqstp, p, &resp->fh);
764 if (resp->status == 0) {
765 *p++ = htonl(resp->count);
766 *p++ = htonl(resp->committed);
19e0663f
TM
767 *p++ = resp->verf[0];
768 *p++ = resp->verf[1];
1da177e4
LT
769 }
770 return xdr_ressize_check(rqstp, p);
771}
772
773/* CREATE, MKDIR, SYMLINK, MKNOD */
774int
63f8de37 775nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 776{
63f8de37
CH
777 struct nfsd3_diropres *resp = rqstp->rq_resp;
778
cc028a10 779 *p++ = resp->status;
1da177e4
LT
780 if (resp->status == 0) {
781 *p++ = xdr_one;
782 p = encode_fh(p, &resp->fh);
783 p = encode_post_op_attr(rqstp, p, &resp->fh);
784 }
785 p = encode_wcc_data(rqstp, p, &resp->dirfh);
786 return xdr_ressize_check(rqstp, p);
787}
788
789/* RENAME */
790int
63f8de37 791nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 792{
63f8de37
CH
793 struct nfsd3_renameres *resp = rqstp->rq_resp;
794
cc028a10 795 *p++ = resp->status;
1da177e4
LT
796 p = encode_wcc_data(rqstp, p, &resp->ffh);
797 p = encode_wcc_data(rqstp, p, &resp->tfh);
798 return xdr_ressize_check(rqstp, p);
799}
800
801/* LINK */
802int
63f8de37 803nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 804{
63f8de37
CH
805 struct nfsd3_linkres *resp = rqstp->rq_resp;
806
cc028a10 807 *p++ = resp->status;
1da177e4
LT
808 p = encode_post_op_attr(rqstp, p, &resp->fh);
809 p = encode_wcc_data(rqstp, p, &resp->tfh);
810 return xdr_ressize_check(rqstp, p);
811}
812
813/* READDIR */
814int
63f8de37 815nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 816{
63f8de37
CH
817 struct nfsd3_readdirres *resp = rqstp->rq_resp;
818
cc028a10 819 *p++ = resp->status;
1da177e4
LT
820 p = encode_post_op_attr(rqstp, p, &resp->fh);
821
822 if (resp->status == 0) {
823 /* stupid readdir cookie */
824 memcpy(p, resp->verf, 8); p += 2;
825 xdr_ressize_check(rqstp, p);
826 if (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE)
827 return 1; /*No room for trailer */
828 rqstp->rq_res.page_len = (resp->count) << 2;
829
830 /* add the 'tail' to the end of the 'head' page - page 0. */
1da177e4
LT
831 rqstp->rq_res.tail[0].iov_base = p;
832 *p++ = 0; /* no more entries */
833 *p++ = htonl(resp->common.err == nfserr_eof);
834 rqstp->rq_res.tail[0].iov_len = 2<<2;
835 return 1;
836 } else
837 return xdr_ressize_check(rqstp, p);
838}
839
3ee6f61c 840static __be32 *
91f07168 841encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
40ee5dc6 842 int namlen, u64 ino)
1da177e4
LT
843{
844 *p++ = xdr_one; /* mark entry present */
845 p = xdr_encode_hyper(p, ino); /* file id */
846 p = xdr_encode_array(p, name, namlen);/* name length & name */
847
848 cd->offset = p; /* remember pointer */
849 p = xdr_encode_hyper(p, NFS_OFFSET_MAX);/* offset of next entry */
850
851 return p;
852}
853
efe39651 854static __be32
1da177e4 855compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
43b0e7ea 856 const char *name, int namlen, u64 ino)
1da177e4
LT
857{
858 struct svc_export *exp;
859 struct dentry *dparent, *dchild;
efe39651 860 __be32 rv = nfserr_noent;
1da177e4
LT
861
862 dparent = cd->fh.fh_dentry;
863 exp = cd->fh.fh_export;
864
1da177e4
LT
865 if (isdotent(name, namlen)) {
866 if (namlen == 2) {
867 dchild = dget_parent(dparent);
efe39651
AV
868 /* filesystem root - cannot return filehandle for ".." */
869 if (dchild == dparent)
870 goto out;
1da177e4
LT
871 } else
872 dchild = dget(dparent);
873 } else
6c2d4798 874 dchild = lookup_positive_unlocked(name, dparent, namlen);
1da177e4 875 if (IS_ERR(dchild))
efe39651 876 return rv;
8177e6d6
BF
877 if (d_mountpoint(dchild))
878 goto out;
43b0e7ea
N
879 if (dchild->d_inode->i_ino != ino)
880 goto out;
efe39651 881 rv = fh_compose(fhp, exp, dchild, &cd->fh);
8177e6d6 882out:
1da177e4
LT
883 dput(dchild);
884 return rv;
885}
886
43b0e7ea 887static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen, u64 ino)
8177e6d6 888{
068c34c0 889 struct svc_fh *fh = &cd->scratch;
efe39651 890 __be32 err;
8177e6d6 891
068c34c0 892 fh_init(fh, NFS3_FHSIZE);
43b0e7ea 893 err = compose_entry_fh(cd, fh, name, namlen, ino);
8177e6d6
BF
894 if (err) {
895 *p++ = 0;
896 *p++ = 0;
aed100fa 897 goto out;
8177e6d6 898 }
068c34c0 899 p = encode_post_op_attr(cd->rqstp, p, fh);
8177e6d6 900 *p++ = xdr_one; /* yes, a file handle follows */
068c34c0 901 p = encode_fh(p, fh);
aed100fa 902out:
068c34c0 903 fh_put(fh);
8177e6d6
BF
904 return p;
905}
906
1da177e4
LT
907/*
908 * Encode a directory entry. This one works for both normal readdir
909 * and readdirplus.
910 * The normal readdir reply requires 2 (fileid) + 1 (stringlen)
911 * + string + 2 (cookie) + 1 (next) words, i.e. 6 + strlen.
912 *
913 * The readdirplus baggage is 1+21 words for post_op_attr, plus the
914 * file handle.
915 */
916
917#define NFS3_ENTRY_BAGGAGE (2 + 1 + 2 + 1)
918#define NFS3_ENTRYPLUS_BAGGAGE (1 + 21 + 1 + (NFS3_FHSIZE >> 2))
919static int
598b9a56 920encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
40ee5dc6 921 loff_t offset, u64 ino, unsigned int d_type, int plus)
1da177e4
LT
922{
923 struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres,
924 common);
91f07168 925 __be32 *p = cd->buffer;
1da177e4 926 caddr_t curr_page_addr = NULL;
afc59400 927 struct page ** page;
1da177e4
LT
928 int slen; /* string (name) length */
929 int elen; /* estimated entry length in words */
930 int num_entry_words = 0; /* actual number of words */
931
932 if (cd->offset) {
933 u64 offset64 = offset;
934
935 if (unlikely(cd->offset1)) {
936 /* we ended up with offset on a page boundary */
937 *cd->offset = htonl(offset64 >> 32);
938 *cd->offset1 = htonl(offset64 & 0xffffffff);
939 cd->offset1 = NULL;
940 } else {
598b9a56 941 xdr_encode_hyper(cd->offset, offset64);
1da177e4 942 }
b602345d 943 cd->offset = NULL;
1da177e4
LT
944 }
945
946 /*
947 dprintk("encode_entry(%.*s @%ld%s)\n",
948 namlen, name, (long) offset, plus? " plus" : "");
949 */
950
951 /* truncate filename if too long */
3c7aa15d 952 namlen = min(namlen, NFS3_MAXNAMLEN);
1da177e4
LT
953
954 slen = XDR_QUADLEN(namlen);
955 elen = slen + NFS3_ENTRY_BAGGAGE
956 + (plus? NFS3_ENTRYPLUS_BAGGAGE : 0);
957
958 if (cd->buflen < elen) {
959 cd->common.err = nfserr_toosmall;
960 return -EINVAL;
961 }
962
963 /* determine which page in rq_respages[] we are currently filling */
afc59400
BF
964 for (page = cd->rqstp->rq_respages + 1;
965 page < cd->rqstp->rq_next_page; page++) {
966 curr_page_addr = page_address(*page);
1da177e4
LT
967
968 if (((caddr_t)cd->buffer >= curr_page_addr) &&
969 ((caddr_t)cd->buffer < curr_page_addr + PAGE_SIZE))
970 break;
971 }
972
973 if ((caddr_t)(cd->buffer + elen) < (curr_page_addr + PAGE_SIZE)) {
974 /* encode entry in current page */
975
976 p = encode_entry_baggage(cd, p, name, namlen, ino);
977
8177e6d6 978 if (plus)
43b0e7ea 979 p = encode_entryplus_baggage(cd, p, name, namlen, ino);
1da177e4 980 num_entry_words = p - cd->buffer;
afc59400 981 } else if (*(page+1) != NULL) {
1da177e4
LT
982 /* temporarily encode entry into next page, then move back to
983 * current and next page in rq_respages[] */
91f07168 984 __be32 *p1, *tmp;
1da177e4
LT
985 int len1, len2;
986
987 /* grab next page for temporary storage of entry */
afc59400 988 p1 = tmp = page_address(*(page+1));
1da177e4
LT
989
990 p1 = encode_entry_baggage(cd, p1, name, namlen, ino);
991
8177e6d6 992 if (plus)
43b0e7ea 993 p1 = encode_entryplus_baggage(cd, p1, name, namlen, ino);
1da177e4
LT
994
995 /* determine entry word length and lengths to go in pages */
996 num_entry_words = p1 - tmp;
997 len1 = curr_page_addr + PAGE_SIZE - (caddr_t)cd->buffer;
998 if ((num_entry_words << 2) < len1) {
999 /* the actual number of words in the entry is less
1000 * than elen and can still fit in the current page
1001 */
1002 memmove(p, tmp, num_entry_words << 2);
1003 p += num_entry_words;
1004
1005 /* update offset */
1006 cd->offset = cd->buffer + (cd->offset - tmp);
1007 } else {
1008 unsigned int offset_r = (cd->offset - tmp) << 2;
1009
1010 /* update pointer to offset location.
1011 * This is a 64bit quantity, so we need to
1012 * deal with 3 cases:
1013 * - entirely in first page
1014 * - entirely in second page
1015 * - 4 bytes in each page
1016 */
1017 if (offset_r + 8 <= len1) {
1018 cd->offset = p + (cd->offset - tmp);
1019 } else if (offset_r >= len1) {
1020 cd->offset -= len1 >> 2;
1021 } else {
1022 /* sitting on the fence */
1023 BUG_ON(offset_r != len1 - 4);
1024 cd->offset = p + (cd->offset - tmp);
1025 cd->offset1 = tmp;
1026 }
1027
1028 len2 = (num_entry_words << 2) - len1;
1029
1030 /* move from temp page to current and next pages */
1031 memmove(p, tmp, len1);
1032 memmove(tmp, (caddr_t)tmp+len1, len2);
1033
1034 p = tmp + (len2 >> 2);
1035 }
1036 }
1037 else {
1038 cd->common.err = nfserr_toosmall;
1039 return -EINVAL;
1040 }
1041
1042 cd->buflen -= num_entry_words;
1043 cd->buffer = p;
1044 cd->common.err = nfs_ok;
1045 return 0;
1046
1047}
1048
1049int
a0ad13ef
N
1050nfs3svc_encode_entry(void *cd, const char *name,
1051 int namlen, loff_t offset, u64 ino, unsigned int d_type)
1da177e4
LT
1052{
1053 return encode_entry(cd, name, namlen, offset, ino, d_type, 0);
1054}
1055
1056int
a0ad13ef
N
1057nfs3svc_encode_entry_plus(void *cd, const char *name,
1058 int namlen, loff_t offset, u64 ino,
1059 unsigned int d_type)
1da177e4
LT
1060{
1061 return encode_entry(cd, name, namlen, offset, ino, d_type, 1);
1062}
1063
1064/* FSSTAT */
1065int
63f8de37 1066nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 1067{
63f8de37 1068 struct nfsd3_fsstatres *resp = rqstp->rq_resp;
1da177e4
LT
1069 struct kstatfs *s = &resp->stats;
1070 u64 bs = s->f_bsize;
1071
cc028a10 1072 *p++ = resp->status;
1da177e4
LT
1073 *p++ = xdr_zero; /* no post_op_attr */
1074
1075 if (resp->status == 0) {
1076 p = xdr_encode_hyper(p, bs * s->f_blocks); /* total bytes */
1077 p = xdr_encode_hyper(p, bs * s->f_bfree); /* free bytes */
1078 p = xdr_encode_hyper(p, bs * s->f_bavail); /* user available bytes */
1079 p = xdr_encode_hyper(p, s->f_files); /* total inodes */
1080 p = xdr_encode_hyper(p, s->f_ffree); /* free inodes */
1081 p = xdr_encode_hyper(p, s->f_ffree); /* user available inodes */
1082 *p++ = htonl(resp->invarsec); /* mean unchanged time */
1083 }
1084 return xdr_ressize_check(rqstp, p);
1085}
1086
1087/* FSINFO */
1088int
63f8de37 1089nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, __be32 *p)
1da177e4 1090{
63f8de37
CH
1091 struct nfsd3_fsinfores *resp = rqstp->rq_resp;
1092
cc028a10 1093 *p++ = resp->status;
1da177e4
LT
1094 *p++ = xdr_zero; /* no post_op_attr */
1095
1096 if (resp->status == 0) {
1097 *p++ = htonl(resp->f_rtmax);
1098 *p++ = htonl(resp->f_rtpref);
1099 *p++ = htonl(resp->f_rtmult);
1100 *p++ = htonl(resp->f_wtmax);
1101 *p++ = htonl(resp->f_wtpref);
1102 *p++ = htonl(resp->f_wtmult);
1103 *p++ = htonl(resp->f_dtpref);
1104 p = xdr_encode_hyper(p, resp->f_maxfilesize);
1105 *p++ = xdr_one;
1106 *p++ = xdr_zero;
1107 *p++ = htonl(resp->f_properties);
1108 }
1109
1110 return xdr_ressize_check(rqstp, p);
1111}
1112
1113/* PATHCONF */
1114int
63f8de37 1115nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 1116{
63f8de37
CH
1117 struct nfsd3_pathconfres *resp = rqstp->rq_resp;
1118
1905cac9 1119 *p++ = resp->status;
1da177e4
LT
1120 *p++ = xdr_zero; /* no post_op_attr */
1121
1122 if (resp->status == 0) {
1123 *p++ = htonl(resp->p_link_max);
1124 *p++ = htonl(resp->p_name_max);
1125 *p++ = htonl(resp->p_no_trunc);
1126 *p++ = htonl(resp->p_chown_restricted);
1127 *p++ = htonl(resp->p_case_insensitive);
1128 *p++ = htonl(resp->p_case_preserving);
1129 }
1130
1131 return xdr_ressize_check(rqstp, p);
1132}
1133
1134/* COMMIT */
1135int
63f8de37 1136nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p)
1da177e4 1137{
63f8de37 1138 struct nfsd3_commitres *resp = rqstp->rq_resp;
b9c0ef85 1139
cc028a10 1140 *p++ = resp->status;
1da177e4
LT
1141 p = encode_wcc_data(rqstp, p, &resp->fh);
1142 /* Write verifier */
1143 if (resp->status == 0) {
524ff1af
TM
1144 *p++ = resp->verf[0];
1145 *p++ = resp->verf[1];
1da177e4
LT
1146 }
1147 return xdr_ressize_check(rqstp, p);
1148}
1149
1150/*
1151 * XDR release functions
1152 */
8537488b
CH
1153void
1154nfs3svc_release_fhandle(struct svc_rqst *rqstp)
1da177e4 1155{
8537488b
CH
1156 struct nfsd3_attrstat *resp = rqstp->rq_resp;
1157
1da177e4 1158 fh_put(&resp->fh);
1da177e4
LT
1159}
1160
8537488b
CH
1161void
1162nfs3svc_release_fhandle2(struct svc_rqst *rqstp)
1da177e4 1163{
8537488b
CH
1164 struct nfsd3_fhandle_pair *resp = rqstp->rq_resp;
1165
1da177e4
LT
1166 fh_put(&resp->fh1);
1167 fh_put(&resp->fh2);
1da177e4 1168}