Lines Matching +full:compound +full:- +full:device
2 * Server-side procedures for NFSv4.
85 struct dentry *dentry = cstate->current_fh.fh_dentry; in check_attr_support()
86 struct svc_export *exp = cstate->current_fh.fh_export; in check_attr_support()
88 if (!nfsd_attrs_supported(cstate->minorversion, bmval)) in check_attr_support()
93 !(exp->ex_flags & NFSEXP_SECURITY_LABEL)) in check_attr_support()
109 if (open->op_create == NFS4_OPEN_CREATE) { in nfsd4_check_open_attributes()
110 if (open->op_createmode == NFS4_CREATE_UNCHECKED in nfsd4_check_open_attributes()
111 || open->op_createmode == NFS4_CREATE_GUARDED) in nfsd4_check_open_attributes()
113 open->op_bmval, nfsd_attrmask); in nfsd4_check_open_attributes()
114 else if (open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1) in nfsd4_check_open_attributes()
116 open->op_bmval, nfsd41_ex_attrmask); in nfsd4_check_open_attributes()
125 return open->op_create == NFS4_OPEN_CREATE in is_create_with_attrs()
126 && (open->op_createmode == NFS4_CREATE_UNCHECKED in is_create_with_attrs()
127 || open->op_createmode == NFS4_CREATE_GUARDED in is_create_with_attrs()
128 || open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1); in is_create_with_attrs()
135 dget(src->fh_dentry); in fh_dup2()
136 if (src->fh_export) in fh_dup2()
137 exp_get(src->fh_export); in fh_dup2()
145 if (open->op_truncate && in do_open_permission()
146 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) in do_open_permission()
151 if (open->op_share_access & NFS4_SHARE_ACCESS_READ) in do_open_permission()
153 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) in do_open_permission()
155 if (open->op_share_deny & NFS4_SHARE_DENY_READ) in do_open_permission()
163 umode_t mode = d_inode(fh->fh_dentry)->i_mode; in nfsd_check_obj_isreg()
170 * Using err_symlink as our catch-all case may look odd; but in nfsd_check_obj_isreg()
183 fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh, in nfsd4_set_open_owner_reply_cache()
184 &resfh->fh_handle); in nfsd4_set_open_owner_reply_cache()
202 switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { in nfsd4_vfs_create()
213 path.mnt = fhp->fh_export->ex_path.mnt; in nfsd4_vfs_create()
215 filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, in nfsd4_vfs_create()
220 open->op_filp = filp; in nfsd4_vfs_create()
235 struct iattr *iap = &open->op_iattr; in nfsd4_create_file()
238 .na_seclabel = &open->op_label, in nfsd4_create_file()
246 if (isdotent(open->op_fname, open->op_fnamelen)) in nfsd4_create_file()
248 if (!(iap->ia_valid & ATTR_MODE)) in nfsd4_create_file()
249 iap->ia_mode = 0; in nfsd4_create_file()
254 parent = fhp->fh_dentry; in nfsd4_create_file()
262 nfsd4_acl_to_attr(NF4REG, open->op_acl, &attrs); in nfsd4_create_file()
266 child = lookup_one_len(open->op_fname, parent, open->op_fnamelen); in nfsd4_create_file()
278 status = fh_compose(resfhp, fhp->fh_export, child, fhp); in nfsd4_create_file()
284 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
285 u32 *verifier = (u32 *)open->op_verf.data; in nfsd4_create_file()
307 switch (open->op_createmode) { in nfsd4_create_file()
318 open->op_truncate = (iap->ia_valid & ATTR_SIZE) && in nfsd4_create_file()
319 !iap->ia_size; in nfsd4_create_file()
327 d_inode(child)->i_size == 0) { in nfsd4_create_file()
328 open->op_created = true; in nfsd4_create_file()
336 d_inode(child)->i_size == 0) { in nfsd4_create_file()
337 open->op_created = true; in nfsd4_create_file()
346 iap->ia_mode &= ~current_umask(); in nfsd4_create_file()
354 open->op_created = true; in nfsd4_create_file()
358 if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0)) in nfsd4_create_file()
359 iap->ia_valid &= ~ATTR_SIZE; in nfsd4_create_file()
360 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
361 iap->ia_valid = ATTR_MTIME | ATTR_ATIME | in nfsd4_create_file()
363 iap->ia_mtime.tv_sec = v_mtime; in nfsd4_create_file()
364 iap->ia_atime.tv_sec = v_atime; in nfsd4_create_file()
365 iap->ia_mtime.tv_nsec = 0; in nfsd4_create_file()
366 iap->ia_atime.tv_nsec = 0; in nfsd4_create_file()
373 open->op_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create_file()
375 open->op_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create_file()
386 * set_change_info - set up the change_info4 for a reply
392 * the event that we didn't get any pre-attrs, just zero out both.
397 cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); in set_change_info()
398 cinfo->before_change = fhp->fh_pre_change; in set_change_info()
399 cinfo->after_change = fhp->fh_post_change; in set_change_info()
402 * If fetching the pre-change attributes failed, then we should in set_change_info()
404 * failed to fetch post-change attributes however. in set_change_info()
406 * If we didn't get post-op attrs, just zero-out the after in set_change_info()
411 if (WARN_ON_ONCE(!fhp->fh_pre_saved)) in set_change_info()
412 cinfo->before_change = 0; in set_change_info()
413 if (!fhp->fh_post_saved) in set_change_info()
414 cinfo->after_change = cinfo->before_change + 1; in set_change_info()
420 struct svc_fh *current_fh = &cstate->current_fh; in do_open_lookup()
428 open->op_truncate = false; in do_open_lookup()
430 if (open->op_create) { in do_open_lookup()
436 * -------------+--------+-----------------+-------------------- in do_open_lookup()
446 current->fs->umask = open->op_umask; in do_open_lookup()
448 current->fs->umask = 0; in do_open_lookup()
455 if (nfsd4_create_is_exclusive(open->op_createmode) && status == 0) in do_open_lookup()
456 open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS | in do_open_lookup()
460 open->op_fname, open->op_fnamelen, *resfh); in do_open_lookup()
475 if (open->op_created || in do_open_lookup()
476 open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) in do_open_lookup()
479 set_change_info(&open->op_cinfo, current_fh); in do_open_lookup()
487 struct svc_fh *current_fh = &cstate->current_fh; in do_open_fhandle()
494 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); in do_open_fhandle()
498 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && in do_open_fhandle()
499 (open->op_iattr.ia_size == 0); in do_open_fhandle()
509 if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH) in do_open_fhandle()
519 (struct nfsd4_sessionid *)session->se_sessionid.data; in copy_clientid()
521 clid->cl_boot = sid->clientid.cl_boot; in copy_clientid()
522 clid->cl_id = sid->clientid.cl_id; in copy_clientid()
529 struct nfsd4_open *open = &u->open; in nfsd4_open()
537 (int)open->op_fnamelen, open->op_fname, in nfsd4_open()
538 open->op_openowner); in nfsd4_open()
540 open->op_filp = NULL; in nfsd4_open()
541 open->op_rqstp = rqstp; in nfsd4_open()
544 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) in nfsd4_open()
547 open->op_created = false; in nfsd4_open()
553 !test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &cstate->clp->cl_flags) && in nfsd4_open()
554 open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
558 copy_clientid(&open->op_clientid, cstate->session); in nfsd4_open()
563 struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay; in nfsd4_open()
564 fh_put(&cstate->current_fh); in nfsd4_open()
565 fh_copy_shallow(&cstate->current_fh.fh_handle, in nfsd4_open()
566 &rp->rp_openfh); in nfsd4_open()
567 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_open()
576 if (open->op_xdr_error) { in nfsd4_open()
577 status = open->op_xdr_error; in nfsd4_open()
588 if (opens_in_grace(net) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
591 if (!opens_in_grace(net) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
594 switch (open->op_claim_type) { in nfsd4_open()
602 status = nfs4_check_open_reclaim(cstate->clp); in nfsd4_open()
605 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_open()
613 resfh = &cstate->current_fh; in nfsd4_open()
625 if (status && open->op_created) in nfsd4_open()
626 pr_warn("nfsd4_process_open2 failed to open newly-created file: status=%u\n", in nfsd4_open()
629 nn->somebody_reclaimed = true; in nfsd4_open()
631 if (open->op_filp) { in nfsd4_open()
632 fput(open->op_filp); in nfsd4_open()
633 open->op_filp = NULL; in nfsd4_open()
635 if (resfh && resfh != &cstate->current_fh) { in nfsd4_open()
636 fh_dup2(&cstate->current_fh, resfh); in nfsd4_open()
646 * OPEN is the only seqid-mutating operation whose decoding can fail
647 * with a seqid-mutating error (specifically, decoding of user names in
653 struct nfsd4_open *open = &op->u.open; in nfsd4_open_omfg()
655 if (!seqid_mutating_err(ntohl(op->status))) in nfsd4_open_omfg()
656 return op->status; in nfsd4_open_omfg()
658 return op->status; in nfsd4_open_omfg()
659 open->op_xdr_error = op->status; in nfsd4_open_omfg()
660 return nfsd4_open(rqstp, cstate, &op->u); in nfsd4_open_omfg()
664 * filehandle-manipulating ops.
670 u->getfh = &cstate->current_fh; in nfsd4_getfh()
678 struct nfsd4_putfh *putfh = &u->putfh; in nfsd4_putfh()
681 fh_put(&cstate->current_fh); in nfsd4_putfh()
682 cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; in nfsd4_putfh()
683 memcpy(&cstate->current_fh.fh_handle.fh_raw, putfh->pf_fhval, in nfsd4_putfh()
684 putfh->pf_fhlen); in nfsd4_putfh()
685 ret = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_BYPASS_GSS); in nfsd4_putfh()
687 if (ret == nfserr_stale && putfh->no_verify) { in nfsd4_putfh()
688 SET_FH_FLAG(&cstate->current_fh, NFSD4_FH_FOREIGN); in nfsd4_putfh()
699 fh_put(&cstate->current_fh); in nfsd4_putrootfh()
701 return exp_pseudoroot(rqstp, &cstate->current_fh); in nfsd4_putrootfh()
708 if (!cstate->save_fh.fh_dentry) in nfsd4_restorefh()
711 fh_dup2(&cstate->current_fh, &cstate->save_fh); in nfsd4_restorefh()
713 memcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t)); in nfsd4_restorefh()
723 fh_dup2(&cstate->save_fh, &cstate->current_fh); in nfsd4_savefh()
725 memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); in nfsd4_savefh()
738 struct nfsd4_access *access = &u->access; in nfsd4_access()
742 if (cstate->minorversion >= 2) in nfsd4_access()
746 if (access->ac_req_access & ~access_full) in nfsd4_access()
749 access->ac_resp_access = access->ac_req_access; in nfsd4_access()
750 return nfsd_access(rqstp, &cstate->current_fh, &access->ac_resp_access, in nfsd4_access()
751 &access->ac_supported); in nfsd4_access()
756 __be32 *verf = (__be32 *)verifier->data; in gen_boot_verifier()
758 BUILD_BUG_ON(2*sizeof(*verf) != sizeof(verifier->data)); in gen_boot_verifier()
767 struct nfsd4_commit *commit = &u->commit; in nfsd4_commit()
771 status = nfsd_file_acquire(rqstp, &cstate->current_fh, NFSD_MAY_WRITE | in nfsd4_commit()
776 status = nfsd_commit(rqstp, &cstate->current_fh, nf, commit->co_offset, in nfsd4_commit()
777 commit->co_count, in nfsd4_commit()
778 (__be32 *)commit->co_verf.data); in nfsd4_commit()
787 struct nfsd4_create *create = &u->create; in nfsd4_create()
789 .na_iattr = &create->cr_iattr, in nfsd4_create()
790 .na_seclabel = &create->cr_label, in nfsd4_create()
798 status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); in nfsd4_create()
802 status = check_attr_support(rqstp, cstate, create->cr_bmval, in nfsd4_create()
807 status = nfsd4_acl_to_attr(create->cr_type, create->cr_acl, &attrs); in nfsd4_create()
808 current->fs->umask = create->cr_umask; in nfsd4_create()
809 switch (create->cr_type) { in nfsd4_create()
811 status = nfsd_symlink(rqstp, &cstate->current_fh, in nfsd4_create()
812 create->cr_name, create->cr_namelen, in nfsd4_create()
813 create->cr_data, &attrs, &resfh); in nfsd4_create()
818 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
819 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
820 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
822 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
823 create->cr_name, create->cr_namelen, in nfsd4_create()
829 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
830 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
831 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
833 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
834 create->cr_name, create->cr_namelen, in nfsd4_create()
839 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
840 create->cr_name, create->cr_namelen, in nfsd4_create()
845 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
846 create->cr_name, create->cr_namelen, in nfsd4_create()
851 create->cr_iattr.ia_valid &= ~ATTR_SIZE; in nfsd4_create()
852 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
853 create->cr_name, create->cr_namelen, in nfsd4_create()
865 create->cr_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create()
867 create->cr_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create()
868 set_change_info(&create->cr_cinfo, &cstate->current_fh); in nfsd4_create()
869 fh_dup2(&cstate->current_fh, &resfh); in nfsd4_create()
873 current->fs->umask = 0; in nfsd4_create()
882 struct nfsd4_getattr *getattr = &u->getattr; in nfsd4_getattr()
885 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_getattr()
889 if (getattr->ga_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_getattr()
892 getattr->ga_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_getattr()
893 getattr->ga_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_getattr()
894 getattr->ga_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_getattr()
896 getattr->ga_fhp = &cstate->current_fh; in nfsd4_getattr()
904 struct nfsd4_link *link = &u->link; in nfsd4_link()
907 status = nfsd_link(rqstp, &cstate->current_fh, in nfsd4_link()
908 link->li_name, link->li_namelen, &cstate->save_fh); in nfsd4_link()
910 set_change_info(&link->li_cinfo, &cstate->current_fh); in nfsd4_link()
923 if (tmp_fh.fh_dentry == fh->fh_dentry) { in nfsd4_do_lookupp()
935 return nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_lookupp()
942 return nfsd_lookup(rqstp, &cstate->current_fh, in nfsd4_lookup()
943 u->lookup.lo_name, u->lookup.lo_len, in nfsd4_lookup()
944 &cstate->current_fh); in nfsd4_lookup()
951 struct nfsd4_read *read = &u->read; in nfsd4_read()
954 read->rd_nf = NULL; in nfsd4_read()
956 trace_nfsd_read_start(rqstp, &cstate->current_fh, in nfsd4_read()
957 read->rd_offset, read->rd_length); in nfsd4_read()
959 read->rd_length = min_t(u32, read->rd_length, svc_max_payload(rqstp)); in nfsd4_read()
960 if (read->rd_offset > (u64)OFFSET_MAX) in nfsd4_read()
961 read->rd_offset = (u64)OFFSET_MAX; in nfsd4_read()
962 if (read->rd_offset + read->rd_length > (u64)OFFSET_MAX) in nfsd4_read()
963 read->rd_length = (u64)OFFSET_MAX - read->rd_offset; in nfsd4_read()
968 * following compound. in nfsd4_read()
971 * the client wants us to do more in this compound: in nfsd4_read()
974 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_read()
976 argp->splice_ok = false; in nfsd4_read()
980 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_read()
981 &read->rd_stateid, RD_STATE, in nfsd4_read()
982 &read->rd_nf, NULL); in nfsd4_read()
984 read->rd_rqstp = rqstp; in nfsd4_read()
985 read->rd_fhp = &cstate->current_fh; in nfsd4_read()
993 if (u->read.rd_nf) in nfsd4_read_release()
994 nfsd_file_put(u->read.rd_nf); in nfsd4_read_release()
995 trace_nfsd_read_done(u->read.rd_rqstp, u->read.rd_fhp, in nfsd4_read_release()
996 u->read.rd_offset, u->read.rd_length); in nfsd4_read_release()
1003 struct nfsd4_readdir *readdir = &u->readdir; in nfsd4_readdir()
1004 u64 cookie = readdir->rd_cookie; in nfsd4_readdir()
1007 /* no need to check permission - this will be done in nfsd_readdir() */ in nfsd4_readdir()
1009 if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_readdir()
1012 readdir->rd_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_readdir()
1013 readdir->rd_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_readdir()
1014 readdir->rd_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_readdir()
1017 (cookie == 0 && memcmp(readdir->rd_verf.data, zeroverf.data, NFS4_VERIFIER_SIZE))) in nfsd4_readdir()
1020 readdir->rd_rqstp = rqstp; in nfsd4_readdir()
1021 readdir->rd_fhp = &cstate->current_fh; in nfsd4_readdir()
1029 u->readlink.rl_rqstp = rqstp; in nfsd4_readlink()
1030 u->readlink.rl_fhp = &cstate->current_fh; in nfsd4_readlink()
1038 struct nfsd4_remove *remove = &u->remove; in nfsd4_remove()
1043 status = nfsd_unlink(rqstp, &cstate->current_fh, 0, in nfsd4_remove()
1044 remove->rm_name, remove->rm_namelen); in nfsd4_remove()
1046 set_change_info(&remove->rm_cinfo, &cstate->current_fh); in nfsd4_remove()
1054 struct nfsd4_rename *rename = &u->rename; in nfsd4_rename()
1059 status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, in nfsd4_rename()
1060 rename->rn_snamelen, &cstate->current_fh, in nfsd4_rename()
1061 rename->rn_tname, rename->rn_tnamelen); in nfsd4_rename()
1064 set_change_info(&rename->rn_sinfo, &cstate->save_fh); in nfsd4_rename()
1065 set_change_info(&rename->rn_tinfo, &cstate->current_fh); in nfsd4_rename()
1073 struct nfsd4_secinfo *secinfo = &u->secinfo; in nfsd4_secinfo()
1078 err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); in nfsd4_secinfo()
1081 err = nfsd_lookup_dentry(rqstp, &cstate->current_fh, in nfsd4_secinfo()
1082 secinfo->si_name, secinfo->si_namelen, in nfsd4_secinfo()
1090 secinfo->si_exp = exp; in nfsd4_secinfo()
1092 if (cstate->minorversion) in nfsd4_secinfo()
1094 fh_put(&cstate->current_fh); in nfsd4_secinfo()
1104 switch (u->secinfo_no_name.sin_style) { in nfsd4_secinfo_no_name()
1108 err = nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_secinfo_no_name()
1116 u->secinfo_no_name.sin_exp = exp_get(cstate->current_fh.fh_export); in nfsd4_secinfo_no_name()
1117 fh_put(&cstate->current_fh); in nfsd4_secinfo_no_name()
1124 if (u->secinfo.si_exp) in nfsd4_secinfo_release()
1125 exp_put(u->secinfo.si_exp); in nfsd4_secinfo_release()
1131 if (u->secinfo_no_name.sin_exp) in nfsd4_secinfo_no_name_release()
1132 exp_put(u->secinfo_no_name.sin_exp); in nfsd4_secinfo_no_name_release()
1139 struct nfsd4_setattr *setattr = &u->setattr; in nfsd4_setattr()
1141 .na_iattr = &setattr->sa_iattr, in nfsd4_setattr()
1142 .na_seclabel = &setattr->sa_label, in nfsd4_setattr()
1148 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { in nfsd4_setattr()
1150 &cstate->current_fh, &setattr->sa_stateid, in nfsd4_setattr()
1155 err = fh_want_write(&cstate->current_fh); in nfsd4_setattr()
1160 status = check_attr_support(rqstp, cstate, setattr->sa_bmval, in nfsd4_setattr()
1165 inode = cstate->current_fh.fh_dentry->d_inode; in nfsd4_setattr()
1166 status = nfsd4_acl_to_attr(S_ISDIR(inode->i_mode) ? NF4DIR : NF4REG, in nfsd4_setattr()
1167 setattr->sa_acl, &attrs); in nfsd4_setattr()
1171 status = nfsd_setattr(rqstp, &cstate->current_fh, &attrs, in nfsd4_setattr()
1179 fh_drop_write(&cstate->current_fh); in nfsd4_setattr()
1187 struct nfsd4_write *write = &u->write; in nfsd4_write()
1188 stateid_t *stateid = &write->wr_stateid; in nfsd4_write()
1194 if (write->wr_offset > (u64)OFFSET_MAX || in nfsd4_write()
1195 write->wr_offset + write->wr_buflen > (u64)OFFSET_MAX) in nfsd4_write()
1198 cnt = write->wr_buflen; in nfsd4_write()
1199 trace_nfsd_write_start(rqstp, &cstate->current_fh, in nfsd4_write()
1200 write->wr_offset, cnt); in nfsd4_write()
1201 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_write()
1206 write->wr_how_written = write->wr_stable_how; in nfsd4_write()
1208 nvecs = svc_fill_write_vector(rqstp, &write->wr_payload); in nfsd4_write()
1209 WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); in nfsd4_write()
1211 status = nfsd_vfs_write(rqstp, &cstate->current_fh, nf, in nfsd4_write()
1212 write->wr_offset, rqstp->rq_vec, nvecs, &cnt, in nfsd4_write()
1213 write->wr_how_written, in nfsd4_write()
1214 (__be32 *)write->wr_verifier.data); in nfsd4_write()
1217 write->wr_bytes_written = cnt; in nfsd4_write()
1218 trace_nfsd_write_done(rqstp, &cstate->current_fh, in nfsd4_write()
1219 write->wr_offset, cnt); in nfsd4_write()
1230 if (!cstate->save_fh.fh_dentry) in nfsd4_verify_copy()
1233 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh, in nfsd4_verify_copy()
1238 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_verify_copy()
1243 /* fix up for NFS-specific error code */ in nfsd4_verify_copy()
1244 if (!S_ISREG(file_inode((*src)->nf_file)->i_mode) || in nfsd4_verify_copy()
1245 !S_ISREG(file_inode((*dst)->nf_file)->i_mode)) { in nfsd4_verify_copy()
1265 struct nfsd4_clone *clone = &u->clone; in nfsd4_clone()
1269 status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, in nfsd4_clone()
1270 &clone->cl_dst_stateid, &dst); in nfsd4_clone()
1274 status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos, in nfsd4_clone()
1275 dst, clone->cl_dst_pos, clone->cl_count, in nfsd4_clone()
1276 EX_ISSYNC(cstate->current_fh.fh_export)); in nfsd4_clone()
1286 if (!refcount_dec_and_test(©->refcount)) in nfs4_put_copy()
1288 kfree(copy->cp_src); in nfs4_put_copy()
1294 if (!test_and_set_bit(NFSD4_COPY_F_STOPPED, ©->cp_flags)) in nfsd4_stop_copy()
1295 kthread_stop(copy->copy_task); in nfsd4_stop_copy()
1303 spin_lock(&clp->async_lock); in nfsd4_get_copy()
1304 if (!list_empty(&clp->async_copies)) { in nfsd4_get_copy()
1305 copy = list_first_entry(&clp->async_copies, struct nfsd4_copy, in nfsd4_get_copy()
1307 refcount_inc(©->refcount); in nfsd4_get_copy()
1309 spin_unlock(&clp->async_lock); in nfsd4_get_copy()
1347 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1348 list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) { in nfsd4_ssc_setup_dul()
1349 if (strncmp(ni->nsui_ipaddr, ipaddr, sizeof(ni->nsui_ipaddr))) in nfsd4_ssc_setup_dul()
1352 if (ni->nsui_busy) { in nfsd4_ssc_setup_dul()
1353 /* wait - and try again */ in nfsd4_ssc_setup_dul()
1354 prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, TASK_IDLE); in nfsd4_ssc_setup_dul()
1355 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1357 /* allow 20secs for mount/unmount for now - revisit */ in nfsd4_ssc_setup_dul()
1360 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1364 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1368 refcount_inc(&ni->nsui_refcnt); in nfsd4_ssc_setup_dul()
1369 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1372 /* return vfsmount in (*nsui)->nsui_vfsmount */ in nfsd4_ssc_setup_dul()
1376 strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1); in nfsd4_ssc_setup_dul()
1377 refcount_set(&work->nsui_refcnt, 2); in nfsd4_ssc_setup_dul()
1378 work->nsui_busy = true; in nfsd4_ssc_setup_dul()
1379 list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_ssc_setup_dul()
1383 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1391 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1392 nsui->nsui_vfsmount = ss_mnt; in nfsd4_ssc_update_dul()
1393 nsui->nsui_busy = false; in nfsd4_ssc_update_dul()
1394 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_update_dul()
1395 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1401 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1402 list_del(&nsui->nsui_list); in nfsd4_ssc_cancel_dul()
1403 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_cancel_dul()
1404 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1426 naddr = &nss->u.nl4_addr; in nfsd4_interssc_connect()
1427 tmp_addrlen = rpc_uaddr2sockaddr(SVC_NET(rqstp), naddr->addr, in nfsd4_interssc_connect()
1428 naddr->addr_len, in nfsd4_interssc_connect()
1442 if (naddr->netid_len != match_netid_len || in nfsd4_interssc_connect()
1443 strncmp(naddr->netid, match_netid, naddr->netid_len)) in nfsd4_interssc_connect()
1477 if ((*nsui)->nsui_vfsmount) in nfsd4_interssc_connect()
1480 /* Use an 'internal' mount: SB_KERNMOUNT -> MNT_INTERNAL */ in nfsd4_interssc_connect()
1482 module_put(type->owner); in nfsd4_interssc_connect()
1517 stateid_t *s_stid = ©->cp_src_stateid; in nfsd4_setup_inter_ssc()
1521 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_setup_inter_ssc()
1522 ©->cp_dst_stateid, in nfsd4_setup_inter_ssc()
1523 WR_STATE, ©->nf_dst, NULL); in nfsd4_setup_inter_ssc()
1527 status = nfsd4_interssc_connect(copy->cp_src, rqstp, ©->ss_nsui); in nfsd4_setup_inter_ssc()
1531 s_fh = &cstate->save_fh; in nfsd4_setup_inter_ssc()
1533 copy->c_fh.size = s_fh->fh_handle.fh_size; in nfsd4_setup_inter_ssc()
1534 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_raw, copy->c_fh.size); in nfsd4_setup_inter_ssc()
1535 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); in nfsd4_setup_inter_ssc()
1536 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque, in nfsd4_setup_inter_ssc()
1548 struct nfsd_net *nn = net_generic(dst->nf_net, nfsd_net_id); in nfsd4_cleanup_inter_ssc()
1554 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1555 list_del(&nsui->nsui_list); in nfsd4_cleanup_inter_ssc()
1561 refcount_dec(&nsui->nsui_refcnt); in nfsd4_cleanup_inter_ssc()
1562 nsui->nsui_expire = jiffies + timeout; in nfsd4_cleanup_inter_ssc()
1563 list_add_tail(&nsui->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_cleanup_inter_ssc()
1564 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1596 return nfsd4_verify_copy(rqstp, cstate, ©->cp_src_stateid, in nfsd4_setup_intra_ssc()
1597 ©->nf_src, ©->cp_dst_stateid, in nfsd4_setup_intra_ssc()
1598 ©->nf_dst); in nfsd4_setup_intra_ssc()
1615 trace_nfsd_cb_offload_done(&cbo->co_res.cb_stateid, task); in nfsd4_cb_offload_done()
1626 copy->cp_res.wr_stable_how = in nfsd4_init_copy_res()
1627 test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ? in nfsd4_init_copy_res()
1630 gen_boot_verifier(©->cp_res.wr_verifier, copy->cp_clp->net); in nfsd4_init_copy_res()
1639 u64 bytes_total = copy->cp_count; in _nfsd_copy_file_range()
1640 u64 src_pos = copy->cp_src_pos; in _nfsd_copy_file_range()
1641 u64 dst_pos = copy->cp_dst_pos; in _nfsd_copy_file_range()
1656 bytes_total -= bytes_copied; in _nfsd_copy_file_range()
1657 copy->cp_res.wr_bytes_written += bytes_copied; in _nfsd_copy_file_range()
1661 /* for a non-zero asynchronous copy do a commit of data */ in _nfsd_copy_file_range()
1662 if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) { in _nfsd_copy_file_range()
1663 since = READ_ONCE(dst->f_wb_err); in _nfsd_copy_file_range()
1664 end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1; in _nfsd_copy_file_range()
1665 status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0); in _nfsd_copy_file_range()
1667 status = filemap_check_wb_err(dst->f_mapping, since); in _nfsd_copy_file_range()
1669 set_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags); in _nfsd_copy_file_range()
1686 if (bytes < 0 && !copy->cp_res.wr_bytes_written) in nfsd4_do_copy()
1697 dst->cp_src_pos = src->cp_src_pos; in dup_copy_fields()
1698 dst->cp_dst_pos = src->cp_dst_pos; in dup_copy_fields()
1699 dst->cp_count = src->cp_count; in dup_copy_fields()
1700 dst->cp_flags = src->cp_flags; in dup_copy_fields()
1701 memcpy(&dst->cp_res, &src->cp_res, sizeof(src->cp_res)); in dup_copy_fields()
1702 memcpy(&dst->fh, &src->fh, sizeof(src->fh)); in dup_copy_fields()
1703 dst->cp_clp = src->cp_clp; in dup_copy_fields()
1704 dst->nf_dst = nfsd_file_get(src->nf_dst); in dup_copy_fields()
1707 dst->nf_src = nfsd_file_get(src->nf_src); in dup_copy_fields()
1709 memcpy(&dst->cp_stateid, &src->cp_stateid, sizeof(src->cp_stateid)); in dup_copy_fields()
1710 memcpy(dst->cp_src, src->cp_src, sizeof(struct nl4_server)); in dup_copy_fields()
1711 memcpy(&dst->stateid, &src->stateid, sizeof(src->stateid)); in dup_copy_fields()
1712 memcpy(&dst->c_fh, &src->c_fh, sizeof(src->c_fh)); in dup_copy_fields()
1713 dst->ss_nsui = src->ss_nsui; in dup_copy_fields()
1718 if (copy->nf_src) in release_copy_files()
1719 nfsd_file_put(copy->nf_src); in release_copy_files()
1720 if (copy->nf_dst) in release_copy_files()
1721 nfsd_file_put(copy->nf_dst); in release_copy_files()
1728 if (copy->cp_clp) { in cleanup_async_copy()
1729 spin_lock(©->cp_clp->async_lock); in cleanup_async_copy()
1730 if (!list_empty(©->copies)) in cleanup_async_copy()
1731 list_del_init(©->copies); in cleanup_async_copy()
1732 spin_unlock(©->cp_clp->async_lock); in cleanup_async_copy()
1745 memcpy(&cbo->co_res, ©->cp_res, sizeof(copy->cp_res)); in nfsd4_send_cb_offload()
1746 memcpy(&cbo->co_fh, ©->fh, sizeof(copy->fh)); in nfsd4_send_cb_offload()
1747 cbo->co_nfserr = nfserr; in nfsd4_send_cb_offload()
1749 nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops, in nfsd4_send_cb_offload()
1751 trace_nfsd_cb_offload(copy->cp_clp, &cbo->co_res.cb_stateid, in nfsd4_send_cb_offload()
1752 &cbo->co_fh, copy->cp_count, nfserr); in nfsd4_send_cb_offload()
1753 nfsd4_run_cb(&cbo->co_cb); in nfsd4_send_cb_offload()
1757 * nfsd4_do_async_copy - kthread function for background server-side COPY
1772 filp = nfs42_ssc_open(copy->ss_nsui->nsui_vfsmount, in nfsd4_do_async_copy()
1773 ©->c_fh, ©->stateid); in nfsd4_do_async_copy()
1776 case -EBADF: in nfsd4_do_async_copy()
1785 nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file, in nfsd4_do_async_copy()
1787 nfsd4_cleanup_inter_ssc(copy->ss_nsui, filp, copy->nf_dst); in nfsd4_do_async_copy()
1789 nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_do_async_copy()
1790 copy->nf_dst->nf_file, false); in nfsd4_do_async_copy()
1803 struct nfsd4_copy *copy = &u->copy; in nfsd4_copy()
1807 copy->cp_clp = cstate->clp; in nfsd4_copy()
1828 memcpy(©->fh, &cstate->current_fh.fh_handle, in nfsd4_copy()
1833 status = nfserrno(-ENOMEM); in nfsd4_copy()
1837 INIT_LIST_HEAD(&async_copy->copies); in nfsd4_copy()
1838 refcount_set(&async_copy->refcount, 1); in nfsd4_copy()
1839 async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); in nfsd4_copy()
1840 if (!async_copy->cp_src) in nfsd4_copy()
1844 memcpy(©->cp_res.cb_stateid, ©->cp_stateid.cs_stid, in nfsd4_copy()
1845 sizeof(copy->cp_res.cb_stateid)); in nfsd4_copy()
1847 async_copy->copy_task = kthread_create(nfsd4_do_async_copy, in nfsd4_copy()
1849 if (IS_ERR(async_copy->copy_task)) in nfsd4_copy()
1851 spin_lock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1852 list_add(&async_copy->copies, in nfsd4_copy()
1853 &async_copy->cp_clp->async_copies); in nfsd4_copy()
1854 spin_unlock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1855 wake_up_process(async_copy->copy_task); in nfsd4_copy()
1858 status = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_copy()
1859 copy->nf_dst->nf_file, true); in nfsd4_copy()
1868 * Source's vfsmount of inter-copy will be unmounted in nfsd4_copy()
1870 * since async_copy->ss_nsui might not be set yet. in nfsd4_copy()
1872 refcount_dec(©->ss_nsui->nsui_refcnt); in nfsd4_copy()
1876 status = nfserrno(-ENOMEM); in nfsd4_copy()
1885 lockdep_assert_held(&clp->async_lock); in find_async_copy_locked()
1887 list_for_each_entry(copy, &clp->async_copies, copies) { in find_async_copy_locked()
1888 if (memcmp(©->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE)) in find_async_copy_locked()
1900 spin_lock(&clp->async_lock); in find_async_copy()
1903 refcount_inc(©->refcount); in find_async_copy()
1904 spin_unlock(&clp->async_lock); in find_async_copy()
1913 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_cancel()
1915 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_cancel()
1917 copy = find_async_copy(clp, &os->stateid); in nfsd4_offload_cancel()
1921 return manage_cpntf_state(nn, &os->stateid, clp, NULL); in nfsd4_offload_cancel()
1932 struct nfsd4_copy_notify *cn = &u->copy_notify; in nfsd4_copy_notify()
1937 struct nfs4_client *clp = cstate->clp; in nfsd4_copy_notify()
1939 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_copy_notify()
1940 &cn->cpn_src_stateid, RD_STATE, NULL, in nfsd4_copy_notify()
1945 cn->cpn_lease_time.tv_sec = nn->nfsd4_lease; in nfsd4_copy_notify()
1946 cn->cpn_lease_time.tv_nsec = 0; in nfsd4_copy_notify()
1948 status = nfserrno(-ENOMEM); in nfsd4_copy_notify()
1952 memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t)); in nfsd4_copy_notify()
1953 memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t)); in nfsd4_copy_notify()
1954 memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t)); in nfsd4_copy_notify()
1959 cn->cpn_src->nl4_type = NL4_NETADDR; in nfsd4_copy_notify()
1960 status = nfsd4_set_netaddr((struct sockaddr *)&rqstp->rq_daddr, in nfsd4_copy_notify()
1961 &cn->cpn_src->u.nl4_addr); in nfsd4_copy_notify()
1979 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_fallocate()
1980 &fallocate->falloc_stateid, in nfsd4_fallocate()
1985 status = nfsd4_vfs_fallocate(rqstp, &cstate->current_fh, nf->nf_file, in nfsd4_fallocate()
1986 fallocate->falloc_offset, in nfsd4_fallocate()
1987 fallocate->falloc_length, in nfsd4_fallocate()
1998 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_status()
2001 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_status()
2003 spin_lock(&clp->async_lock); in nfsd4_offload_status()
2004 copy = find_async_copy_locked(clp, &os->stateid); in nfsd4_offload_status()
2006 os->count = copy->cp_res.wr_bytes_written; in nfsd4_offload_status()
2009 spin_unlock(&clp->async_lock); in nfsd4_offload_status()
2018 return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); in nfsd4_allocate()
2025 return nfsd4_fallocate(rqstp, cstate, &u->deallocate, in nfsd4_deallocate()
2033 struct nfsd4_seek *seek = &u->seek; in nfsd4_seek()
2038 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_seek()
2039 &seek->seek_stateid, in nfsd4_seek()
2044 switch (seek->seek_whence) { in nfsd4_seek()
2057 * Note: This call does change file->f_pos, but nothing in NFSD in nfsd4_seek()
2058 * should ever file->f_pos. in nfsd4_seek()
2060 seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence); in nfsd4_seek()
2061 if (seek->seek_pos < 0) in nfsd4_seek()
2062 status = nfserrno(seek->seek_pos); in nfsd4_seek()
2063 else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file))) in nfsd4_seek()
2064 seek->seek_eof = true; in nfsd4_seek()
2084 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in _nfsd4_verify()
2088 status = check_attr_support(rqstp, cstate, verify->ve_bmval, NULL); in _nfsd4_verify()
2092 if ((verify->ve_bmval[0] & FATTR4_WORD0_RDATTR_ERROR) in _nfsd4_verify()
2093 || (verify->ve_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)) in _nfsd4_verify()
2095 if (verify->ve_attrlen & 3) in _nfsd4_verify()
2101 count = 4 + (verify->ve_attrlen >> 2); in _nfsd4_verify()
2107 status = nfsd4_encode_fattr_to_buf(&p, count, &cstate->current_fh, in _nfsd4_verify()
2108 cstate->current_fh.fh_export, in _nfsd4_verify()
2109 cstate->current_fh.fh_dentry, in _nfsd4_verify()
2110 verify->ve_bmval, in _nfsd4_verify()
2124 if (ntohl(*p++) != verify->ve_attrlen) in _nfsd4_verify()
2126 if (!memcmp(p, verify->ve_attrval, verify->ve_attrlen)) in _nfsd4_verify()
2140 status = _nfsd4_verify(rqstp, cstate, &u->verify); in nfsd4_nverify()
2150 status = _nfsd4_verify(rqstp, cstate, &u->nverify); in nfsd4_verify()
2158 if (!exp->ex_layout_types) { in nfsd4_layout_verify()
2164 !(exp->ex_layout_types & (1 << layout_type))) { in nfsd4_layout_verify()
2177 struct nfsd4_getdeviceinfo *gdp = &u->getdeviceinfo; in nfsd4_getdeviceinfo()
2185 gdp->gd_layout_type, in nfsd4_getdeviceinfo()
2186 gdp->gd_devid.fsid_idx, gdp->gd_devid.generation, in nfsd4_getdeviceinfo()
2187 gdp->gd_maxcount); in nfsd4_getdeviceinfo()
2189 map = nfsd4_find_devid_map(gdp->gd_devid.fsid_idx); in nfsd4_getdeviceinfo()
2191 dprintk("%s: couldn't find device ID to export mapping!\n", in nfsd4_getdeviceinfo()
2196 exp = rqst_exp_find(rqstp, map->fsid_type, map->fsid); in nfsd4_getdeviceinfo()
2198 dprintk("%s: could not find device id\n", __func__); in nfsd4_getdeviceinfo()
2203 ops = nfsd4_layout_verify(exp, gdp->gd_layout_type); in nfsd4_getdeviceinfo()
2208 if (gdp->gd_maxcount != 0) { in nfsd4_getdeviceinfo()
2209 nfserr = ops->proc_getdeviceinfo(exp->ex_path.mnt->mnt_sb, in nfsd4_getdeviceinfo()
2210 rqstp, cstate->clp, gdp); in nfsd4_getdeviceinfo()
2213 gdp->gd_notify_types &= ops->notify_types; in nfsd4_getdeviceinfo()
2222 kfree(u->getdeviceinfo.gd_device); in nfsd4_getdeviceinfo_release()
2229 struct nfsd4_layoutget *lgp = &u->layoutget; in nfsd4_layoutget()
2230 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutget()
2236 switch (lgp->lg_seg.iomode) { in nfsd4_layoutget()
2245 __func__, lgp->lg_seg.iomode); in nfsd4_layoutget()
2255 ops = nfsd4_layout_verify(current_fh->fh_export, lgp->lg_layout_type); in nfsd4_layoutget()
2271 if (lgp->lg_seg.length < lgp->lg_minlength || in nfsd4_layoutget()
2272 (lgp->lg_minlength != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2273 lgp->lg_minlength > NFS4_MAX_UINT64 - lgp->lg_seg.offset) || in nfsd4_layoutget()
2274 (lgp->lg_seg.length != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2275 lgp->lg_seg.length > NFS4_MAX_UINT64 - lgp->lg_seg.offset)) in nfsd4_layoutget()
2277 if (lgp->lg_seg.length == 0) in nfsd4_layoutget()
2280 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid, in nfsd4_layoutget()
2281 true, lgp->lg_layout_type, &ls); in nfsd4_layoutget()
2283 trace_nfsd_layout_get_lookup_fail(&lgp->lg_sid); in nfsd4_layoutget()
2288 if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls)) in nfsd4_layoutget()
2291 nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry), in nfsd4_layoutget()
2299 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutget()
2300 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutget()
2308 kfree(u->layoutget.lg_content); in nfsd4_layoutget_release()
2315 struct nfsd4_layoutcommit *lcp = &u->layoutcommit; in nfsd4_layoutcommit()
2316 const struct nfsd4_layout_seg *seg = &lcp->lc_seg; in nfsd4_layoutcommit()
2317 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutcommit()
2319 loff_t new_size = lcp->lc_last_wr + 1; in nfsd4_layoutcommit()
2329 ops = nfsd4_layout_verify(current_fh->fh_export, lcp->lc_layout_type); in nfsd4_layoutcommit()
2332 inode = d_inode(current_fh->fh_dentry); in nfsd4_layoutcommit()
2335 if (new_size <= seg->offset) { in nfsd4_layoutcommit()
2339 if (new_size > seg->offset + seg->length) { in nfsd4_layoutcommit()
2343 if (!lcp->lc_newoffset && new_size > i_size_read(inode)) { in nfsd4_layoutcommit()
2348 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lcp->lc_sid, in nfsd4_layoutcommit()
2349 false, lcp->lc_layout_type, in nfsd4_layoutcommit()
2352 trace_nfsd_layout_commit_lookup_fail(&lcp->lc_sid); in nfsd4_layoutcommit()
2360 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutcommit()
2363 lcp->lc_size_chg = true; in nfsd4_layoutcommit()
2364 lcp->lc_newsize = new_size; in nfsd4_layoutcommit()
2366 lcp->lc_size_chg = false; in nfsd4_layoutcommit()
2369 nfserr = ops->proc_layoutcommit(inode, lcp); in nfsd4_layoutcommit()
2370 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutcommit()
2379 struct nfsd4_layoutreturn *lrp = &u->layoutreturn; in nfsd4_layoutreturn()
2380 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutreturn()
2388 if (!nfsd4_layout_verify(current_fh->fh_export, lrp->lr_layout_type)) in nfsd4_layoutreturn()
2391 switch (lrp->lr_seg.iomode) { in nfsd4_layoutreturn()
2398 lrp->lr_seg.iomode); in nfsd4_layoutreturn()
2403 switch (lrp->lr_return_type) { in nfsd4_layoutreturn()
2413 lrp->lr_return_type); in nfsd4_layoutreturn()
2426 struct nfsd4_getxattr *getxattr = &u->getxattr; in nfsd4_getxattr()
2428 return nfsd_getxattr(rqstp, &cstate->current_fh, in nfsd4_getxattr()
2429 getxattr->getxa_name, &getxattr->getxa_buf, in nfsd4_getxattr()
2430 &getxattr->getxa_len); in nfsd4_getxattr()
2437 struct nfsd4_setxattr *setxattr = &u->setxattr; in nfsd4_setxattr()
2443 ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name, in nfsd4_setxattr()
2444 setxattr->setxa_buf, setxattr->setxa_len, in nfsd4_setxattr()
2445 setxattr->setxa_flags); in nfsd4_setxattr()
2448 set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh); in nfsd4_setxattr()
2461 return nfsd_listxattr(rqstp, &cstate->current_fh, in nfsd4_listxattrs()
2462 &u->listxattrs.lsxa_buf, &u->listxattrs.lsxa_len); in nfsd4_listxattrs()
2469 struct nfsd4_removexattr *removexattr = &u->removexattr; in nfsd4_removexattr()
2475 ret = nfsd_removexattr(rqstp, &cstate->current_fh, in nfsd4_removexattr()
2476 removexattr->rmxa_name); in nfsd4_removexattr()
2479 set_change_info(&removexattr->rmxa_cinfo, &cstate->current_fh); in nfsd4_removexattr()
2504 * Enforce NFSv4.1 COMPOUND ordering rules:
2507 * - SEQUENCE other than as first op results in
2509 * - BIND_CONN_TO_SESSION must be the only op in its compound.
2511 * - DESTROY_SESSION must be the final operation in a compound, if
2517 struct nfsd4_op *first_op = &args->ops[0]; in nfs41_check_op_ordering()
2520 if (args->minorversion == 0) in nfs41_check_op_ordering()
2523 if (args->opcnt == 0) in nfs41_check_op_ordering()
2525 if (first_op->status == nfserr_op_illegal) in nfs41_check_op_ordering()
2527 if (!(nfsd4_ops[first_op->opnum].op_flags & ALLOWED_AS_FIRST_OP)) in nfs41_check_op_ordering()
2529 if (first_op->opnum == OP_SEQUENCE) in nfs41_check_op_ordering()
2534 * compound: in nfs41_check_op_ordering()
2536 if (args->opcnt != 1) in nfs41_check_op_ordering()
2543 return &nfsd4_ops[op->opnum]; in OPDESC()
2548 if (op->opnum == OP_ILLEGAL) in nfsd4_cache_this_op()
2550 return OPDESC(op)->op_flags & OP_CACHEME; in nfsd4_cache_this_op()
2555 struct nfsd4_compoundres *resp = rqstp->rq_resp; in need_wrongsec_check()
2556 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in need_wrongsec_check()
2557 struct nfsd4_op *this = &argp->ops[resp->opcnt - 1]; in need_wrongsec_check()
2558 struct nfsd4_op *next = &argp->ops[resp->opcnt]; in need_wrongsec_check()
2563 * Most ops check wronsec on our own; only the putfh-like ops in need_wrongsec_check()
2566 if (!(thisd->op_flags & OP_IS_PUTFH_LIKE)) in need_wrongsec_check()
2570 * put-filehandle operation if we're not going to use the in need_wrongsec_check()
2573 if (argp->opcnt == resp->opcnt) in need_wrongsec_check()
2575 if (next->opnum == OP_ILLEGAL) in need_wrongsec_check()
2583 return !(nextd->op_flags & OP_HANDLES_WRONGSEC); in need_wrongsec_check()
2595 /* traverse all operation and if it's a COPY compound, mark the in check_if_stalefh_allowed()
2598 for (i = 0; i < args->opcnt; i++) { in check_if_stalefh_allowed()
2599 op = &args->ops[i]; in check_if_stalefh_allowed()
2600 if (op->opnum == OP_PUTFH) in check_if_stalefh_allowed()
2602 else if (op->opnum == OP_SAVEFH) in check_if_stalefh_allowed()
2604 else if (op->opnum == OP_RESTOREFH) in check_if_stalefh_allowed()
2606 else if (op->opnum == OP_COPY) { in check_if_stalefh_allowed()
2607 copy = (struct nfsd4_copy *)&op->u; in check_if_stalefh_allowed()
2609 op->status = nfserr_nofilehandle; in check_if_stalefh_allowed()
2612 putfh = (struct nfsd4_putfh *)&saved_op->u; in check_if_stalefh_allowed()
2614 putfh->no_verify = true; in check_if_stalefh_allowed()
2626 * COMPOUND call.
2631 struct nfsd4_compoundargs *args = rqstp->rq_argp; in nfsd4_proc_compound()
2632 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_proc_compound()
2634 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_proc_compound()
2635 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_proc_compound()
2636 struct svc_fh *save_fh = &cstate->save_fh; in nfsd4_proc_compound()
2640 resp->xdr = &rqstp->rq_res_stream; in nfsd4_proc_compound()
2641 resp->statusp = resp->xdr->p; in nfsd4_proc_compound()
2644 xdr_reserve_space(resp->xdr, XDR_UNIT); in nfsd4_proc_compound()
2647 xdr_reserve_space(resp->xdr, XDR_UNIT * 2 + args->taglen); in nfsd4_proc_compound()
2648 resp->taglen = args->taglen; in nfsd4_proc_compound()
2649 resp->tag = args->tag; in nfsd4_proc_compound()
2650 resp->rqstp = rqstp; in nfsd4_proc_compound()
2651 cstate->minorversion = args->minorversion; in nfsd4_proc_compound()
2656 * too hard to avoid non-idempotency problems. in nfsd4_proc_compound()
2658 clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2664 if (nfsd_minorversion(nn, args->minorversion, NFSD_TEST) <= 0) in nfsd4_proc_compound()
2669 op = &args->ops[0]; in nfsd4_proc_compound()
2670 op->status = status; in nfsd4_proc_compound()
2671 resp->opcnt = 1; in nfsd4_proc_compound()
2676 rqstp->rq_lease_breaker = (void **)&cstate->clp; in nfsd4_proc_compound()
2678 trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt); in nfsd4_proc_compound()
2679 while (!status && resp->opcnt < args->opcnt) { in nfsd4_proc_compound()
2680 op = &args->ops[resp->opcnt++]; in nfsd4_proc_compound()
2682 if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) { in nfsd4_proc_compound()
2685 if (cstate->minorversion == 0 && in nfsd4_proc_compound()
2686 args->client_opcnt > resp->opcnt) { in nfsd4_proc_compound()
2687 op->status = nfserr_resource; in nfsd4_proc_compound()
2693 * The XDR decode routines may have pre-set op->status; in nfsd4_proc_compound()
2697 if (op->status) { in nfsd4_proc_compound()
2698 if (op->opnum == OP_OPEN) in nfsd4_proc_compound()
2699 op->status = nfsd4_open_omfg(rqstp, cstate, op); in nfsd4_proc_compound()
2702 if (!current_fh->fh_dentry && in nfsd4_proc_compound()
2704 if (!(op->opdesc->op_flags & ALLOWED_WITHOUT_FH)) { in nfsd4_proc_compound()
2705 op->status = nfserr_nofilehandle; in nfsd4_proc_compound()
2708 } else if (current_fh->fh_export && in nfsd4_proc_compound()
2709 current_fh->fh_export->ex_fslocs.migrated && in nfsd4_proc_compound()
2710 !(op->opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) { in nfsd4_proc_compound()
2711 op->status = nfserr_moved; in nfsd4_proc_compound()
2717 /* If op is non-idempotent */ in nfsd4_proc_compound()
2718 if (op->opdesc->op_flags & OP_MODIFIES_SOMETHING) { in nfsd4_proc_compound()
2723 u32 plen = op->opdesc->op_rsize_bop(rqstp, op); in nfsd4_proc_compound()
2728 if (resp->opcnt < args->opcnt) in nfsd4_proc_compound()
2730 op->status = nfsd4_check_resp_size(resp, plen); in nfsd4_proc_compound()
2733 if (op->status) in nfsd4_proc_compound()
2736 if (op->opdesc->op_get_currentstateid) in nfsd4_proc_compound()
2737 op->opdesc->op_get_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2738 op->status = op->opdesc->op_func(rqstp, cstate, &op->u); in nfsd4_proc_compound()
2741 if (cstate->status == nfserr_replay_cache) { in nfsd4_proc_compound()
2743 status = op->status; in nfsd4_proc_compound()
2746 if (!op->status) { in nfsd4_proc_compound()
2747 if (op->opdesc->op_set_currentstateid) in nfsd4_proc_compound()
2748 op->opdesc->op_set_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2750 if (op->opdesc->op_flags & OP_CLEAR_STATEID) in nfsd4_proc_compound()
2753 if (current_fh->fh_export && in nfsd4_proc_compound()
2755 op->status = check_nfsd_access(current_fh->fh_export, rqstp); in nfsd4_proc_compound()
2758 if (op->status == nfserr_replay_me) { in nfsd4_proc_compound()
2759 op->replay = &cstate->replay_owner->so_replay; in nfsd4_proc_compound()
2760 nfsd4_encode_replay(resp->xdr, op); in nfsd4_proc_compound()
2761 status = op->status = op->replay->rp_status; in nfsd4_proc_compound()
2764 status = op->status; in nfsd4_proc_compound()
2767 trace_nfsd_compound_status(args->client_opcnt, resp->opcnt, in nfsd4_proc_compound()
2768 status, nfsd4_op_name(op->opnum)); in nfsd4_proc_compound()
2771 nfsd4_increment_op_stats(op->opnum); in nfsd4_proc_compound()
2776 BUG_ON(cstate->replay_owner); in nfsd4_proc_compound()
2778 cstate->status = status; in nfsd4_proc_compound()
2780 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2803 * The _rsize() helpers are invoked by the NFSv4 COMPOUND decoder, which
2812 buflen = (rqstp->rq_page_end - rqstp->rq_next_page) * PAGE_SIZE; in nfsd4_max_payload()
2813 buflen -= rqstp->rq_auth_slack; in nfsd4_max_payload()
2814 buflen -= rqstp->rq_res.head[0].iov_len; in nfsd4_max_payload()
2858 const u32 *bmap = op->u.getattr.ga_bmval; in nfsd4_getattr_rsize()
2925 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_rsize()
2933 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_plus_rsize()
2947 u32 rlen = min(op->u.readdir.rd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_readdir_rsize()
2983 return (op_encode_hdr_size + 1 + op->u.test_stateid.ts_num_ids) in nfsd4_test_stateid_rsize()
3086 u32 rlen = min(op->u.getdeviceinfo.gd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_getdeviceinfo_rsize()
3150 u32 rlen = min(op->u.listxattrs.lsxa_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_listxattrs_rsize()
3578 * nfsd4_spo_must_allow - Determine if the compound op contains an
3583 * Checks to see if the compound contains a spo_must_allow op
3589 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_spo_must_allow()
3590 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_spo_must_allow()
3592 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_spo_must_allow()
3593 struct nfs4_op_map *allow = &cstate->clp->cl_spo_must_allow; in nfsd4_spo_must_allow()
3596 if (!cstate->minorversion) in nfsd4_spo_must_allow()
3599 if (cstate->spo_must_allowed) in nfsd4_spo_must_allow()
3602 opiter = resp->opcnt; in nfsd4_spo_must_allow()
3603 while (opiter < argp->opcnt) { in nfsd4_spo_must_allow()
3604 this = &argp->ops[opiter++]; in nfsd4_spo_must_allow()
3605 if (test_bit(this->opnum, allow->u.longs) && in nfsd4_spo_must_allow()
3606 cstate->clp->cl_mach_cred && in nfsd4_spo_must_allow()
3607 nfsd4_mach_creds_match(cstate->clp, rqstp)) { in nfsd4_spo_must_allow()
3608 cstate->spo_must_allowed = true; in nfsd4_spo_must_allow()
3612 cstate->spo_must_allowed = false; in nfsd4_spo_must_allow()
3618 if (op->opnum == OP_ILLEGAL || op->status == nfserr_notsupp) in nfsd4_max_reply()
3621 BUG_ON(OPDESC(op)->op_rsize_bop == NULL); in nfsd4_max_reply()
3622 return OPDESC(op)->op_rsize_bop(rqstp, op); in nfsd4_max_reply()
3627 if (OPDESC(op)->op_flags & OP_MODIFIES_SOMETHING) { in warn_on_nonidempotent_op()
3629 op->opnum, nfsd4_op_name(op->opnum)); in warn_on_nonidempotent_op()
3663 .pc_name = "COMPOUND",