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()
172 /* RFC 7530 - 16.16.6 */ in nfsd_check_obj_isreg()
184 fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh, in nfsd4_set_open_owner_reply_cache()
185 &resfh->fh_handle); in nfsd4_set_open_owner_reply_cache()
203 switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { in nfsd4_vfs_create()
214 path.mnt = fhp->fh_export->ex_path.mnt; in nfsd4_vfs_create()
216 filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, in nfsd4_vfs_create()
221 open->op_filp = filp; in nfsd4_vfs_create()
236 struct iattr *iap = &open->op_iattr; in nfsd4_create_file()
239 .na_seclabel = &open->op_label, in nfsd4_create_file()
247 if (isdotent(open->op_fname, open->op_fnamelen)) in nfsd4_create_file()
249 if (!(iap->ia_valid & ATTR_MODE)) in nfsd4_create_file()
250 iap->ia_mode = 0; in nfsd4_create_file()
255 parent = fhp->fh_dentry; in nfsd4_create_file()
263 nfsd4_acl_to_attr(NF4REG, open->op_acl, &attrs); in nfsd4_create_file()
267 child = lookup_one_len(open->op_fname, parent, open->op_fnamelen); in nfsd4_create_file()
279 status = fh_compose(resfhp, fhp->fh_export, child, fhp); in nfsd4_create_file()
285 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
286 u32 *verifier = (u32 *)open->op_verf.data; in nfsd4_create_file()
308 switch (open->op_createmode) { in nfsd4_create_file()
319 open->op_truncate = (iap->ia_valid & ATTR_SIZE) && in nfsd4_create_file()
320 !iap->ia_size; in nfsd4_create_file()
328 d_inode(child)->i_size == 0) { in nfsd4_create_file()
329 open->op_created = true; in nfsd4_create_file()
337 d_inode(child)->i_size == 0) { in nfsd4_create_file()
338 open->op_created = true; in nfsd4_create_file()
347 iap->ia_mode &= ~current_umask(); in nfsd4_create_file()
355 open->op_created = true; in nfsd4_create_file()
359 if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0)) in nfsd4_create_file()
360 iap->ia_valid &= ~ATTR_SIZE; in nfsd4_create_file()
361 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
362 iap->ia_valid = ATTR_MTIME | ATTR_ATIME | in nfsd4_create_file()
364 iap->ia_mtime.tv_sec = v_mtime; in nfsd4_create_file()
365 iap->ia_atime.tv_sec = v_atime; in nfsd4_create_file()
366 iap->ia_mtime.tv_nsec = 0; in nfsd4_create_file()
367 iap->ia_atime.tv_nsec = 0; in nfsd4_create_file()
374 open->op_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create_file()
376 open->op_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create_file()
387 * set_change_info - set up the change_info4 for a reply
393 * the event that we didn't get any pre-attrs, just zero out both.
398 cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); in set_change_info()
399 cinfo->before_change = fhp->fh_pre_change; in set_change_info()
400 cinfo->after_change = fhp->fh_post_change; in set_change_info()
403 * If fetching the pre-change attributes failed, then we should in set_change_info()
405 * failed to fetch post-change attributes however. in set_change_info()
407 * If we didn't get post-op attrs, just zero-out the after in set_change_info()
412 if (WARN_ON_ONCE(!fhp->fh_pre_saved)) in set_change_info()
413 cinfo->before_change = 0; in set_change_info()
414 if (!fhp->fh_post_saved) in set_change_info()
415 cinfo->after_change = cinfo->before_change + 1; in set_change_info()
421 struct svc_fh *current_fh = &cstate->current_fh; in do_open_lookup()
429 open->op_truncate = false; in do_open_lookup()
431 if (open->op_create) { in do_open_lookup()
437 * -------------+--------+-----------------+-------------------- in do_open_lookup()
447 current->fs->umask = open->op_umask; in do_open_lookup()
449 current->fs->umask = 0; in do_open_lookup()
456 if (nfsd4_create_is_exclusive(open->op_createmode) && status == 0) in do_open_lookup()
457 open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS | in do_open_lookup()
461 open->op_fname, open->op_fnamelen, *resfh); in do_open_lookup()
470 status = nfsd_check_obj_isreg(*resfh, cstate->minorversion); in do_open_lookup()
476 if (open->op_created || in do_open_lookup()
477 open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) in do_open_lookup()
480 set_change_info(&open->op_cinfo, current_fh); in do_open_lookup()
488 struct svc_fh *current_fh = &cstate->current_fh; in do_open_fhandle()
495 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); in do_open_fhandle()
499 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && in do_open_fhandle()
500 (open->op_iattr.ia_size == 0); in do_open_fhandle()
510 if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH) in do_open_fhandle()
520 (struct nfsd4_sessionid *)session->se_sessionid.data; in copy_clientid()
522 clid->cl_boot = sid->clientid.cl_boot; in copy_clientid()
523 clid->cl_id = sid->clientid.cl_id; in copy_clientid()
530 struct nfsd4_open *open = &u->open; in nfsd4_open()
538 (int)open->op_fnamelen, open->op_fname, in nfsd4_open()
539 open->op_openowner); in nfsd4_open()
541 open->op_filp = NULL; in nfsd4_open()
542 open->op_rqstp = rqstp; in nfsd4_open()
545 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) in nfsd4_open()
548 open->op_created = false; in nfsd4_open()
554 !test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &cstate->clp->cl_flags) && in nfsd4_open()
555 open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
559 copy_clientid(&open->op_clientid, cstate->session); in nfsd4_open()
564 struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay; in nfsd4_open()
565 fh_put(&cstate->current_fh); in nfsd4_open()
566 fh_copy_shallow(&cstate->current_fh.fh_handle, in nfsd4_open()
567 &rp->rp_openfh); in nfsd4_open()
568 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_open()
577 if (open->op_xdr_error) { in nfsd4_open()
578 status = open->op_xdr_error; in nfsd4_open()
589 if (opens_in_grace(net) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
592 if (!opens_in_grace(net) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
595 switch (open->op_claim_type) { in nfsd4_open()
603 status = nfs4_check_open_reclaim(cstate->clp); in nfsd4_open()
606 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_open()
614 resfh = &cstate->current_fh; in nfsd4_open()
626 if (status && open->op_created) in nfsd4_open()
627 pr_warn("nfsd4_process_open2 failed to open newly-created file: status=%u\n", in nfsd4_open()
630 nn->somebody_reclaimed = true; in nfsd4_open()
632 if (open->op_filp) { in nfsd4_open()
633 fput(open->op_filp); in nfsd4_open()
634 open->op_filp = NULL; in nfsd4_open()
636 if (resfh && resfh != &cstate->current_fh) { in nfsd4_open()
637 fh_dup2(&cstate->current_fh, resfh); in nfsd4_open()
647 * OPEN is the only seqid-mutating operation whose decoding can fail
648 * with a seqid-mutating error (specifically, decoding of user names in
654 struct nfsd4_open *open = &op->u.open; in nfsd4_open_omfg()
656 if (!seqid_mutating_err(ntohl(op->status))) in nfsd4_open_omfg()
657 return op->status; in nfsd4_open_omfg()
659 return op->status; in nfsd4_open_omfg()
660 open->op_xdr_error = op->status; in nfsd4_open_omfg()
661 return nfsd4_open(rqstp, cstate, &op->u); in nfsd4_open_omfg()
665 * filehandle-manipulating ops.
671 u->getfh = &cstate->current_fh; in nfsd4_getfh()
679 struct nfsd4_putfh *putfh = &u->putfh; in nfsd4_putfh()
682 fh_put(&cstate->current_fh); in nfsd4_putfh()
683 cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; in nfsd4_putfh()
684 memcpy(&cstate->current_fh.fh_handle.fh_raw, putfh->pf_fhval, in nfsd4_putfh()
685 putfh->pf_fhlen); in nfsd4_putfh()
686 ret = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_BYPASS_GSS); in nfsd4_putfh()
688 if (ret == nfserr_stale && putfh->no_verify) { in nfsd4_putfh()
689 SET_FH_FLAG(&cstate->current_fh, NFSD4_FH_FOREIGN); in nfsd4_putfh()
700 fh_put(&cstate->current_fh); in nfsd4_putrootfh()
702 return exp_pseudoroot(rqstp, &cstate->current_fh); in nfsd4_putrootfh()
709 if (!cstate->save_fh.fh_dentry) in nfsd4_restorefh()
712 fh_dup2(&cstate->current_fh, &cstate->save_fh); in nfsd4_restorefh()
714 memcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t)); in nfsd4_restorefh()
724 fh_dup2(&cstate->save_fh, &cstate->current_fh); in nfsd4_savefh()
726 memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); in nfsd4_savefh()
739 struct nfsd4_access *access = &u->access; in nfsd4_access()
743 if (cstate->minorversion >= 2) in nfsd4_access()
747 if (access->ac_req_access & ~access_full) in nfsd4_access()
750 access->ac_resp_access = access->ac_req_access; in nfsd4_access()
751 return nfsd_access(rqstp, &cstate->current_fh, &access->ac_resp_access, in nfsd4_access()
752 &access->ac_supported); in nfsd4_access()
759 struct nfsd4_commit *commit = &u->commit; in nfsd4_commit()
763 status = nfsd_file_acquire(rqstp, &cstate->current_fh, NFSD_MAY_WRITE | in nfsd4_commit()
768 status = nfsd_commit(rqstp, &cstate->current_fh, nf, commit->co_offset, in nfsd4_commit()
769 commit->co_count, in nfsd4_commit()
770 (__be32 *)commit->co_verf.data); in nfsd4_commit()
779 struct nfsd4_create *create = &u->create; in nfsd4_create()
781 .na_iattr = &create->cr_iattr, in nfsd4_create()
782 .na_seclabel = &create->cr_label, in nfsd4_create()
790 status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); in nfsd4_create()
794 status = check_attr_support(rqstp, cstate, create->cr_bmval, in nfsd4_create()
799 status = nfsd4_acl_to_attr(create->cr_type, create->cr_acl, &attrs); in nfsd4_create()
800 current->fs->umask = create->cr_umask; in nfsd4_create()
801 switch (create->cr_type) { in nfsd4_create()
803 status = nfsd_symlink(rqstp, &cstate->current_fh, in nfsd4_create()
804 create->cr_name, create->cr_namelen, in nfsd4_create()
805 create->cr_data, &attrs, &resfh); in nfsd4_create()
810 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
811 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
812 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
814 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
815 create->cr_name, create->cr_namelen, in nfsd4_create()
821 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
822 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
823 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
825 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
826 create->cr_name, create->cr_namelen, in nfsd4_create()
831 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
832 create->cr_name, create->cr_namelen, in nfsd4_create()
837 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
838 create->cr_name, create->cr_namelen, in nfsd4_create()
843 create->cr_iattr.ia_valid &= ~ATTR_SIZE; in nfsd4_create()
844 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
845 create->cr_name, create->cr_namelen, in nfsd4_create()
857 create->cr_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create()
859 create->cr_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create()
860 set_change_info(&create->cr_cinfo, &cstate->current_fh); in nfsd4_create()
861 fh_dup2(&cstate->current_fh, &resfh); in nfsd4_create()
865 current->fs->umask = 0; in nfsd4_create()
874 struct nfsd4_getattr *getattr = &u->getattr; in nfsd4_getattr()
877 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_getattr()
881 if (getattr->ga_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_getattr()
884 getattr->ga_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_getattr()
885 getattr->ga_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_getattr()
886 getattr->ga_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_getattr()
888 getattr->ga_fhp = &cstate->current_fh; in nfsd4_getattr()
896 struct nfsd4_link *link = &u->link; in nfsd4_link()
899 status = nfsd_link(rqstp, &cstate->current_fh, in nfsd4_link()
900 link->li_name, link->li_namelen, &cstate->save_fh); in nfsd4_link()
902 set_change_info(&link->li_cinfo, &cstate->current_fh); in nfsd4_link()
915 if (tmp_fh.fh_dentry == fh->fh_dentry) { in nfsd4_do_lookupp()
927 return nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_lookupp()
934 return nfsd_lookup(rqstp, &cstate->current_fh, in nfsd4_lookup()
935 u->lookup.lo_name, u->lookup.lo_len, in nfsd4_lookup()
936 &cstate->current_fh); in nfsd4_lookup()
943 struct nfsd4_read *read = &u->read; in nfsd4_read()
946 read->rd_nf = NULL; in nfsd4_read()
948 trace_nfsd_read_start(rqstp, &cstate->current_fh, in nfsd4_read()
949 read->rd_offset, read->rd_length); in nfsd4_read()
951 read->rd_length = min_t(u32, read->rd_length, svc_max_payload(rqstp)); in nfsd4_read()
952 if (read->rd_offset > (u64)OFFSET_MAX) in nfsd4_read()
953 read->rd_offset = (u64)OFFSET_MAX; in nfsd4_read()
954 if (read->rd_offset + read->rd_length > (u64)OFFSET_MAX) in nfsd4_read()
955 read->rd_length = (u64)OFFSET_MAX - read->rd_offset; in nfsd4_read()
960 * following compound. in nfsd4_read()
963 * the client wants us to do more in this compound: in nfsd4_read()
966 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_read()
968 argp->splice_ok = false; in nfsd4_read()
972 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_read()
973 &read->rd_stateid, RD_STATE, in nfsd4_read()
974 &read->rd_nf, NULL); in nfsd4_read()
976 read->rd_rqstp = rqstp; in nfsd4_read()
977 read->rd_fhp = &cstate->current_fh; in nfsd4_read()
985 if (u->read.rd_nf) in nfsd4_read_release()
986 nfsd_file_put(u->read.rd_nf); in nfsd4_read_release()
987 trace_nfsd_read_done(u->read.rd_rqstp, u->read.rd_fhp, in nfsd4_read_release()
988 u->read.rd_offset, u->read.rd_length); in nfsd4_read_release()
995 struct nfsd4_readdir *readdir = &u->readdir; in nfsd4_readdir()
996 u64 cookie = readdir->rd_cookie; in nfsd4_readdir()
999 /* no need to check permission - this will be done in nfsd_readdir() */ in nfsd4_readdir()
1001 if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_readdir()
1004 readdir->rd_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_readdir()
1005 readdir->rd_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_readdir()
1006 readdir->rd_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_readdir()
1009 (cookie == 0 && memcmp(readdir->rd_verf.data, zeroverf.data, NFS4_VERIFIER_SIZE))) in nfsd4_readdir()
1012 readdir->rd_rqstp = rqstp; in nfsd4_readdir()
1013 readdir->rd_fhp = &cstate->current_fh; in nfsd4_readdir()
1021 u->readlink.rl_rqstp = rqstp; in nfsd4_readlink()
1022 u->readlink.rl_fhp = &cstate->current_fh; in nfsd4_readlink()
1030 struct nfsd4_remove *remove = &u->remove; in nfsd4_remove()
1035 status = nfsd_unlink(rqstp, &cstate->current_fh, 0, in nfsd4_remove()
1036 remove->rm_name, remove->rm_namelen); in nfsd4_remove()
1038 set_change_info(&remove->rm_cinfo, &cstate->current_fh); in nfsd4_remove()
1046 struct nfsd4_rename *rename = &u->rename; in nfsd4_rename()
1051 status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, in nfsd4_rename()
1052 rename->rn_snamelen, &cstate->current_fh, in nfsd4_rename()
1053 rename->rn_tname, rename->rn_tnamelen); in nfsd4_rename()
1056 set_change_info(&rename->rn_sinfo, &cstate->save_fh); in nfsd4_rename()
1057 set_change_info(&rename->rn_tinfo, &cstate->current_fh); in nfsd4_rename()
1065 struct nfsd4_secinfo *secinfo = &u->secinfo; in nfsd4_secinfo()
1070 err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); in nfsd4_secinfo()
1073 err = nfsd_lookup_dentry(rqstp, &cstate->current_fh, in nfsd4_secinfo()
1074 secinfo->si_name, secinfo->si_namelen, in nfsd4_secinfo()
1082 secinfo->si_exp = exp; in nfsd4_secinfo()
1084 if (cstate->minorversion) in nfsd4_secinfo()
1086 fh_put(&cstate->current_fh); in nfsd4_secinfo()
1096 switch (u->secinfo_no_name.sin_style) { in nfsd4_secinfo_no_name()
1100 err = nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_secinfo_no_name()
1108 u->secinfo_no_name.sin_exp = exp_get(cstate->current_fh.fh_export); in nfsd4_secinfo_no_name()
1109 fh_put(&cstate->current_fh); in nfsd4_secinfo_no_name()
1116 if (u->secinfo.si_exp) in nfsd4_secinfo_release()
1117 exp_put(u->secinfo.si_exp); in nfsd4_secinfo_release()
1123 if (u->secinfo_no_name.sin_exp) in nfsd4_secinfo_no_name_release()
1124 exp_put(u->secinfo_no_name.sin_exp); in nfsd4_secinfo_no_name_release()
1131 struct nfsd4_setattr *setattr = &u->setattr; in nfsd4_setattr()
1133 .na_iattr = &setattr->sa_iattr, in nfsd4_setattr()
1134 .na_seclabel = &setattr->sa_label, in nfsd4_setattr()
1141 if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { in nfsd4_setattr()
1143 &cstate->current_fh, &setattr->sa_stateid, in nfsd4_setattr()
1148 err = fh_want_write(&cstate->current_fh); in nfsd4_setattr()
1153 status = check_attr_support(rqstp, cstate, setattr->sa_bmval, in nfsd4_setattr()
1158 inode = cstate->current_fh.fh_dentry->d_inode; in nfsd4_setattr()
1159 status = nfsd4_acl_to_attr(S_ISDIR(inode->i_mode) ? NF4DIR : NF4REG, in nfsd4_setattr()
1160 setattr->sa_acl, &attrs); in nfsd4_setattr()
1164 save_no_wcc = cstate->current_fh.fh_no_wcc; in nfsd4_setattr()
1165 cstate->current_fh.fh_no_wcc = true; in nfsd4_setattr()
1166 status = nfsd_setattr(rqstp, &cstate->current_fh, &attrs, NULL); in nfsd4_setattr()
1167 cstate->current_fh.fh_no_wcc = save_no_wcc; in nfsd4_setattr()
1174 fh_drop_write(&cstate->current_fh); in nfsd4_setattr()
1182 struct nfsd4_write *write = &u->write; in nfsd4_write()
1183 stateid_t *stateid = &write->wr_stateid; in nfsd4_write()
1189 if (write->wr_offset > (u64)OFFSET_MAX || in nfsd4_write()
1190 write->wr_offset + write->wr_buflen > (u64)OFFSET_MAX) in nfsd4_write()
1193 cnt = write->wr_buflen; in nfsd4_write()
1194 trace_nfsd_write_start(rqstp, &cstate->current_fh, in nfsd4_write()
1195 write->wr_offset, cnt); in nfsd4_write()
1196 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_write()
1201 write->wr_how_written = write->wr_stable_how; in nfsd4_write()
1203 nvecs = svc_fill_write_vector(rqstp, &write->wr_payload); in nfsd4_write()
1204 WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); in nfsd4_write()
1206 status = nfsd_vfs_write(rqstp, &cstate->current_fh, nf, in nfsd4_write()
1207 write->wr_offset, rqstp->rq_vec, nvecs, &cnt, in nfsd4_write()
1208 write->wr_how_written, in nfsd4_write()
1209 (__be32 *)write->wr_verifier.data); in nfsd4_write()
1212 write->wr_bytes_written = cnt; in nfsd4_write()
1213 trace_nfsd_write_done(rqstp, &cstate->current_fh, in nfsd4_write()
1214 write->wr_offset, cnt); in nfsd4_write()
1225 if (!cstate->save_fh.fh_dentry) in nfsd4_verify_copy()
1228 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh, in nfsd4_verify_copy()
1233 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_verify_copy()
1238 /* fix up for NFS-specific error code */ in nfsd4_verify_copy()
1239 if (!S_ISREG(file_inode((*src)->nf_file)->i_mode) || in nfsd4_verify_copy()
1240 !S_ISREG(file_inode((*dst)->nf_file)->i_mode)) { in nfsd4_verify_copy()
1260 struct nfsd4_clone *clone = &u->clone; in nfsd4_clone()
1264 status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, in nfsd4_clone()
1265 &clone->cl_dst_stateid, &dst); in nfsd4_clone()
1269 status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos, in nfsd4_clone()
1270 dst, clone->cl_dst_pos, clone->cl_count, in nfsd4_clone()
1271 EX_ISSYNC(cstate->current_fh.fh_export)); in nfsd4_clone()
1281 if (!refcount_dec_and_test(&copy->refcount)) in nfs4_put_copy()
1283 atomic_dec(&copy->cp_nn->pending_async_copies); in nfs4_put_copy()
1284 kfree(copy->cp_src); in nfs4_put_copy()
1290 if (!test_and_set_bit(NFSD4_COPY_F_STOPPED, &copy->cp_flags)) in nfsd4_stop_copy()
1291 kthread_stop(copy->copy_task); in nfsd4_stop_copy()
1299 spin_lock(&clp->async_lock); in nfsd4_get_copy()
1300 if (!list_empty(&clp->async_copies)) { in nfsd4_get_copy()
1301 copy = list_first_entry(&clp->async_copies, struct nfsd4_copy, in nfsd4_get_copy()
1303 refcount_inc(&copy->refcount); in nfsd4_get_copy()
1305 spin_unlock(&clp->async_lock); in nfsd4_get_copy()
1343 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1344 list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) { in nfsd4_ssc_setup_dul()
1345 if (strncmp(ni->nsui_ipaddr, ipaddr, sizeof(ni->nsui_ipaddr))) in nfsd4_ssc_setup_dul()
1348 if (ni->nsui_busy) { in nfsd4_ssc_setup_dul()
1349 /* wait - and try again */ in nfsd4_ssc_setup_dul()
1350 prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, TASK_IDLE); in nfsd4_ssc_setup_dul()
1351 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1353 /* allow 20secs for mount/unmount for now - revisit */ in nfsd4_ssc_setup_dul()
1356 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1360 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1364 refcount_inc(&ni->nsui_refcnt); in nfsd4_ssc_setup_dul()
1365 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1368 /* return vfsmount in (*nsui)->nsui_vfsmount */ in nfsd4_ssc_setup_dul()
1372 strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1); in nfsd4_ssc_setup_dul()
1373 refcount_set(&work->nsui_refcnt, 2); in nfsd4_ssc_setup_dul()
1374 work->nsui_busy = true; in nfsd4_ssc_setup_dul()
1375 list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_ssc_setup_dul()
1379 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1387 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1388 nsui->nsui_vfsmount = ss_mnt; in nfsd4_ssc_update_dul()
1389 nsui->nsui_busy = false; in nfsd4_ssc_update_dul()
1390 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_update_dul()
1391 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1397 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1398 list_del(&nsui->nsui_list); in nfsd4_ssc_cancel_dul()
1399 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_cancel_dul()
1400 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1422 naddr = &nss->u.nl4_addr; in nfsd4_interssc_connect()
1423 tmp_addrlen = rpc_uaddr2sockaddr(SVC_NET(rqstp), naddr->addr, in nfsd4_interssc_connect()
1424 naddr->addr_len, in nfsd4_interssc_connect()
1438 if (naddr->netid_len != match_netid_len || in nfsd4_interssc_connect()
1439 strncmp(naddr->netid, match_netid, naddr->netid_len)) in nfsd4_interssc_connect()
1473 if ((*nsui)->nsui_vfsmount) in nfsd4_interssc_connect()
1476 /* Use an 'internal' mount: SB_KERNMOUNT -> MNT_INTERNAL */ in nfsd4_interssc_connect()
1478 module_put(type->owner); in nfsd4_interssc_connect()
1513 stateid_t *s_stid = &copy->cp_src_stateid; in nfsd4_setup_inter_ssc()
1517 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_setup_inter_ssc()
1518 &copy->cp_dst_stateid, in nfsd4_setup_inter_ssc()
1519 WR_STATE, &copy->nf_dst, NULL); in nfsd4_setup_inter_ssc()
1523 status = nfsd4_interssc_connect(copy->cp_src, rqstp, &copy->ss_nsui); in nfsd4_setup_inter_ssc()
1527 s_fh = &cstate->save_fh; in nfsd4_setup_inter_ssc()
1529 copy->c_fh.size = s_fh->fh_handle.fh_size; in nfsd4_setup_inter_ssc()
1530 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_raw, copy->c_fh.size); in nfsd4_setup_inter_ssc()
1531 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); in nfsd4_setup_inter_ssc()
1532 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque, in nfsd4_setup_inter_ssc()
1544 struct nfsd_net *nn = net_generic(dst->nf_net, nfsd_net_id); in nfsd4_cleanup_inter_ssc()
1550 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1551 list_del(&nsui->nsui_list); in nfsd4_cleanup_inter_ssc()
1557 refcount_dec(&nsui->nsui_refcnt); in nfsd4_cleanup_inter_ssc()
1558 nsui->nsui_expire = jiffies + timeout; in nfsd4_cleanup_inter_ssc()
1559 list_add_tail(&nsui->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_cleanup_inter_ssc()
1560 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1592 return nfsd4_verify_copy(rqstp, cstate, &copy->cp_src_stateid, in nfsd4_setup_intra_ssc()
1593 &copy->nf_src, &copy->cp_dst_stateid, in nfsd4_setup_intra_ssc()
1594 &copy->nf_dst); in nfsd4_setup_intra_ssc()
1611 trace_nfsd_cb_offload_done(&cbo->co_res.cb_stateid, task); in nfsd4_cb_offload_done()
1623 copy->cp_res.wr_stable_how = in nfsd4_init_copy_res()
1624 test_bit(NFSD4_COPY_F_COMMITTED, &copy->cp_flags) ? in nfsd4_init_copy_res()
1635 u64 bytes_total = copy->cp_count; in _nfsd_copy_file_range()
1636 u64 src_pos = copy->cp_src_pos; in _nfsd_copy_file_range()
1637 u64 dst_pos = copy->cp_dst_pos; in _nfsd_copy_file_range()
1652 bytes_total -= bytes_copied; in _nfsd_copy_file_range()
1653 copy->cp_res.wr_bytes_written += bytes_copied; in _nfsd_copy_file_range()
1657 /* for a non-zero asynchronous copy do a commit of data */ in _nfsd_copy_file_range()
1658 if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) { in _nfsd_copy_file_range()
1659 since = READ_ONCE(dst->f_wb_err); in _nfsd_copy_file_range()
1660 end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1; in _nfsd_copy_file_range()
1661 status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0); in _nfsd_copy_file_range()
1663 status = filemap_check_wb_err(dst->f_mapping, since); in _nfsd_copy_file_range()
1665 set_bit(NFSD4_COPY_F_COMMITTED, &copy->cp_flags); in _nfsd_copy_file_range()
1682 if (bytes < 0 && !copy->cp_res.wr_bytes_written) in nfsd4_do_copy()
1693 dst->cp_src_pos = src->cp_src_pos; in dup_copy_fields()
1694 dst->cp_dst_pos = src->cp_dst_pos; in dup_copy_fields()
1695 dst->cp_count = src->cp_count; in dup_copy_fields()
1696 dst->cp_flags = src->cp_flags; in dup_copy_fields()
1697 memcpy(&dst->cp_res, &src->cp_res, sizeof(src->cp_res)); in dup_copy_fields()
1698 memcpy(&dst->fh, &src->fh, sizeof(src->fh)); in dup_copy_fields()
1699 dst->cp_clp = src->cp_clp; in dup_copy_fields()
1700 dst->nf_dst = nfsd_file_get(src->nf_dst); in dup_copy_fields()
1703 dst->nf_src = nfsd_file_get(src->nf_src); in dup_copy_fields()
1705 memcpy(&dst->cp_stateid, &src->cp_stateid, sizeof(src->cp_stateid)); in dup_copy_fields()
1706 memcpy(dst->cp_src, src->cp_src, sizeof(struct nl4_server)); in dup_copy_fields()
1707 memcpy(&dst->stateid, &src->stateid, sizeof(src->stateid)); in dup_copy_fields()
1708 memcpy(&dst->c_fh, &src->c_fh, sizeof(src->c_fh)); in dup_copy_fields()
1709 dst->ss_nsui = src->ss_nsui; in dup_copy_fields()
1714 if (copy->nf_src) in release_copy_files()
1715 nfsd_file_put(copy->nf_src); in release_copy_files()
1716 if (copy->nf_dst) in release_copy_files()
1717 nfsd_file_put(copy->nf_dst); in release_copy_files()
1724 if (copy->cp_clp) { in cleanup_async_copy()
1725 spin_lock(&copy->cp_clp->async_lock); in cleanup_async_copy()
1726 if (!list_empty(&copy->copies)) in cleanup_async_copy()
1727 list_del_init(&copy->copies); in cleanup_async_copy()
1728 spin_unlock(&copy->cp_clp->async_lock); in cleanup_async_copy()
1741 memcpy(&cbo->co_res, &copy->cp_res, sizeof(copy->cp_res)); in nfsd4_send_cb_offload()
1742 memcpy(&cbo->co_fh, &copy->fh, sizeof(copy->fh)); in nfsd4_send_cb_offload()
1743 cbo->co_nfserr = copy->nfserr; in nfsd4_send_cb_offload()
1745 nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops, in nfsd4_send_cb_offload()
1747 trace_nfsd_cb_offload(copy->cp_clp, &cbo->co_res.cb_stateid, in nfsd4_send_cb_offload()
1748 &cbo->co_fh, copy->cp_count, copy->nfserr); in nfsd4_send_cb_offload()
1749 nfsd4_run_cb(&cbo->co_cb); in nfsd4_send_cb_offload()
1753 * nfsd4_do_async_copy - kthread function for background server-side COPY
1767 filp = nfs42_ssc_open(copy->ss_nsui->nsui_vfsmount, in nfsd4_do_async_copy()
1768 &copy->c_fh, &copy->stateid); in nfsd4_do_async_copy()
1771 case -EBADF: in nfsd4_do_async_copy()
1772 copy->nfserr = nfserr_wrong_type; in nfsd4_do_async_copy()
1775 copy->nfserr = nfserr_offload_denied; in nfsd4_do_async_copy()
1780 copy->nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file, in nfsd4_do_async_copy()
1782 nfsd4_cleanup_inter_ssc(copy->ss_nsui, filp, copy->nf_dst); in nfsd4_do_async_copy()
1784 copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_do_async_copy()
1785 copy->nf_dst->nf_file, false); in nfsd4_do_async_copy()
1789 set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags); in nfsd4_do_async_copy()
1802 struct nfsd4_copy *copy = &u->copy; in nfsd4_copy()
1813 result = &copy->cp_res; in nfsd4_copy()
1814 nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn); in nfsd4_copy()
1816 copy->cp_clp = cstate->clp; in nfsd4_copy()
1837 memcpy(&copy->fh, &cstate->current_fh.fh_handle, in nfsd4_copy()
1843 async_copy->cp_nn = nn; in nfsd4_copy()
1844 INIT_LIST_HEAD(&async_copy->copies); in nfsd4_copy()
1845 refcount_set(&async_copy->refcount, 1); in nfsd4_copy()
1847 if (atomic_inc_return(&nn->pending_async_copies) > in nfsd4_copy()
1848 (int)rqstp->rq_pool->sp_nrthreads) in nfsd4_copy()
1850 async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); in nfsd4_copy()
1851 if (!async_copy->cp_src) in nfsd4_copy()
1855 memcpy(&result->cb_stateid, &copy->cp_stateid.cs_stid, in nfsd4_copy()
1856 sizeof(result->cb_stateid)); in nfsd4_copy()
1858 async_copy->copy_task = kthread_create(nfsd4_do_async_copy, in nfsd4_copy()
1860 if (IS_ERR(async_copy->copy_task)) in nfsd4_copy()
1862 spin_lock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1863 list_add(&async_copy->copies, in nfsd4_copy()
1864 &async_copy->cp_clp->async_copies); in nfsd4_copy()
1865 spin_unlock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1866 wake_up_process(async_copy->copy_task); in nfsd4_copy()
1869 status = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_copy()
1870 copy->nf_dst->nf_file, true); in nfsd4_copy()
1879 * Source's vfsmount of inter-copy will be unmounted in nfsd4_copy()
1881 * since async_copy->ss_nsui might not be set yet. in nfsd4_copy()
1883 refcount_dec(&copy->ss_nsui->nsui_refcnt); in nfsd4_copy()
1896 lockdep_assert_held(&clp->async_lock); in find_async_copy_locked()
1898 list_for_each_entry(copy, &clp->async_copies, copies) { in find_async_copy_locked()
1899 if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE)) in find_async_copy_locked()
1911 spin_lock(&clp->async_lock); in find_async_copy()
1914 refcount_inc(&copy->refcount); in find_async_copy()
1915 spin_unlock(&clp->async_lock); in find_async_copy()
1924 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_cancel()
1926 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_cancel()
1928 copy = find_async_copy(clp, &os->stateid); in nfsd4_offload_cancel()
1932 return manage_cpntf_state(nn, &os->stateid, clp, NULL); in nfsd4_offload_cancel()
1943 struct nfsd4_copy_notify *cn = &u->copy_notify; in nfsd4_copy_notify()
1948 struct nfs4_client *clp = cstate->clp; in nfsd4_copy_notify()
1950 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_copy_notify()
1951 &cn->cpn_src_stateid, RD_STATE, NULL, in nfsd4_copy_notify()
1958 cn->cpn_lease_time.tv_sec = nn->nfsd4_lease; in nfsd4_copy_notify()
1959 cn->cpn_lease_time.tv_nsec = 0; in nfsd4_copy_notify()
1961 status = nfserrno(-ENOMEM); in nfsd4_copy_notify()
1965 memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t)); in nfsd4_copy_notify()
1966 memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t)); in nfsd4_copy_notify()
1967 memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t)); in nfsd4_copy_notify()
1972 cn->cpn_src->nl4_type = NL4_NETADDR; in nfsd4_copy_notify()
1973 status = nfsd4_set_netaddr((struct sockaddr *)&rqstp->rq_daddr, in nfsd4_copy_notify()
1974 &cn->cpn_src->u.nl4_addr); in nfsd4_copy_notify()
1992 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_fallocate()
1993 &fallocate->falloc_stateid, in nfsd4_fallocate()
1998 status = nfsd4_vfs_fallocate(rqstp, &cstate->current_fh, nf->nf_file, in nfsd4_fallocate()
1999 fallocate->falloc_offset, in nfsd4_fallocate()
2000 fallocate->falloc_length, in nfsd4_fallocate()
2011 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_status()
2014 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_status()
2016 os->completed = false; in nfsd4_offload_status()
2017 spin_lock(&clp->async_lock); in nfsd4_offload_status()
2018 copy = find_async_copy_locked(clp, &os->stateid); in nfsd4_offload_status()
2020 os->count = copy->cp_res.wr_bytes_written; in nfsd4_offload_status()
2021 if (test_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags)) { in nfsd4_offload_status()
2022 os->completed = true; in nfsd4_offload_status()
2023 os->status = copy->nfserr; in nfsd4_offload_status()
2027 spin_unlock(&clp->async_lock); in nfsd4_offload_status()
2036 return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); in nfsd4_allocate()
2043 return nfsd4_fallocate(rqstp, cstate, &u->deallocate, in nfsd4_deallocate()
2051 struct nfsd4_seek *seek = &u->seek; in nfsd4_seek()
2056 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_seek()
2057 &seek->seek_stateid, in nfsd4_seek()
2062 switch (seek->seek_whence) { in nfsd4_seek()
2075 * Note: This call does change file->f_pos, but nothing in NFSD in nfsd4_seek()
2076 * should ever file->f_pos. in nfsd4_seek()
2078 seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence); in nfsd4_seek()
2079 if (seek->seek_pos < 0) in nfsd4_seek()
2080 status = nfserrno(seek->seek_pos); in nfsd4_seek()
2081 else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file))) in nfsd4_seek()
2082 seek->seek_eof = true; in nfsd4_seek()
2102 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in _nfsd4_verify()
2106 status = check_attr_support(rqstp, cstate, verify->ve_bmval, NULL); in _nfsd4_verify()
2110 if ((verify->ve_bmval[0] & FATTR4_WORD0_RDATTR_ERROR) in _nfsd4_verify()
2111 || (verify->ve_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)) in _nfsd4_verify()
2113 if (verify->ve_attrlen & 3) in _nfsd4_verify()
2119 count = 4 + (verify->ve_attrlen >> 2); in _nfsd4_verify()
2125 status = nfsd4_encode_fattr_to_buf(&p, count, &cstate->current_fh, in _nfsd4_verify()
2126 cstate->current_fh.fh_export, in _nfsd4_verify()
2127 cstate->current_fh.fh_dentry, in _nfsd4_verify()
2128 verify->ve_bmval, in _nfsd4_verify()
2142 if (ntohl(*p++) != verify->ve_attrlen) in _nfsd4_verify()
2144 if (!memcmp(p, verify->ve_attrval, verify->ve_attrlen)) in _nfsd4_verify()
2158 status = _nfsd4_verify(rqstp, cstate, &u->verify); in nfsd4_nverify()
2168 status = _nfsd4_verify(rqstp, cstate, &u->nverify); in nfsd4_verify()
2177 struct nfsd4_get_dir_delegation *gdd = &u->get_dir_delegation; in nfsd4_get_dir_delegation()
2185 * This is sub-optimal, since it means that the server would need to in nfsd4_get_dir_delegation()
2186 * abort compound processing just because the delegation wasn't in nfsd4_get_dir_delegation()
2188 * return NFS4_OK with a non-fatal status of GDD4_UNAVAIL in this in nfsd4_get_dir_delegation()
2191 gdd->gddrnf_status = GDD4_UNAVAIL; in nfsd4_get_dir_delegation()
2199 if (!exp->ex_layout_types) { in nfsd4_layout_verify()
2205 !(exp->ex_layout_types & (1 << layout_type))) { in nfsd4_layout_verify()
2218 struct nfsd4_getdeviceinfo *gdp = &u->getdeviceinfo; in nfsd4_getdeviceinfo()
2226 gdp->gd_layout_type, in nfsd4_getdeviceinfo()
2227 gdp->gd_devid.fsid_idx, gdp->gd_devid.generation, in nfsd4_getdeviceinfo()
2228 gdp->gd_maxcount); in nfsd4_getdeviceinfo()
2230 map = nfsd4_find_devid_map(gdp->gd_devid.fsid_idx); in nfsd4_getdeviceinfo()
2232 dprintk("%s: couldn't find device ID to export mapping!\n", in nfsd4_getdeviceinfo()
2237 exp = rqst_exp_find(&rqstp->rq_chandle, SVC_NET(rqstp), in nfsd4_getdeviceinfo()
2238 rqstp->rq_client, rqstp->rq_gssclient, in nfsd4_getdeviceinfo()
2239 map->fsid_type, map->fsid); in nfsd4_getdeviceinfo()
2241 dprintk("%s: could not find device id\n", __func__); in nfsd4_getdeviceinfo()
2246 ops = nfsd4_layout_verify(exp, gdp->gd_layout_type); in nfsd4_getdeviceinfo()
2251 if (gdp->gd_maxcount != 0) { in nfsd4_getdeviceinfo()
2252 nfserr = ops->proc_getdeviceinfo(exp->ex_path.mnt->mnt_sb, in nfsd4_getdeviceinfo()
2253 rqstp, cstate->clp, gdp); in nfsd4_getdeviceinfo()
2256 gdp->gd_notify_types &= ops->notify_types; in nfsd4_getdeviceinfo()
2265 kfree(u->getdeviceinfo.gd_device); in nfsd4_getdeviceinfo_release()
2272 struct nfsd4_layoutget *lgp = &u->layoutget; in nfsd4_layoutget()
2273 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutget()
2279 switch (lgp->lg_seg.iomode) { in nfsd4_layoutget()
2288 __func__, lgp->lg_seg.iomode); in nfsd4_layoutget()
2298 ops = nfsd4_layout_verify(current_fh->fh_export, lgp->lg_layout_type); in nfsd4_layoutget()
2314 if (lgp->lg_seg.length < lgp->lg_minlength || in nfsd4_layoutget()
2315 (lgp->lg_minlength != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2316 lgp->lg_minlength > NFS4_MAX_UINT64 - lgp->lg_seg.offset) || in nfsd4_layoutget()
2317 (lgp->lg_seg.length != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2318 lgp->lg_seg.length > NFS4_MAX_UINT64 - lgp->lg_seg.offset)) in nfsd4_layoutget()
2320 if (lgp->lg_seg.length == 0) in nfsd4_layoutget()
2323 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid, in nfsd4_layoutget()
2324 true, lgp->lg_layout_type, &ls); in nfsd4_layoutget()
2326 trace_nfsd_layout_get_lookup_fail(&lgp->lg_sid); in nfsd4_layoutget()
2331 if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls)) in nfsd4_layoutget()
2334 nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry), in nfsd4_layoutget()
2342 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutget()
2343 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutget()
2351 kfree(u->layoutget.lg_content); in nfsd4_layoutget_release()
2358 struct nfsd4_layoutcommit *lcp = &u->layoutcommit; in nfsd4_layoutcommit()
2359 const struct nfsd4_layout_seg *seg = &lcp->lc_seg; in nfsd4_layoutcommit()
2360 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutcommit()
2362 loff_t new_size = lcp->lc_last_wr + 1; in nfsd4_layoutcommit()
2373 ops = nfsd4_layout_verify(current_fh->fh_export, lcp->lc_layout_type); in nfsd4_layoutcommit()
2376 inode = d_inode(current_fh->fh_dentry); in nfsd4_layoutcommit()
2379 if (new_size <= seg->offset) { in nfsd4_layoutcommit()
2383 if (new_size > seg->offset + seg->length) { in nfsd4_layoutcommit()
2387 if (!lcp->lc_newoffset && new_size > i_size_read(inode)) { in nfsd4_layoutcommit()
2392 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lcp->lc_sid, in nfsd4_layoutcommit()
2393 false, lcp->lc_layout_type, in nfsd4_layoutcommit()
2396 trace_nfsd_layout_commit_lookup_fail(&lcp->lc_sid); in nfsd4_layoutcommit()
2404 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutcommit()
2407 lcp->lc_size_chg = true; in nfsd4_layoutcommit()
2408 lcp->lc_newsize = new_size; in nfsd4_layoutcommit()
2410 lcp->lc_size_chg = false; in nfsd4_layoutcommit()
2413 nfserr = ops->proc_layoutcommit(inode, lcp); in nfsd4_layoutcommit()
2414 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutcommit()
2423 struct nfsd4_layoutreturn *lrp = &u->layoutreturn; in nfsd4_layoutreturn()
2424 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutreturn()
2432 if (!nfsd4_layout_verify(current_fh->fh_export, lrp->lr_layout_type)) in nfsd4_layoutreturn()
2435 switch (lrp->lr_seg.iomode) { in nfsd4_layoutreturn()
2442 lrp->lr_seg.iomode); in nfsd4_layoutreturn()
2447 switch (lrp->lr_return_type) { in nfsd4_layoutreturn()
2457 lrp->lr_return_type); in nfsd4_layoutreturn()
2470 struct nfsd4_getxattr *getxattr = &u->getxattr; in nfsd4_getxattr()
2472 return nfsd_getxattr(rqstp, &cstate->current_fh, in nfsd4_getxattr()
2473 getxattr->getxa_name, &getxattr->getxa_buf, in nfsd4_getxattr()
2474 &getxattr->getxa_len); in nfsd4_getxattr()
2481 struct nfsd4_setxattr *setxattr = &u->setxattr; in nfsd4_setxattr()
2487 ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name, in nfsd4_setxattr()
2488 setxattr->setxa_buf, setxattr->setxa_len, in nfsd4_setxattr()
2489 setxattr->setxa_flags); in nfsd4_setxattr()
2492 set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh); in nfsd4_setxattr()
2505 return nfsd_listxattr(rqstp, &cstate->current_fh, in nfsd4_listxattrs()
2506 &u->listxattrs.lsxa_buf, &u->listxattrs.lsxa_len); in nfsd4_listxattrs()
2513 struct nfsd4_removexattr *removexattr = &u->removexattr; in nfsd4_removexattr()
2519 ret = nfsd_removexattr(rqstp, &cstate->current_fh, in nfsd4_removexattr()
2520 removexattr->rmxa_name); in nfsd4_removexattr()
2523 set_change_info(&removexattr->rmxa_cinfo, &cstate->current_fh); in nfsd4_removexattr()
2540 percpu_counter_inc(&nn->counter[NFSD_STATS_NFS4_OP(opnum)]); in nfsd4_increment_op_stats()
2548 * Enforce NFSv4.1 COMPOUND ordering rules:
2551 * - SEQUENCE other than as first op results in
2553 * - BIND_CONN_TO_SESSION must be the only op in its compound.
2555 * - DESTROY_SESSION must be the final operation in a compound, if
2561 struct nfsd4_op *first_op = &args->ops[0]; in nfs41_check_op_ordering()
2564 if (args->minorversion == 0) in nfs41_check_op_ordering()
2567 if (args->opcnt == 0) in nfs41_check_op_ordering()
2569 if (first_op->status == nfserr_op_illegal) in nfs41_check_op_ordering()
2571 if (!(nfsd4_ops[first_op->opnum].op_flags & ALLOWED_AS_FIRST_OP)) in nfs41_check_op_ordering()
2573 if (first_op->opnum == OP_SEQUENCE) in nfs41_check_op_ordering()
2578 * compound: in nfs41_check_op_ordering()
2580 if (args->opcnt != 1) in nfs41_check_op_ordering()
2587 return &nfsd4_ops[op->opnum]; in OPDESC()
2592 if (op->opnum == OP_ILLEGAL) in nfsd4_cache_this_op()
2594 return OPDESC(op)->op_flags & OP_CACHEME; in nfsd4_cache_this_op()
2599 struct nfsd4_compoundres *resp = rqstp->rq_resp; in need_wrongsec_check()
2600 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in need_wrongsec_check()
2601 struct nfsd4_op *this = &argp->ops[resp->opcnt - 1]; in need_wrongsec_check()
2602 struct nfsd4_op *next = &argp->ops[resp->opcnt]; in need_wrongsec_check()
2607 * Most ops check wronsec on our own; only the putfh-like ops in need_wrongsec_check()
2610 if (!(thisd->op_flags & OP_IS_PUTFH_LIKE)) in need_wrongsec_check()
2614 * put-filehandle operation if we're not going to use the in need_wrongsec_check()
2617 if (argp->opcnt == resp->opcnt) in need_wrongsec_check()
2619 if (next->opnum == OP_ILLEGAL) in need_wrongsec_check()
2627 return !(nextd->op_flags & OP_HANDLES_WRONGSEC); in need_wrongsec_check()
2639 /* traverse all operation and if it's a COPY compound, mark the in check_if_stalefh_allowed()
2642 for (i = 0; i < args->opcnt; i++) { in check_if_stalefh_allowed()
2643 op = &args->ops[i]; in check_if_stalefh_allowed()
2644 if (op->opnum == OP_PUTFH) in check_if_stalefh_allowed()
2646 else if (op->opnum == OP_SAVEFH) in check_if_stalefh_allowed()
2648 else if (op->opnum == OP_RESTOREFH) in check_if_stalefh_allowed()
2650 else if (op->opnum == OP_COPY) { in check_if_stalefh_allowed()
2651 copy = (struct nfsd4_copy *)&op->u; in check_if_stalefh_allowed()
2653 op->status = nfserr_nofilehandle; in check_if_stalefh_allowed()
2656 putfh = (struct nfsd4_putfh *)&saved_op->u; in check_if_stalefh_allowed()
2658 putfh->no_verify = true; in check_if_stalefh_allowed()
2670 * COMPOUND call.
2675 struct nfsd4_compoundargs *args = rqstp->rq_argp; in nfsd4_proc_compound()
2676 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_proc_compound()
2678 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_proc_compound()
2679 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_proc_compound()
2680 struct svc_fh *save_fh = &cstate->save_fh; in nfsd4_proc_compound()
2684 resp->xdr = &rqstp->rq_res_stream; in nfsd4_proc_compound()
2685 resp->statusp = resp->xdr->p; in nfsd4_proc_compound()
2688 xdr_reserve_space(resp->xdr, XDR_UNIT); in nfsd4_proc_compound()
2691 xdr_reserve_space(resp->xdr, XDR_UNIT * 2 + args->taglen); in nfsd4_proc_compound()
2692 resp->taglen = args->taglen; in nfsd4_proc_compound()
2693 resp->tag = args->tag; in nfsd4_proc_compound()
2694 resp->rqstp = rqstp; in nfsd4_proc_compound()
2695 cstate->minorversion = args->minorversion; in nfsd4_proc_compound()
2700 * too hard to avoid non-idempotency problems. in nfsd4_proc_compound()
2702 clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2708 if (nfsd_minorversion(nn, args->minorversion, NFSD_TEST) <= 0) in nfsd4_proc_compound()
2713 op = &args->ops[0]; in nfsd4_proc_compound()
2714 op->status = status; in nfsd4_proc_compound()
2715 resp->opcnt = 1; in nfsd4_proc_compound()
2720 rqstp->rq_lease_breaker = (void **)&cstate->clp; in nfsd4_proc_compound()
2722 trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt); in nfsd4_proc_compound()
2723 while (!status && resp->opcnt < args->opcnt) { in nfsd4_proc_compound()
2724 op = &args->ops[resp->opcnt++]; in nfsd4_proc_compound()
2726 if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) { in nfsd4_proc_compound()
2729 if (cstate->minorversion == 0 && in nfsd4_proc_compound()
2730 args->client_opcnt > resp->opcnt) { in nfsd4_proc_compound()
2731 op->status = nfserr_resource; in nfsd4_proc_compound()
2737 * The XDR decode routines may have pre-set op->status; in nfsd4_proc_compound()
2741 if (op->status) { in nfsd4_proc_compound()
2742 if (op->opnum == OP_OPEN) in nfsd4_proc_compound()
2743 op->status = nfsd4_open_omfg(rqstp, cstate, op); in nfsd4_proc_compound()
2746 if (!current_fh->fh_dentry && in nfsd4_proc_compound()
2748 if (!(op->opdesc->op_flags & ALLOWED_WITHOUT_FH)) { in nfsd4_proc_compound()
2749 op->status = nfserr_nofilehandle; in nfsd4_proc_compound()
2752 } else if (current_fh->fh_export && in nfsd4_proc_compound()
2753 current_fh->fh_export->ex_fslocs.migrated && in nfsd4_proc_compound()
2754 !(op->opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) { in nfsd4_proc_compound()
2755 op->status = nfserr_moved; in nfsd4_proc_compound()
2761 /* If op is non-idempotent */ in nfsd4_proc_compound()
2762 if (op->opdesc->op_flags & OP_MODIFIES_SOMETHING) { in nfsd4_proc_compound()
2767 u32 plen = op->opdesc->op_rsize_bop(rqstp, op); in nfsd4_proc_compound()
2772 if (resp->opcnt < args->opcnt) in nfsd4_proc_compound()
2774 op->status = nfsd4_check_resp_size(resp, plen); in nfsd4_proc_compound()
2777 if (op->status) in nfsd4_proc_compound()
2780 if (op->opdesc->op_get_currentstateid) in nfsd4_proc_compound()
2781 op->opdesc->op_get_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2782 op->status = op->opdesc->op_func(rqstp, cstate, &op->u); in nfsd4_proc_compound()
2785 if (cstate->status == nfserr_replay_cache) { in nfsd4_proc_compound()
2787 status = op->status; in nfsd4_proc_compound()
2790 if (!op->status) { in nfsd4_proc_compound()
2791 if (op->opdesc->op_set_currentstateid) in nfsd4_proc_compound()
2792 op->opdesc->op_set_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2794 if (op->opdesc->op_flags & OP_CLEAR_STATEID) in nfsd4_proc_compound()
2797 if (current_fh->fh_export && in nfsd4_proc_compound()
2799 op->status = check_nfsd_access(current_fh->fh_export, rqstp); in nfsd4_proc_compound()
2802 if (op->status == nfserr_replay_me) { in nfsd4_proc_compound()
2803 op->replay = &cstate->replay_owner->so_replay; in nfsd4_proc_compound()
2804 nfsd4_encode_replay(resp->xdr, op); in nfsd4_proc_compound()
2805 status = op->status = op->replay->rp_status; in nfsd4_proc_compound()
2808 status = op->status; in nfsd4_proc_compound()
2811 trace_nfsd_compound_status(args->client_opcnt, resp->opcnt, in nfsd4_proc_compound()
2812 status, nfsd4_op_name(op->opnum)); in nfsd4_proc_compound()
2815 nfsd4_increment_op_stats(nn, op->opnum); in nfsd4_proc_compound()
2820 BUG_ON(cstate->replay_owner); in nfsd4_proc_compound()
2822 cstate->status = status; in nfsd4_proc_compound()
2824 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2847 * The _rsize() helpers are invoked by the NFSv4 COMPOUND decoder, which
2856 buflen = (rqstp->rq_page_end - rqstp->rq_next_page) * PAGE_SIZE; in nfsd4_max_payload()
2857 buflen -= rqstp->rq_auth_slack; in nfsd4_max_payload()
2858 buflen -= rqstp->rq_res.head[0].iov_len; in nfsd4_max_payload()
2902 const u32 *bmap = op->u.getattr.ga_bmval; in nfsd4_getattr_rsize()
2969 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_rsize()
2977 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_plus_rsize()
2991 u32 rlen = min(op->u.readdir.rd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_readdir_rsize()
3027 return (op_encode_hdr_size + 1 + op->u.test_stateid.ts_num_ids) in nfsd4_test_stateid_rsize()
3142 u32 rlen = min(op->u.getdeviceinfo.gd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_getdeviceinfo_rsize()
3206 u32 rlen = min(op->u.listxattrs.lsxa_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_listxattrs_rsize()
3640 * nfsd4_spo_must_allow - Determine if the compound op contains an
3645 * Checks to see if the compound contains a spo_must_allow op
3651 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_spo_must_allow()
3652 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_spo_must_allow()
3654 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_spo_must_allow()
3655 struct nfs4_op_map *allow = &cstate->clp->cl_spo_must_allow; in nfsd4_spo_must_allow()
3658 if (!cstate->minorversion) in nfsd4_spo_must_allow()
3661 if (cstate->spo_must_allowed) in nfsd4_spo_must_allow()
3664 opiter = resp->opcnt; in nfsd4_spo_must_allow()
3665 while (opiter < argp->opcnt) { in nfsd4_spo_must_allow()
3666 this = &argp->ops[opiter++]; in nfsd4_spo_must_allow()
3667 if (test_bit(this->opnum, allow->u.longs) && in nfsd4_spo_must_allow()
3668 cstate->clp->cl_mach_cred && in nfsd4_spo_must_allow()
3669 nfsd4_mach_creds_match(cstate->clp, rqstp)) { in nfsd4_spo_must_allow()
3670 cstate->spo_must_allowed = true; in nfsd4_spo_must_allow()
3674 cstate->spo_must_allowed = false; in nfsd4_spo_must_allow()
3680 if (op->opnum == OP_ILLEGAL || op->status == nfserr_notsupp) in nfsd4_max_reply()
3683 BUG_ON(OPDESC(op)->op_rsize_bop == NULL); in nfsd4_max_reply()
3684 return OPDESC(op)->op_rsize_bop(rqstp, op); in nfsd4_max_reply()
3689 if (OPDESC(op)->op_flags & OP_MODIFIES_SOMETHING) { in warn_on_nonidempotent_op()
3691 op->opnum, nfsd4_op_name(op->opnum)); in warn_on_nonidempotent_op()
3725 .pc_name = "COMPOUND",