4 * Server-side procedures for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * Note: some routines in this file are just trivial wrappers
38 * (e.g. nfsd4_lookup()) defined solely for the sake of consistent
39 * naming. Since all such routines have been declared "inline",
40 * there shouldn't be any associated overhead. At some point in
41 * the future, I might inline these "by hand" to clean up a
45 #include <linux/param.h>
46 #include <linux/major.h>
47 #include <linux/slab.h>
49 #include <linux/sunrpc/svc.h>
50 #include <linux/nfsd/nfsd.h>
51 #include <linux/nfsd/cache.h>
52 #include <linux/nfs4.h>
53 #include <linux/nfsd/state.h>
54 #include <linux/nfsd/xdr4.h>
56 #define NFSDDBG_FACILITY NFSDDBG_PROC
58 /* Note: The organization of the OPEN code seems a little strange; it
59 * has been superfluously split into three routines, one of which is named
60 * nfsd4_process_open2() even though there is no nfsd4_process_open1()!
61 * This is because the code has been organized in anticipation of a
62 * subsequent patch which will implement more of the NFSv4 state model.
65 do_open_lookup(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_open
*open
)
70 fh_init(&resfh
, NFS4_FHSIZE
);
71 open
->op_truncate
= 0;
73 if (open
->op_create
) {
75 * Note: create modes (UNCHECKED,GUARDED...) are the same
78 status
= nfsd_create_v3(rqstp
, current_fh
, open
->op_fname
.data
,
79 open
->op_fname
.len
, &open
->op_iattr
,
80 &resfh
, open
->op_createmode
,
81 (u32
*)open
->op_verf
, &open
->op_truncate
);
84 status
= nfsd_lookup(rqstp
, current_fh
,
85 open
->op_fname
.data
, open
->op_fname
.len
, &resfh
);
86 fh_unlock(current_fh
);
90 set_change_info(&open
->op_cinfo
, current_fh
);
91 fh_dup2(current_fh
, &resfh
);
94 if (open
->op_share_access
& NFS4_SHARE_ACCESS_READ
)
96 if (open
->op_share_deny
& NFS4_SHARE_ACCESS_WRITE
)
97 accmode
|= (MAY_WRITE
| MAY_TRUNC
);
98 status
= fh_verify(rqstp
, current_fh
, S_IFREG
, accmode
);
106 nfsd4_open(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_open
*open
)
109 dprintk("NFSD: nfsd4_open filename %.*s\n",open
->op_fname
.len
, open
->op_fname
.data
);
111 /* This check required by spec. */
112 if (open
->op_create
&& open
->op_claim_type
!= NFS4_OPEN_CLAIM_NULL
)
115 /* check seqid for replay. set nfs4_owner */
116 status
= nfsd4_process_open1(open
);
120 * This block of code will (1) set CURRENT_FH to the file being opened,
121 * creating it if necessary, (2) set open->op_cinfo,
122 * (3) set open->op_truncate if the file is to be truncated
123 * after opening, (4) do permission checking.
125 status
= do_open_lookup(rqstp
, current_fh
, open
);
130 * nfsd4_process_open2() does the actual opening of the file. If
131 * successful, it (1) truncates the file if open->op_truncate was
132 * set, (2) sets open->op_stateid, (3) sets open->op_delegation.
134 status
= nfsd4_process_open2(rqstp
, current_fh
, open
);
141 * filehandle-manipulating ops.
144 nfsd4_getfh(struct svc_fh
*current_fh
, struct svc_fh
**getfh
)
146 if (!current_fh
->fh_dentry
)
147 return nfserr_nofilehandle
;
154 nfsd4_putfh(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_putfh
*putfh
)
157 current_fh
->fh_handle
.fh_size
= putfh
->pf_fhlen
;
158 memcpy(¤t_fh
->fh_handle
.fh_base
, putfh
->pf_fhval
, putfh
->pf_fhlen
);
159 return fh_verify(rqstp
, current_fh
, 0, MAY_NOP
);
163 nfsd4_putrootfh(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
)
166 return exp_pseudoroot(rqstp
->rq_client
, current_fh
,
171 nfsd4_restorefh(struct svc_fh
*current_fh
, struct svc_fh
*save_fh
)
173 if (!save_fh
->fh_dentry
)
174 return nfserr_nofilehandle
;
176 fh_dup2(current_fh
, save_fh
);
181 nfsd4_savefh(struct svc_fh
*current_fh
, struct svc_fh
*save_fh
)
183 if (!current_fh
->fh_dentry
)
184 return nfserr_nofilehandle
;
186 fh_dup2(save_fh
, current_fh
);
194 nfsd4_access(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_access
*access
)
196 if (access
->ac_req_access
& ~NFS3_ACCESS_FULL
)
199 access
->ac_resp_access
= access
->ac_req_access
;
200 return nfsd_access(rqstp
, current_fh
, &access
->ac_resp_access
, &access
->ac_supported
);
204 nfsd4_commit(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_commit
*commit
)
206 u32
*p
= (u32
*)commit
->co_verf
;
207 *p
++ = nfssvc_boot
.tv_sec
;
208 *p
++ = nfssvc_boot
.tv_usec
;
210 return nfsd_commit(rqstp
, current_fh
, commit
->co_offset
, commit
->co_count
);
214 nfsd4_create(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_create
*create
)
220 fh_init(&resfh
, NFS4_FHSIZE
);
222 status
= fh_verify(rqstp
, current_fh
, S_IFDIR
, MAY_CREATE
);
226 switch (create
->cr_type
) {
228 /* ugh! we have to null-terminate the linktext, or
229 * vfs_symlink() will choke. it is always safe to
230 * null-terminate by brute force, since at worst we
231 * will overwrite the first byte of the create namelen
232 * in the XDR buffer, which has already been extracted
235 create
->cr_linkname
[create
->cr_linklen
] = 0;
237 status
= nfsd_symlink(rqstp
, current_fh
, create
->cr_name
,
238 create
->cr_namelen
, create
->cr_linkname
,
239 create
->cr_linklen
, &resfh
, &create
->cr_iattr
);
243 rdev
= MKDEV(create
->cr_specdata1
, create
->cr_specdata2
);
244 if (MAJOR(rdev
) != create
->cr_specdata1
||
245 MINOR(rdev
) != create
->cr_specdata2
)
247 status
= nfsd_create(rqstp
, current_fh
, create
->cr_name
,
248 create
->cr_namelen
, &create
->cr_iattr
,
249 S_IFBLK
, rdev
, &resfh
);
253 rdev
= MKDEV(create
->cr_specdata1
, create
->cr_specdata2
);
254 if (MAJOR(rdev
) != create
->cr_specdata1
||
255 MINOR(rdev
) != create
->cr_specdata2
)
257 status
= nfsd_create(rqstp
, current_fh
, create
->cr_name
,
258 create
->cr_namelen
, &create
->cr_iattr
,
259 S_IFCHR
, rdev
, &resfh
);
263 status
= nfsd_create(rqstp
, current_fh
, create
->cr_name
,
264 create
->cr_namelen
, &create
->cr_iattr
,
265 S_IFSOCK
, 0, &resfh
);
269 status
= nfsd_create(rqstp
, current_fh
, create
->cr_name
,
270 create
->cr_namelen
, &create
->cr_iattr
,
275 create
->cr_iattr
.ia_valid
&= ~ATTR_SIZE
;
276 status
= nfsd_create(rqstp
, current_fh
, create
->cr_name
,
277 create
->cr_namelen
, &create
->cr_iattr
,
286 fh_unlock(current_fh
);
287 set_change_info(&create
->cr_cinfo
, current_fh
);
288 fh_dup2(current_fh
, &resfh
);
296 nfsd4_getattr(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_getattr
*getattr
)
300 status
= fh_verify(rqstp
, current_fh
, 0, MAY_NOP
);
304 if (getattr
->ga_bmval
[1] & NFSD_WRITEONLY_ATTRS_WORD1
)
307 getattr
->ga_bmval
[0] &= NFSD_SUPPORTED_ATTRS_WORD0
;
308 getattr
->ga_bmval
[1] &= NFSD_SUPPORTED_ATTRS_WORD1
;
310 getattr
->ga_fhp
= current_fh
;
315 nfsd4_link(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
,
316 struct svc_fh
*save_fh
, struct nfsd4_link
*link
)
320 status
= nfsd_link(rqstp
, current_fh
, link
->li_name
, link
->li_namelen
, save_fh
);
322 set_change_info(&link
->li_cinfo
, current_fh
);
327 nfsd4_lookupp(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
)
330 * XXX: We currently violate the spec in one small respect
331 * here. If LOOKUPP is done at the root of the pseudofs,
332 * the spec requires us to return NFSERR_NOENT. Personally,
333 * I think that leaving the filehandle unchanged is more
334 * logical, but this is an academic question anyway, since
335 * no clients actually use LOOKUPP.
337 return nfsd_lookup(rqstp
, current_fh
, "..", 2, current_fh
);
341 nfsd4_lookup(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_lookup
*lookup
)
343 return nfsd_lookup(rqstp
, current_fh
, lookup
->lo_name
, lookup
->lo_len
, current_fh
);
347 nfsd4_read(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_read
*read
)
349 struct nfs4_stateid
*stp
;
352 /* no need to check permission - this will be done in nfsd_read() */
354 if (read
->rd_offset
>= OFFSET_MAX
)
359 /* For stateid -1, we don't check share reservations. */
360 if (ONE_STATEID(&read
->rd_stateid
)) {
361 dprintk("NFSD: nfsd4_read: -1 stateid...\n");
365 * For stateid 0, the client doesn't have to have the file open, but
366 * we still check for share reservation conflicts.
368 if (ZERO_STATEID(&read
->rd_stateid
)) {
369 dprintk("NFSD: nfsd4_read: zero stateid...\n");
370 if ((status
= nfs4_share_conflict(current_fh
, NFS4_SHARE_DENY_READ
))) {
371 dprintk("NFSD: nfsd4_read: conflicting share reservation!\n");
378 if ((status
= nfs4_preprocess_stateid_op(current_fh
, &read
->rd_stateid
,
380 dprintk("NFSD: nfsd4_read: couldn't process stateid!\n");
383 status
= nfserr_openmode
;
384 if (!(stp
->st_share_access
& NFS4_SHARE_ACCESS_READ
)) {
385 dprintk("NFSD: nfsd4_read: file not opened for read!\n");
390 nfsd4_unlock_state();
391 read
->rd_rqstp
= rqstp
;
392 read
->rd_fhp
= current_fh
;
397 nfsd4_readdir(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_readdir
*readdir
)
399 /* no need to check permission - this will be done in nfsd_readdir() */
401 if (readdir
->rd_bmval
[1] & NFSD_WRITEONLY_ATTRS_WORD1
)
404 readdir
->rd_bmval
[0] &= NFSD_SUPPORTED_ATTRS_WORD0
;
405 readdir
->rd_bmval
[1] &= NFSD_SUPPORTED_ATTRS_WORD1
;
407 if (readdir
->rd_cookie
> ~(u32
)0)
408 return nfserr_bad_cookie
;
410 readdir
->rd_rqstp
= rqstp
;
411 readdir
->rd_fhp
= current_fh
;
416 nfsd4_readlink(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_readlink
*readlink
)
418 readlink
->rl_rqstp
= rqstp
;
419 readlink
->rl_fhp
= current_fh
;
424 nfsd4_remove(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_remove
*remove
)
428 status
= nfsd_unlink(rqstp
, current_fh
, 0, remove
->rm_name
, remove
->rm_namelen
);
430 fh_unlock(current_fh
);
431 set_change_info(&remove
->rm_cinfo
, current_fh
);
437 nfsd4_rename(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
,
438 struct svc_fh
*save_fh
, struct nfsd4_rename
*rename
)
442 status
= nfsd_rename(rqstp
, save_fh
, rename
->rn_sname
,
443 rename
->rn_snamelen
, current_fh
,
444 rename
->rn_tname
, rename
->rn_tnamelen
);
446 set_change_info(&rename
->rn_sinfo
, current_fh
);
447 set_change_info(&rename
->rn_tinfo
, save_fh
);
453 nfsd4_setattr(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_setattr
*setattr
)
455 struct nfs4_stateid
*stp
;
458 if (setattr
->sa_iattr
.ia_valid
& ATTR_SIZE
) {
460 status
= nfserr_bad_stateid
;
461 if (ZERO_STATEID(&setattr
->sa_stateid
) || ONE_STATEID(&setattr
->sa_stateid
)) {
462 dprintk("NFSD: nfsd4_setattr: magic stateid!\n");
467 if ((status
= nfs4_preprocess_stateid_op(current_fh
,
468 &setattr
->sa_stateid
,
470 dprintk("NFSD: nfsd4_setattr: couldn't process stateid!\n");
473 status
= nfserr_openmode
;
474 if (!(stp
->st_share_access
& NFS4_SHARE_ACCESS_WRITE
)) {
475 dprintk("NFSD: nfsd4_setattr: not opened for write!\n");
478 nfsd4_unlock_state();
480 return (nfsd_setattr(rqstp
, current_fh
, &setattr
->sa_iattr
, 0, (time_t)0));
482 nfsd4_unlock_state();
487 nfsd4_write(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_write
*write
)
489 struct nfs4_stateid
*stp
;
490 stateid_t
*stateid
= &write
->wr_stateid
;
494 /* no need to check permission - this will be done in nfsd_write() */
496 if (write
->wr_offset
>= OFFSET_MAX
)
500 if (ZERO_STATEID(stateid
) || ONE_STATEID(stateid
)) {
501 dprintk("NFSD: nfsd4_write: zero stateid...\n");
502 if ((status
= nfs4_share_conflict(current_fh
, NFS4_SHARE_DENY_WRITE
))) {
503 dprintk("NFSD: nfsd4_write: conflicting share reservation!\n");
508 if ((status
= nfs4_preprocess_stateid_op(current_fh
, stateid
,
510 dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
514 status
= nfserr_openmode
;
515 if (!(stp
->st_share_access
& NFS4_SHARE_ACCESS_WRITE
)) {
516 dprintk("NFSD: nfsd4_write: file not open for write!\n");
521 nfsd4_unlock_state();
522 write
->wr_bytes_written
= write
->wr_buflen
;
523 write
->wr_how_written
= write
->wr_stable_how
;
524 p
= (u32
*)write
->wr_verifier
;
525 *p
++ = nfssvc_boot
.tv_sec
;
526 *p
++ = nfssvc_boot
.tv_usec
;
528 return (nfsd_write(rqstp
, current_fh
, write
->wr_offset
,
529 write
->wr_vec
, write
->wr_vlen
, write
->wr_buflen
,
530 &write
->wr_how_written
));
532 nfsd4_unlock_state();
536 /* This routine never returns NFS_OK! If there are no other errors, it
537 * will return NFSERR_SAME or NFSERR_NOT_SAME depending on whether the
538 * attributes matched. VERIFY is implemented by mapping NFSERR_SAME
539 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK.
542 nfsd4_verify(struct svc_rqst
*rqstp
, struct svc_fh
*current_fh
, struct nfsd4_verify
*verify
)
548 status
= fh_verify(rqstp
, current_fh
, 0, MAY_NOP
);
552 if ((verify
->ve_bmval
[0] & ~NFSD_SUPPORTED_ATTRS_WORD0
)
553 || (verify
->ve_bmval
[1] & ~NFSD_SUPPORTED_ATTRS_WORD1
))
554 return nfserr_notsupp
;
555 if (verify
->ve_bmval
[1] & NFSD_WRITEONLY_ATTRS_WORD1
)
557 if (verify
->ve_attrlen
& 3)
561 * bitmap_len(1) + bitmap(2) + attr_len(1) = 4
563 count
= 4 + (verify
->ve_attrlen
>> 2);
564 buf
= kmalloc(count
<< 2, GFP_KERNEL
);
566 return nfserr_resource
;
568 status
= nfsd4_encode_fattr(current_fh
, current_fh
->fh_export
,
569 current_fh
->fh_dentry
, buf
,
570 &count
, verify
->ve_bmval
);
572 /* this means that nfsd4_encode_fattr() ran out of space */
573 if (status
== nfserr_resource
&& count
== 0)
574 status
= nfserr_not_same
;
579 status
= nfserr_not_same
;
580 if (ntohl(*p
++) != verify
->ve_attrlen
)
582 if (!memcmp(p
, verify
->ve_attrval
, verify
->ve_attrlen
))
583 status
= nfserr_same
;
594 nfsd4_proc_null(struct svc_rqst
*rqstp
, void *argp
, void *resp
)
604 nfsd4_proc_compound(struct svc_rqst
*rqstp
,
605 struct nfsd4_compoundargs
*args
,
606 struct nfsd4_compoundres
*resp
)
609 struct svc_fh current_fh
;
610 struct svc_fh save_fh
;
611 int slack_space
; /* in words, not bytes! */
614 fh_init(¤t_fh
, NFS4_FHSIZE
);
615 fh_init(&save_fh
, NFS4_FHSIZE
);
617 resp
->xbuf
= &rqstp
->rq_res
;
618 resp
->p
= rqstp
->rq_res
.head
[0].iov_base
+ rqstp
->rq_res
.head
[0].iov_len
;
619 resp
->tagp
= resp
->p
;
620 /* reserve space for: taglen, tag, and opcnt */
621 resp
->p
+= 2 + XDR_QUADLEN(args
->taglen
);
622 resp
->end
= rqstp
->rq_res
.head
[0].iov_base
+ PAGE_SIZE
;
623 resp
->taglen
= args
->taglen
;
624 resp
->tag
= args
->tag
;
629 * According to RFC3010, this takes precedence over all other errors.
631 status
= nfserr_minor_vers_mismatch
;
632 if (args
->minorversion
> NFSD_SUPPORTED_MINOR_VERSION
)
636 while (!status
&& resp
->opcnt
< args
->opcnt
) {
637 op
= &args
->ops
[resp
->opcnt
++];
640 * The XDR decode routines may have pre-set op->status;
641 * for example, if there is a miscellaneous XDR error
642 * it will be set to nfserr_bad_xdr.
647 /* We must be able to encode a successful response to
648 * this operation, with enough room left over to encode a
649 * failed response to the next operation. If we don't
650 * have enough room, fail with ERR_RESOURCE.
652 /* FIXME - is slack_space *really* words, or bytes??? - neilb */
653 slack_space
= (char *)resp
->end
- (char *)resp
->p
;
654 if (slack_space
< COMPOUND_SLACK_SPACE
+ COMPOUND_ERR_SLACK_SPACE
) {
655 BUG_ON(slack_space
< COMPOUND_ERR_SLACK_SPACE
);
656 op
->status
= nfserr_resource
;
662 op
->status
= nfsd4_access(rqstp
, ¤t_fh
, &op
->u
.access
);
665 op
->status
= nfsd4_close(rqstp
, ¤t_fh
, &op
->u
.close
);
668 op
->status
= nfsd4_commit(rqstp
, ¤t_fh
, &op
->u
.commit
);
671 op
->status
= nfsd4_create(rqstp
, ¤t_fh
, &op
->u
.create
);
674 op
->status
= nfsd4_getattr(rqstp
, ¤t_fh
, &op
->u
.getattr
);
677 op
->status
= nfsd4_getfh(¤t_fh
, &op
->u
.getfh
);
680 op
->status
= nfsd4_link(rqstp
, ¤t_fh
, &save_fh
, &op
->u
.link
);
683 op
->status
= nfsd4_lookup(rqstp
, ¤t_fh
, &op
->u
.lookup
);
686 op
->status
= nfsd4_lookupp(rqstp
, ¤t_fh
);
689 op
->status
= nfsd4_verify(rqstp
, ¤t_fh
, &op
->u
.nverify
);
690 if (op
->status
== nfserr_not_same
)
694 op
->status
= nfsd4_open(rqstp
, ¤t_fh
, &op
->u
.open
);
696 case OP_OPEN_CONFIRM
:
697 op
->status
= nfsd4_open_confirm(rqstp
, ¤t_fh
, &op
->u
.open_confirm
);
699 case OP_OPEN_DOWNGRADE
:
700 op
->status
= nfsd4_open_downgrade(rqstp
, ¤t_fh
, &op
->u
.open_downgrade
);
703 op
->status
= nfsd4_putfh(rqstp
, ¤t_fh
, &op
->u
.putfh
);
706 op
->status
= nfsd4_putrootfh(rqstp
, ¤t_fh
);
709 op
->status
= nfsd4_read(rqstp
, ¤t_fh
, &op
->u
.read
);
712 op
->status
= nfsd4_readdir(rqstp
, ¤t_fh
, &op
->u
.readdir
);
715 op
->status
= nfsd4_readlink(rqstp
, ¤t_fh
, &op
->u
.readlink
);
718 op
->status
= nfsd4_remove(rqstp
, ¤t_fh
, &op
->u
.remove
);
721 op
->status
= nfsd4_rename(rqstp
, ¤t_fh
, &save_fh
, &op
->u
.rename
);
724 op
->status
= nfsd4_renew(&op
->u
.renew
);
727 op
->status
= nfsd4_restorefh(¤t_fh
, &save_fh
);
730 op
->status
= nfsd4_savefh(¤t_fh
, &save_fh
);
733 op
->status
= nfsd4_setattr(rqstp
, ¤t_fh
, &op
->u
.setattr
);
736 op
->status
= nfsd4_setclientid(rqstp
, &op
->u
.setclientid
);
738 case OP_SETCLIENTID_CONFIRM
:
739 op
->status
= nfsd4_setclientid_confirm(rqstp
, &op
->u
.setclientid_confirm
);
742 op
->status
= nfsd4_verify(rqstp
, ¤t_fh
, &op
->u
.verify
);
743 if (op
->status
== nfserr_same
)
747 op
->status
= nfsd4_write(rqstp
, ¤t_fh
, &op
->u
.write
);
750 BUG_ON(op
->status
== nfs_ok
);
755 nfsd4_encode_operation(resp
, op
);
760 if (args
->ops
!= args
->iops
) {
762 args
->ops
= args
->iops
;
768 while (args
->to_free
) {
769 struct tmpbuf
*tb
= args
->to_free
;
770 args
->to_free
= tb
->next
;
779 #define nfs4svc_decode_voidargs NULL
780 #define nfs4svc_release_void NULL
781 #define nfsd4_voidres nfsd4_voidargs
782 #define nfs4svc_release_compound NULL
783 struct nfsd4_voidargs
{ int dummy
; };
785 #define PROC(name, argt, rest, relt, cache, respsize) \
786 { (svc_procfunc) nfsd4_proc_##name, \
787 (kxdrproc_t) nfs4svc_decode_##argt##args, \
788 (kxdrproc_t) nfs4svc_encode_##rest##res, \
789 (kxdrproc_t) nfs4svc_release_##relt, \
790 sizeof(struct nfsd4_##argt##args), \
791 sizeof(struct nfsd4_##rest##res), \
798 * TODO: At the present time, the NFSv4 server does not do XID caching
799 * of requests. Implementing XID caching would not be a serious problem,
800 * although it would require a mild change in interfaces since one
801 * doesn't know whether an NFSv4 request is idempotent until after the
802 * XDR decode. However, XID caching totally confuses pynfs (Peter
803 * Astrand's regression testsuite for NFSv4 servers), which reuses
804 * XID's liberally, so I've left it unimplemented until pynfs generates
807 static struct svc_procedure nfsd_procedures4
[2] = {
808 PROC(null
, void, void, void, RC_NOCACHE
, 1),
809 PROC(compound
, compound
, compound
, compound
, RC_NOCACHE
, NFSD_BUFSIZE
)
812 struct svc_version nfsd_version4
= {
815 .vs_proc
= nfsd_procedures4
,
816 .vs_dispatch
= nfsd_dispatch
,
817 .vs_xdrsize
= NFS4_SVC_XDRSIZE
,