4 * Server-side procedures for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
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>
55 #include <linux/nfs4_acl.h>
57 #define NFSDDBG_FACILITY NFSDDBG_PROC
60 fh_dup2(struct svc_fh *dst, struct svc_fh *src)
65 cache_get(&src->fh_export->h);
70 do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
74 if (open->op_truncate &&
75 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
79 if (open->op_share_access & NFS4_SHARE_ACCESS_READ)
81 if (open->op_share_deny & NFS4_SHARE_ACCESS_WRITE)
82 accmode |= (MAY_WRITE | MAY_TRUNC);
83 accmode |= MAY_OWNER_OVERRIDE;
85 status = fh_verify(rqstp, current_fh, S_IFREG, accmode);
91 do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
96 fh_init(&resfh, NFS4_FHSIZE);
97 open->op_truncate = 0;
99 if (open->op_create) {
101 * Note: create modes (UNCHECKED,GUARDED...) are the same
104 status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data,
105 open->op_fname.len, &open->op_iattr,
106 &resfh, open->op_createmode,
107 (u32 *)open->op_verf.data, &open->op_truncate);
110 status = nfsd_lookup(rqstp, current_fh,
111 open->op_fname.data, open->op_fname.len, &resfh);
112 fh_unlock(current_fh);
116 set_change_info(&open->op_cinfo, current_fh);
118 /* set reply cache */
119 fh_dup2(current_fh, &resfh);
120 open->op_stateowner->so_replay.rp_openfh_len =
121 resfh.fh_handle.fh_size;
122 memcpy(open->op_stateowner->so_replay.rp_openfh,
123 &resfh.fh_handle.fh_base,
124 resfh.fh_handle.fh_size);
126 status = do_open_permission(rqstp, current_fh, open);
134 do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
138 /* Only reclaims from previously confirmed clients are valid */
139 if ((status = nfs4_check_open_reclaim(&open->op_clientid)))
142 /* We don't know the target directory, and therefore can not
143 * set the change info
146 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info));
148 /* set replay cache */
149 open->op_stateowner->so_replay.rp_openfh_len = current_fh->fh_handle.fh_size;
150 memcpy(open->op_stateowner->so_replay.rp_openfh,
151 ¤t_fh->fh_handle.fh_base,
152 current_fh->fh_handle.fh_size);
154 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
155 (open->op_iattr.ia_size == 0);
157 status = do_open_permission(rqstp, current_fh, open);
164 nfsd4_open(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
167 dprintk("NFSD: nfsd4_open filename %.*s op_stateowner %p\n",
168 (int)open->op_fname.len, open->op_fname.data,
169 open->op_stateowner);
171 if (nfs4_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
174 if (!nfs4_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
175 return nfserr_no_grace;
177 /* This check required by spec. */
178 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
183 /* check seqid for replay. set nfs4_owner */
184 status = nfsd4_process_open1(open);
185 if (status == NFSERR_REPLAY_ME) {
186 struct nfs4_replay *rp = &open->op_stateowner->so_replay;
188 current_fh->fh_handle.fh_size = rp->rp_openfh_len;
189 memcpy(¤t_fh->fh_handle.fh_base, rp->rp_openfh,
191 status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
193 dprintk("nfsd4_open: replay failed"
194 " restoring previous filehandle\n");
196 status = NFSERR_REPLAY_ME;
200 switch (open->op_claim_type) {
201 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
202 status = nfserr_inval;
206 case NFS4_OPEN_CLAIM_NULL:
208 * (1) set CURRENT_FH to the file being opened,
209 * creating it if necessary, (2) set open->op_cinfo,
210 * (3) set open->op_truncate if the file is to be
211 * truncated after opening, (4) do permission checking.
213 status = do_open_lookup(rqstp, current_fh, open);
217 case NFS4_OPEN_CLAIM_PREVIOUS:
219 * The CURRENT_FH is already set to the file being
220 * opened. (1) set open->op_cinfo, (2) set
221 * open->op_truncate if the file is to be truncated
222 * after opening, (3) do permission checking.
224 status = do_open_fhandle(rqstp, current_fh, open);
228 case NFS4_OPEN_CLAIM_DELEGATE_PREV:
229 printk("NFSD: unsupported OPEN claim type %d\n",
230 open->op_claim_type);
231 status = nfserr_notsupp;
234 printk("NFSD: Invalid OPEN claim type %d\n",
235 open->op_claim_type);
236 status = nfserr_inval;
240 * nfsd4_process_open2() does the actual opening of the file. If
241 * successful, it (1) truncates the file if open->op_truncate was
242 * set, (2) sets open->op_stateid, (3) sets open->op_delegation.
244 status = nfsd4_process_open2(rqstp, current_fh, open);
246 if (open->op_stateowner)
247 nfs4_get_stateowner(open->op_stateowner);
253 * filehandle-manipulating ops.
256 nfsd4_getfh(struct svc_fh *current_fh, struct svc_fh **getfh)
258 if (!current_fh->fh_dentry)
259 return nfserr_nofilehandle;
266 nfsd4_putfh(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_putfh *putfh)
269 current_fh->fh_handle.fh_size = putfh->pf_fhlen;
270 memcpy(¤t_fh->fh_handle.fh_base, putfh->pf_fhval, putfh->pf_fhlen);
271 return fh_verify(rqstp, current_fh, 0, MAY_NOP);
275 nfsd4_putrootfh(struct svc_rqst *rqstp, struct svc_fh *current_fh)
280 status = exp_pseudoroot(rqstp->rq_client, current_fh,
283 status = nfserrno(nfsd_setuser(rqstp, current_fh->fh_export));
288 nfsd4_restorefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
290 if (!save_fh->fh_dentry)
291 return nfserr_restorefh;
293 fh_dup2(current_fh, save_fh);
298 nfsd4_savefh(struct svc_fh *current_fh, struct svc_fh *save_fh)
300 if (!current_fh->fh_dentry)
301 return nfserr_nofilehandle;
303 fh_dup2(save_fh, current_fh);
311 nfsd4_access(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_access *access)
313 if (access->ac_req_access & ~NFS3_ACCESS_FULL)
316 access->ac_resp_access = access->ac_req_access;
317 return nfsd_access(rqstp, current_fh, &access->ac_resp_access, &access->ac_supported);
321 nfsd4_commit(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_commit *commit)
325 u32 *p = (u32 *)commit->co_verf.data;
326 *p++ = nfssvc_boot.tv_sec;
327 *p++ = nfssvc_boot.tv_usec;
329 status = nfsd_commit(rqstp, current_fh, commit->co_offset, commit->co_count);
330 if (status == nfserr_symlink)
331 status = nfserr_inval;
336 nfsd4_create(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_create *create)
342 fh_init(&resfh, NFS4_FHSIZE);
344 status = fh_verify(rqstp, current_fh, S_IFDIR, MAY_CREATE);
345 if (status == nfserr_symlink)
346 status = nfserr_notdir;
350 switch (create->cr_type) {
352 /* ugh! we have to null-terminate the linktext, or
353 * vfs_symlink() will choke. it is always safe to
354 * null-terminate by brute force, since at worst we
355 * will overwrite the first byte of the create namelen
356 * in the XDR buffer, which has already been extracted
359 create->cr_linkname[create->cr_linklen] = 0;
361 status = nfsd_symlink(rqstp, current_fh, create->cr_name,
362 create->cr_namelen, create->cr_linkname,
363 create->cr_linklen, &resfh, &create->cr_iattr);
367 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2);
368 if (MAJOR(rdev) != create->cr_specdata1 ||
369 MINOR(rdev) != create->cr_specdata2)
371 status = nfsd_create(rqstp, current_fh, create->cr_name,
372 create->cr_namelen, &create->cr_iattr,
373 S_IFBLK, rdev, &resfh);
377 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2);
378 if (MAJOR(rdev) != create->cr_specdata1 ||
379 MINOR(rdev) != create->cr_specdata2)
381 status = nfsd_create(rqstp, current_fh, create->cr_name,
382 create->cr_namelen, &create->cr_iattr,
383 S_IFCHR, rdev, &resfh);
387 status = nfsd_create(rqstp, current_fh, create->cr_name,
388 create->cr_namelen, &create->cr_iattr,
389 S_IFSOCK, 0, &resfh);
393 status = nfsd_create(rqstp, current_fh, create->cr_name,
394 create->cr_namelen, &create->cr_iattr,
399 create->cr_iattr.ia_valid &= ~ATTR_SIZE;
400 status = nfsd_create(rqstp, current_fh, create->cr_name,
401 create->cr_namelen, &create->cr_iattr,
406 status = nfserr_badtype;
410 fh_unlock(current_fh);
411 set_change_info(&create->cr_cinfo, current_fh);
412 fh_dup2(current_fh, &resfh);
420 nfsd4_getattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_getattr *getattr)
424 status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
428 if (getattr->ga_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)
431 getattr->ga_bmval[0] &= NFSD_SUPPORTED_ATTRS_WORD0;
432 getattr->ga_bmval[1] &= NFSD_SUPPORTED_ATTRS_WORD1;
434 getattr->ga_fhp = current_fh;
439 nfsd4_link(struct svc_rqst *rqstp, struct svc_fh *current_fh,
440 struct svc_fh *save_fh, struct nfsd4_link *link)
442 int status = nfserr_nofilehandle;
444 if (!save_fh->fh_dentry)
446 status = nfsd_link(rqstp, current_fh, link->li_name, link->li_namelen, save_fh);
448 set_change_info(&link->li_cinfo, current_fh);
453 nfsd4_lookupp(struct svc_rqst *rqstp, struct svc_fh *current_fh)
455 struct svc_fh tmp_fh;
458 fh_init(&tmp_fh, NFS4_FHSIZE);
459 if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh,
460 &rqstp->rq_chandle)) != 0)
462 if (tmp_fh.fh_dentry == current_fh->fh_dentry) {
467 return nfsd_lookup(rqstp, current_fh, "..", 2, current_fh);
471 nfsd4_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lookup *lookup)
473 return nfsd_lookup(rqstp, current_fh, lookup->lo_name, lookup->lo_len, current_fh);
477 nfsd4_read(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_read *read)
480 struct file *filp = NULL;
482 /* no need to check permission - this will be done in nfsd_read() */
484 if (read->rd_offset >= OFFSET_MAX)
489 if ((status = nfs4_preprocess_stateid_op(current_fh, &read->rd_stateid,
490 CHECK_FH | RD_STATE, &filp))) {
491 dprintk("NFSD: nfsd4_read: couldn't process stateid!\n");
497 read->rd_rqstp = rqstp;
498 read->rd_fhp = current_fh;
499 read->rd_filp = filp;
504 nfsd4_readdir(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readdir *readdir)
506 u64 cookie = readdir->rd_cookie;
507 static const nfs4_verifier zeroverf;
509 /* no need to check permission - this will be done in nfsd_readdir() */
511 if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)
514 readdir->rd_bmval[0] &= NFSD_SUPPORTED_ATTRS_WORD0;
515 readdir->rd_bmval[1] &= NFSD_SUPPORTED_ATTRS_WORD1;
517 if ((cookie > ~(u32)0) || (cookie == 1) || (cookie == 2) ||
518 (cookie == 0 && memcmp(readdir->rd_verf.data, zeroverf.data, NFS4_VERIFIER_SIZE)))
519 return nfserr_bad_cookie;
521 readdir->rd_rqstp = rqstp;
522 readdir->rd_fhp = current_fh;
527 nfsd4_readlink(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_readlink *readlink)
529 readlink->rl_rqstp = rqstp;
530 readlink->rl_fhp = current_fh;
535 nfsd4_remove(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_remove *remove)
539 status = nfsd_unlink(rqstp, current_fh, 0, remove->rm_name, remove->rm_namelen);
540 if (status == nfserr_symlink)
541 return nfserr_notdir;
543 fh_unlock(current_fh);
544 set_change_info(&remove->rm_cinfo, current_fh);
550 nfsd4_rename(struct svc_rqst *rqstp, struct svc_fh *current_fh,
551 struct svc_fh *save_fh, struct nfsd4_rename *rename)
553 int status = nfserr_nofilehandle;
555 if (!save_fh->fh_dentry)
557 status = nfsd_rename(rqstp, save_fh, rename->rn_sname,
558 rename->rn_snamelen, current_fh,
559 rename->rn_tname, rename->rn_tnamelen);
561 /* the underlying filesystem returns different error's than required
562 * by NFSv4. both save_fh and current_fh have been verified.. */
563 if (status == nfserr_isdir)
564 status = nfserr_exist;
565 else if ((status == nfserr_notdir) &&
566 (S_ISDIR(save_fh->fh_dentry->d_inode->i_mode) &&
567 S_ISDIR(current_fh->fh_dentry->d_inode->i_mode)))
568 status = nfserr_exist;
569 else if (status == nfserr_symlink)
570 status = nfserr_notdir;
573 set_change_info(&rename->rn_sinfo, current_fh);
574 set_change_info(&rename->rn_tinfo, save_fh);
580 nfsd4_setattr(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_setattr *setattr)
584 if (!current_fh->fh_dentry)
585 return nfserr_nofilehandle;
588 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
590 if ((status = nfs4_preprocess_stateid_op(current_fh,
591 &setattr->sa_stateid,
592 CHECK_FH | WR_STATE, NULL))) {
593 dprintk("NFSD: nfsd4_setattr: couldn't process stateid!\n");
599 if (setattr->sa_acl != NULL)
600 status = nfsd4_set_nfs4_acl(rqstp, current_fh, setattr->sa_acl);
603 status = nfsd_setattr(rqstp, current_fh, &setattr->sa_iattr,
613 nfsd4_write(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_write *write)
615 stateid_t *stateid = &write->wr_stateid;
616 struct file *filp = NULL;
620 /* no need to check permission - this will be done in nfsd_write() */
622 if (write->wr_offset >= OFFSET_MAX)
626 if ((status = nfs4_preprocess_stateid_op(current_fh, stateid,
627 CHECK_FH | WR_STATE, &filp))) {
628 dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
633 write->wr_bytes_written = write->wr_buflen;
634 write->wr_how_written = write->wr_stable_how;
635 p = (u32 *)write->wr_verifier.data;
636 *p++ = nfssvc_boot.tv_sec;
637 *p++ = nfssvc_boot.tv_usec;
639 status = nfsd_write(rqstp, current_fh, filp, write->wr_offset,
640 write->wr_vec, write->wr_vlen, write->wr_buflen,
641 &write->wr_how_written);
643 if (status == nfserr_symlink)
644 status = nfserr_inval;
651 /* This routine never returns NFS_OK! If there are no other errors, it
652 * will return NFSERR_SAME or NFSERR_NOT_SAME depending on whether the
653 * attributes matched. VERIFY is implemented by mapping NFSERR_SAME
654 * to NFS_OK after the call; NVERIFY by mapping NFSERR_NOT_SAME to NFS_OK.
657 nfsd4_verify(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_verify *verify)
663 status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
667 if ((verify->ve_bmval[0] & ~NFSD_SUPPORTED_ATTRS_WORD0)
668 || (verify->ve_bmval[1] & ~NFSD_SUPPORTED_ATTRS_WORD1))
669 return nfserr_attrnotsupp;
670 if ((verify->ve_bmval[0] & FATTR4_WORD0_RDATTR_ERROR)
671 || (verify->ve_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1))
673 if (verify->ve_attrlen & 3)
677 * bitmap_len(1) + bitmap(2) + attr_len(1) = 4
679 count = 4 + (verify->ve_attrlen >> 2);
680 buf = kmalloc(count << 2, GFP_KERNEL);
682 return nfserr_resource;
684 status = nfsd4_encode_fattr(current_fh, current_fh->fh_export,
685 current_fh->fh_dentry, buf,
686 &count, verify->ve_bmval,
689 /* this means that nfsd4_encode_fattr() ran out of space */
690 if (status == nfserr_resource && count == 0)
691 status = nfserr_not_same;
696 status = nfserr_not_same;
697 if (ntohl(*p++) != verify->ve_attrlen)
699 if (!memcmp(p, verify->ve_attrval, verify->ve_attrlen))
700 status = nfserr_same;
711 nfsd4_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
721 nfsd4_proc_compound(struct svc_rqst *rqstp,
722 struct nfsd4_compoundargs *args,
723 struct nfsd4_compoundres *resp)
726 struct svc_fh *current_fh = NULL;
727 struct svc_fh *save_fh = NULL;
728 struct nfs4_stateowner *replay_owner = NULL;
729 int slack_space; /* in words, not bytes! */
732 status = nfserr_resource;
733 current_fh = kmalloc(sizeof(*current_fh), GFP_KERNEL);
734 if (current_fh == NULL)
736 fh_init(current_fh, NFS4_FHSIZE);
737 save_fh = kmalloc(sizeof(*save_fh), GFP_KERNEL);
740 fh_init(save_fh, NFS4_FHSIZE);
742 resp->xbuf = &rqstp->rq_res;
743 resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len;
744 resp->tagp = resp->p;
745 /* reserve space for: taglen, tag, and opcnt */
746 resp->p += 2 + XDR_QUADLEN(args->taglen);
747 resp->end = rqstp->rq_res.head[0].iov_base + PAGE_SIZE;
748 resp->taglen = args->taglen;
749 resp->tag = args->tag;
754 * According to RFC3010, this takes precedence over all other errors.
756 status = nfserr_minor_vers_mismatch;
757 if (args->minorversion > NFSD_SUPPORTED_MINOR_VERSION)
761 while (!status && resp->opcnt < args->opcnt) {
762 op = &args->ops[resp->opcnt++];
765 * The XDR decode routines may have pre-set op->status;
766 * for example, if there is a miscellaneous XDR error
767 * it will be set to nfserr_bad_xdr.
772 /* We must be able to encode a successful response to
773 * this operation, with enough room left over to encode a
774 * failed response to the next operation. If we don't
775 * have enough room, fail with ERR_RESOURCE.
777 /* FIXME - is slack_space *really* words, or bytes??? - neilb */
778 slack_space = (char *)resp->end - (char *)resp->p;
779 if (slack_space < COMPOUND_SLACK_SPACE + COMPOUND_ERR_SLACK_SPACE) {
780 BUG_ON(slack_space < COMPOUND_ERR_SLACK_SPACE);
781 op->status = nfserr_resource;
785 /* All operations except RENEW, SETCLIENTID, RESTOREFH
786 * SETCLIENTID_CONFIRM, PUTFH and PUTROOTFH
787 * require a valid current filehandle
789 * SETATTR NOFILEHANDLE error handled in nfsd4_setattr
790 * due to required returned bitmap argument
792 if ((!current_fh->fh_dentry) &&
793 !((op->opnum == OP_PUTFH) || (op->opnum == OP_PUTROOTFH) ||
794 (op->opnum == OP_SETCLIENTID) ||
795 (op->opnum == OP_SETCLIENTID_CONFIRM) ||
796 (op->opnum == OP_RENEW) || (op->opnum == OP_RESTOREFH) ||
797 (op->opnum == OP_RELEASE_LOCKOWNER) ||
798 (op->opnum == OP_SETATTR))) {
799 op->status = nfserr_nofilehandle;
804 op->status = nfsd4_access(rqstp, current_fh, &op->u.access);
807 op->status = nfsd4_close(rqstp, current_fh, &op->u.close);
808 replay_owner = op->u.close.cl_stateowner;
811 op->status = nfsd4_commit(rqstp, current_fh, &op->u.commit);
814 op->status = nfsd4_create(rqstp, current_fh, &op->u.create);
817 op->status = nfsd4_delegreturn(rqstp, current_fh, &op->u.delegreturn);
820 op->status = nfsd4_getattr(rqstp, current_fh, &op->u.getattr);
823 op->status = nfsd4_getfh(current_fh, &op->u.getfh);
826 op->status = nfsd4_link(rqstp, current_fh, save_fh, &op->u.link);
829 op->status = nfsd4_lock(rqstp, current_fh, &op->u.lock);
830 replay_owner = op->u.lock.lk_stateowner;
833 op->status = nfsd4_lockt(rqstp, current_fh, &op->u.lockt);
836 op->status = nfsd4_locku(rqstp, current_fh, &op->u.locku);
837 replay_owner = op->u.locku.lu_stateowner;
840 op->status = nfsd4_lookup(rqstp, current_fh, &op->u.lookup);
843 op->status = nfsd4_lookupp(rqstp, current_fh);
846 op->status = nfsd4_verify(rqstp, current_fh, &op->u.nverify);
847 if (op->status == nfserr_not_same)
851 op->status = nfsd4_open(rqstp, current_fh, &op->u.open);
852 replay_owner = op->u.open.op_stateowner;
854 case OP_OPEN_CONFIRM:
855 op->status = nfsd4_open_confirm(rqstp, current_fh, &op->u.open_confirm);
856 replay_owner = op->u.open_confirm.oc_stateowner;
858 case OP_OPEN_DOWNGRADE:
859 op->status = nfsd4_open_downgrade(rqstp, current_fh, &op->u.open_downgrade);
860 replay_owner = op->u.open_downgrade.od_stateowner;
863 op->status = nfsd4_putfh(rqstp, current_fh, &op->u.putfh);
866 op->status = nfsd4_putrootfh(rqstp, current_fh);
869 op->status = nfsd4_read(rqstp, current_fh, &op->u.read);
872 op->status = nfsd4_readdir(rqstp, current_fh, &op->u.readdir);
875 op->status = nfsd4_readlink(rqstp, current_fh, &op->u.readlink);
878 op->status = nfsd4_remove(rqstp, current_fh, &op->u.remove);
881 op->status = nfsd4_rename(rqstp, current_fh, save_fh, &op->u.rename);
884 op->status = nfsd4_renew(&op->u.renew);
887 op->status = nfsd4_restorefh(current_fh, save_fh);
890 op->status = nfsd4_savefh(current_fh, save_fh);
893 op->status = nfsd4_setattr(rqstp, current_fh, &op->u.setattr);
896 op->status = nfsd4_setclientid(rqstp, &op->u.setclientid);
898 case OP_SETCLIENTID_CONFIRM:
899 op->status = nfsd4_setclientid_confirm(rqstp, &op->u.setclientid_confirm);
902 op->status = nfsd4_verify(rqstp, current_fh, &op->u.verify);
903 if (op->status == nfserr_same)
907 op->status = nfsd4_write(rqstp, current_fh, &op->u.write);
909 case OP_RELEASE_LOCKOWNER:
910 op->status = nfsd4_release_lockowner(rqstp, &op->u.release_lockowner);
913 BUG_ON(op->status == nfs_ok);
918 if (op->status == NFSERR_REPLAY_ME) {
919 op->replay = &replay_owner->so_replay;
920 nfsd4_encode_replay(resp, op);
921 status = op->status = op->replay->rp_status;
923 nfsd4_encode_operation(resp, op);
926 if (replay_owner && (replay_owner != (void *)(-1))) {
927 nfs4_put_stateowner(replay_owner);
933 nfsd4_release_compoundargs(args);
943 #define nfs4svc_decode_voidargs NULL
944 #define nfs4svc_release_void NULL
945 #define nfsd4_voidres nfsd4_voidargs
946 #define nfs4svc_release_compound NULL
947 struct nfsd4_voidargs { int dummy; };
949 #define PROC(name, argt, rest, relt, cache, respsize) \
950 { (svc_procfunc) nfsd4_proc_##name, \
951 (kxdrproc_t) nfs4svc_decode_##argt##args, \
952 (kxdrproc_t) nfs4svc_encode_##rest##res, \
953 (kxdrproc_t) nfs4svc_release_##relt, \
954 sizeof(struct nfsd4_##argt##args), \
955 sizeof(struct nfsd4_##rest##res), \
962 * TODO: At the present time, the NFSv4 server does not do XID caching
963 * of requests. Implementing XID caching would not be a serious problem,
964 * although it would require a mild change in interfaces since one
965 * doesn't know whether an NFSv4 request is idempotent until after the
966 * XDR decode. However, XID caching totally confuses pynfs (Peter
967 * Astrand's regression testsuite for NFSv4 servers), which reuses
968 * XID's liberally, so I've left it unimplemented until pynfs generates
971 static struct svc_procedure nfsd_procedures4[2] = {
972 PROC(null, void, void, void, RC_NOCACHE, 1),
973 PROC(compound, compound, compound, compound, RC_NOCACHE, NFSD_BUFSIZE)
976 struct svc_version nfsd_version4 = {
979 .vs_proc = nfsd_procedures4,
980 .vs_dispatch = nfsd_dispatch,
981 .vs_xdrsize = NFS4_SVC_XDRSIZE,