Lines Matching +full:compound +full:- +full:device

2  *  Server-side procedures for NFSv4.
87 struct dentry *dentry = cstate->current_fh.fh_dentry; in check_attr_support()
88 struct svc_export *exp = cstate->current_fh.fh_export; in check_attr_support()
90 if (!nfsd_attrs_supported(cstate->minorversion, bmval)) in check_attr_support()
95 !(exp->ex_flags & NFSEXP_SECURITY_LABEL)) in check_attr_support()
111 if (open->op_create == NFS4_OPEN_CREATE) { in nfsd4_check_open_attributes()
112 if (open->op_createmode == NFS4_CREATE_UNCHECKED in nfsd4_check_open_attributes()
113 || open->op_createmode == NFS4_CREATE_GUARDED) in nfsd4_check_open_attributes()
115 open->op_bmval, nfsd_attrmask); in nfsd4_check_open_attributes()
116 else if (open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1) in nfsd4_check_open_attributes()
118 open->op_bmval, nfsd41_ex_attrmask); in nfsd4_check_open_attributes()
127 return open->op_create == NFS4_OPEN_CREATE in is_create_with_attrs()
128 && (open->op_createmode == NFS4_CREATE_UNCHECKED in is_create_with_attrs()
129 || open->op_createmode == NFS4_CREATE_GUARDED in is_create_with_attrs()
130 || open->op_createmode == NFS4_CREATE_EXCLUSIVE4_1); in is_create_with_attrs()
137 dget(src->fh_dentry); in fh_dup2()
138 if (src->fh_export) in fh_dup2()
139 exp_get(src->fh_export); in fh_dup2()
147 if (open->op_truncate && in do_open_permission()
148 !(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) in do_open_permission()
153 if (open->op_share_access & NFS4_SHARE_ACCESS_READ) in do_open_permission()
155 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) in do_open_permission()
157 if (open->op_share_deny & NFS4_SHARE_DENY_READ) in do_open_permission()
165 umode_t mode = d_inode(fh->fh_dentry)->i_mode; in nfsd_check_obj_isreg()
174 /* RFC 7530 - 16.16.6 */ in nfsd_check_obj_isreg()
186 fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh, in nfsd4_set_open_owner_reply_cache()
187 &resfh->fh_handle); in nfsd4_set_open_owner_reply_cache()
205 switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { in nfsd4_vfs_create()
216 path.mnt = fhp->fh_export->ex_path.mnt; in nfsd4_vfs_create()
218 filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, in nfsd4_vfs_create()
223 open->op_filp = filp; in nfsd4_vfs_create()
238 struct iattr *iap = &open->op_iattr; in nfsd4_create_file()
241 .na_seclabel = &open->op_label, in nfsd4_create_file()
249 if (isdotent(open->op_fname, open->op_fnamelen)) in nfsd4_create_file()
251 if (!(iap->ia_valid & ATTR_MODE)) in nfsd4_create_file()
252 iap->ia_mode = 0; in nfsd4_create_file()
257 parent = fhp->fh_dentry; in nfsd4_create_file()
265 nfsd4_acl_to_attr(NF4REG, open->op_acl, &attrs); in nfsd4_create_file()
269 child = lookup_one_len(open->op_fname, parent, open->op_fnamelen); in nfsd4_create_file()
281 status = fh_compose(resfhp, fhp->fh_export, child, fhp); in nfsd4_create_file()
287 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
288 u32 *verifier = (u32 *)open->op_verf.data; in nfsd4_create_file()
310 switch (open->op_createmode) { in nfsd4_create_file()
321 open->op_truncate = (iap->ia_valid & ATTR_SIZE) && in nfsd4_create_file()
322 !iap->ia_size; in nfsd4_create_file()
330 d_inode(child)->i_size == 0) { in nfsd4_create_file()
331 open->op_created = true; in nfsd4_create_file()
339 d_inode(child)->i_size == 0) { in nfsd4_create_file()
340 open->op_created = true; in nfsd4_create_file()
349 iap->ia_mode &= ~current_umask(); in nfsd4_create_file()
357 open->op_created = true; in nfsd4_create_file()
361 if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0)) in nfsd4_create_file()
362 iap->ia_valid &= ~ATTR_SIZE; in nfsd4_create_file()
363 if (nfsd4_create_is_exclusive(open->op_createmode)) { in nfsd4_create_file()
364 iap->ia_valid = ATTR_MTIME | ATTR_ATIME | in nfsd4_create_file()
366 iap->ia_mtime.tv_sec = v_mtime; in nfsd4_create_file()
367 iap->ia_atime.tv_sec = v_atime; in nfsd4_create_file()
368 iap->ia_mtime.tv_nsec = 0; in nfsd4_create_file()
369 iap->ia_atime.tv_nsec = 0; in nfsd4_create_file()
376 open->op_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create_file()
378 open->op_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create_file()
389 * set_change_info - set up the change_info4 for a reply
395 * the event that we didn't get any pre-attrs, just zero out both.
400 cinfo->atomic = (u32)(fhp->fh_pre_saved && fhp->fh_post_saved && !fhp->fh_no_atomic_attr); in set_change_info()
401 cinfo->before_change = fhp->fh_pre_change; in set_change_info()
402 cinfo->after_change = fhp->fh_post_change; in set_change_info()
405 * If fetching the pre-change attributes failed, then we should in set_change_info()
407 * failed to fetch post-change attributes however. in set_change_info()
409 * If we didn't get post-op attrs, just zero-out the after in set_change_info()
414 if (WARN_ON_ONCE(!fhp->fh_pre_saved)) in set_change_info()
415 cinfo->before_change = 0; in set_change_info()
416 if (!fhp->fh_post_saved) in set_change_info()
417 cinfo->after_change = cinfo->before_change + 1; in set_change_info()
423 struct svc_fh *current_fh = &cstate->current_fh; in do_open_lookup()
431 open->op_truncate = false; in do_open_lookup()
433 if (open->op_create) { in do_open_lookup()
439 * -------------+--------+-----------------+-------------------- in do_open_lookup()
449 current->fs->umask = open->op_umask; in do_open_lookup()
451 current->fs->umask = 0; in do_open_lookup()
458 if (nfsd4_create_is_exclusive(open->op_createmode) && status == 0) in do_open_lookup()
459 open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS | in do_open_lookup()
463 open->op_fname, open->op_fnamelen, *resfh); in do_open_lookup()
472 status = nfsd_check_obj_isreg(*resfh, cstate->minorversion); in do_open_lookup()
478 if (open->op_created || in do_open_lookup()
479 open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) in do_open_lookup()
482 set_change_info(&open->op_cinfo, current_fh); in do_open_lookup()
490 struct svc_fh *current_fh = &cstate->current_fh; in do_open_fhandle()
497 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); in do_open_fhandle()
501 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && in do_open_fhandle()
502 (open->op_iattr.ia_size == 0); in do_open_fhandle()
512 if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH) in do_open_fhandle()
522 (struct nfsd4_sessionid *)session->se_sessionid.data; in copy_clientid()
524 clid->cl_boot = sid->clientid.cl_boot; in copy_clientid()
525 clid->cl_id = sid->clientid.cl_id; in copy_clientid()
532 struct nfsd4_open *open = &u->open; in nfsd4_open()
540 (int)open->op_fnamelen, open->op_fname, in nfsd4_open()
541 open->op_openowner); in nfsd4_open()
543 open->op_filp = NULL; in nfsd4_open()
544 open->op_rqstp = rqstp; in nfsd4_open()
547 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) in nfsd4_open()
550 open->op_created = false; in nfsd4_open()
556 !test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &cstate->clp->cl_flags) && in nfsd4_open()
557 open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
561 copy_clientid(&open->op_clientid, cstate->session); in nfsd4_open()
566 struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay; in nfsd4_open()
567 fh_put(&cstate->current_fh); in nfsd4_open()
568 fh_copy_shallow(&cstate->current_fh.fh_handle, in nfsd4_open()
569 &rp->rp_openfh); in nfsd4_open()
570 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_open()
579 if (open->op_xdr_error) { in nfsd4_open()
580 status = open->op_xdr_error; in nfsd4_open()
591 if (opens_in_grace(net) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
594 if (!opens_in_grace(net) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_open()
597 switch (open->op_claim_type) { in nfsd4_open()
605 status = nfs4_check_open_reclaim(cstate->clp); in nfsd4_open()
608 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_open()
616 resfh = &cstate->current_fh; in nfsd4_open()
628 if (status && open->op_created) in nfsd4_open()
629 pr_warn("nfsd4_process_open2 failed to open newly-created file: status=%u\n", in nfsd4_open()
632 nn->somebody_reclaimed = true; in nfsd4_open()
634 if (open->op_filp) { in nfsd4_open()
635 fput(open->op_filp); in nfsd4_open()
636 open->op_filp = NULL; in nfsd4_open()
638 if (resfh && resfh != &cstate->current_fh) { in nfsd4_open()
639 fh_dup2(&cstate->current_fh, resfh); in nfsd4_open()
649 * OPEN is the only seqid-mutating operation whose decoding can fail
650 * with a seqid-mutating error (specifically, decoding of user names in
656 struct nfsd4_open *open = &op->u.open; in nfsd4_open_omfg()
658 if (!seqid_mutating_err(ntohl(op->status))) in nfsd4_open_omfg()
659 return op->status; in nfsd4_open_omfg()
661 return op->status; in nfsd4_open_omfg()
662 open->op_xdr_error = op->status; in nfsd4_open_omfg()
663 return nfsd4_open(rqstp, cstate, &op->u); in nfsd4_open_omfg()
667 * filehandle-manipulating ops.
673 u->getfh = &cstate->current_fh; in nfsd4_getfh()
681 struct nfsd4_putfh *putfh = &u->putfh; in nfsd4_putfh()
684 fh_put(&cstate->current_fh); in nfsd4_putfh()
685 cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen; in nfsd4_putfh()
686 memcpy(&cstate->current_fh.fh_handle.fh_raw, putfh->pf_fhval, in nfsd4_putfh()
687 putfh->pf_fhlen); in nfsd4_putfh()
688 ret = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_BYPASS_GSS); in nfsd4_putfh()
690 if (ret == nfserr_stale && putfh->no_verify) { in nfsd4_putfh()
691 SET_FH_FLAG(&cstate->current_fh, NFSD4_FH_FOREIGN); in nfsd4_putfh()
702 fh_put(&cstate->current_fh); in nfsd4_putrootfh()
704 return exp_pseudoroot(rqstp, &cstate->current_fh); in nfsd4_putrootfh()
711 if (!cstate->save_fh.fh_dentry) in nfsd4_restorefh()
714 fh_dup2(&cstate->current_fh, &cstate->save_fh); in nfsd4_restorefh()
716 memcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t)); in nfsd4_restorefh()
726 fh_dup2(&cstate->save_fh, &cstate->current_fh); in nfsd4_savefh()
728 memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); in nfsd4_savefh()
741 struct nfsd4_access *access = &u->access; in nfsd4_access()
745 if (cstate->minorversion >= 2) in nfsd4_access()
749 if (access->ac_req_access & ~access_full) in nfsd4_access()
752 access->ac_resp_access = access->ac_req_access; in nfsd4_access()
753 return nfsd_access(rqstp, &cstate->current_fh, &access->ac_resp_access, in nfsd4_access()
754 &access->ac_supported); in nfsd4_access()
761 struct nfsd4_commit *commit = &u->commit; in nfsd4_commit()
765 status = nfsd_file_acquire(rqstp, &cstate->current_fh, NFSD_MAY_WRITE | in nfsd4_commit()
770 status = nfsd_commit(rqstp, &cstate->current_fh, nf, commit->co_offset, in nfsd4_commit()
771 commit->co_count, in nfsd4_commit()
772 (__be32 *)commit->co_verf.data); in nfsd4_commit()
781 struct nfsd4_create *create = &u->create; in nfsd4_create()
783 .na_iattr = &create->cr_iattr, in nfsd4_create()
784 .na_seclabel = &create->cr_label, in nfsd4_create()
792 status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_NOP); in nfsd4_create()
796 status = check_attr_support(rqstp, cstate, create->cr_bmval, in nfsd4_create()
801 status = nfsd4_acl_to_attr(create->cr_type, create->cr_acl, &attrs); in nfsd4_create()
802 current->fs->umask = create->cr_umask; in nfsd4_create()
803 switch (create->cr_type) { in nfsd4_create()
805 status = nfsd_symlink(rqstp, &cstate->current_fh, in nfsd4_create()
806 create->cr_name, create->cr_namelen, in nfsd4_create()
807 create->cr_data, &attrs, &resfh); in nfsd4_create()
812 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
813 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
814 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
816 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
817 create->cr_name, create->cr_namelen, in nfsd4_create()
823 rdev = MKDEV(create->cr_specdata1, create->cr_specdata2); in nfsd4_create()
824 if (MAJOR(rdev) != create->cr_specdata1 || in nfsd4_create()
825 MINOR(rdev) != create->cr_specdata2) in nfsd4_create()
827 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
828 create->cr_name, create->cr_namelen, 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 create->cr_iattr.ia_valid &= ~ATTR_SIZE; in nfsd4_create()
846 status = nfsd_create(rqstp, &cstate->current_fh, in nfsd4_create()
847 create->cr_name, create->cr_namelen, in nfsd4_create()
859 create->cr_bmval[2] &= ~FATTR4_WORD2_SECURITY_LABEL; in nfsd4_create()
861 create->cr_bmval[0] &= ~FATTR4_WORD0_ACL; in nfsd4_create()
862 set_change_info(&create->cr_cinfo, &cstate->current_fh); in nfsd4_create()
863 fh_dup2(&cstate->current_fh, &resfh); in nfsd4_create()
867 current->fs->umask = 0; in nfsd4_create()
876 struct nfsd4_getattr *getattr = &u->getattr; in nfsd4_getattr()
879 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in nfsd4_getattr()
883 if (getattr->ga_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_getattr()
886 getattr->ga_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_getattr()
887 getattr->ga_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_getattr()
888 getattr->ga_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_getattr()
890 getattr->ga_fhp = &cstate->current_fh; in nfsd4_getattr()
898 struct nfsd4_link *link = &u->link; in nfsd4_link()
901 status = nfsd_link(rqstp, &cstate->current_fh, in nfsd4_link()
902 link->li_name, link->li_namelen, &cstate->save_fh); in nfsd4_link()
904 set_change_info(&link->li_cinfo, &cstate->current_fh); in nfsd4_link()
917 if (tmp_fh.fh_dentry == fh->fh_dentry) { in nfsd4_do_lookupp()
929 return nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_lookupp()
936 return nfsd_lookup(rqstp, &cstate->current_fh, in nfsd4_lookup()
937 u->lookup.lo_name, u->lookup.lo_len, in nfsd4_lookup()
938 &cstate->current_fh); in nfsd4_lookup()
945 struct nfsd4_read *read = &u->read; in nfsd4_read()
948 read->rd_nf = NULL; in nfsd4_read()
950 trace_nfsd_read_start(rqstp, &cstate->current_fh, in nfsd4_read()
951 read->rd_offset, read->rd_length); in nfsd4_read()
953 read->rd_length = min_t(u32, read->rd_length, svc_max_payload(rqstp)); in nfsd4_read()
954 if (read->rd_offset > (u64)OFFSET_MAX) in nfsd4_read()
955 read->rd_offset = (u64)OFFSET_MAX; in nfsd4_read()
956 if (read->rd_offset + read->rd_length > (u64)OFFSET_MAX) in nfsd4_read()
957 read->rd_length = (u64)OFFSET_MAX - read->rd_offset; in nfsd4_read()
962 * following compound. in nfsd4_read()
965 * the client wants us to do more in this compound: in nfsd4_read()
968 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_read()
970 argp->splice_ok = false; in nfsd4_read()
974 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_read()
975 &read->rd_stateid, RD_STATE, in nfsd4_read()
976 &read->rd_nf, NULL); in nfsd4_read()
978 read->rd_rqstp = rqstp; in nfsd4_read()
979 read->rd_fhp = &cstate->current_fh; in nfsd4_read()
987 if (u->read.rd_nf) in nfsd4_read_release()
988 nfsd_file_put(u->read.rd_nf); in nfsd4_read_release()
989 trace_nfsd_read_done(u->read.rd_rqstp, u->read.rd_fhp, in nfsd4_read_release()
990 u->read.rd_offset, u->read.rd_length); in nfsd4_read_release()
997 struct nfsd4_readdir *readdir = &u->readdir; in nfsd4_readdir()
998 u64 cookie = readdir->rd_cookie; in nfsd4_readdir()
1001 /* no need to check permission - this will be done in nfsd_readdir() */ in nfsd4_readdir()
1003 if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1) in nfsd4_readdir()
1006 readdir->rd_bmval[0] &= nfsd_suppattrs[cstate->minorversion][0]; in nfsd4_readdir()
1007 readdir->rd_bmval[1] &= nfsd_suppattrs[cstate->minorversion][1]; in nfsd4_readdir()
1008 readdir->rd_bmval[2] &= nfsd_suppattrs[cstate->minorversion][2]; in nfsd4_readdir()
1011 (cookie == 0 && memcmp(readdir->rd_verf.data, zeroverf.data, NFS4_VERIFIER_SIZE))) in nfsd4_readdir()
1014 readdir->rd_rqstp = rqstp; in nfsd4_readdir()
1015 readdir->rd_fhp = &cstate->current_fh; in nfsd4_readdir()
1023 u->readlink.rl_rqstp = rqstp; in nfsd4_readlink()
1024 u->readlink.rl_fhp = &cstate->current_fh; in nfsd4_readlink()
1032 struct nfsd4_remove *remove = &u->remove; in nfsd4_remove()
1037 status = nfsd_unlink(rqstp, &cstate->current_fh, 0, in nfsd4_remove()
1038 remove->rm_name, remove->rm_namelen); in nfsd4_remove()
1040 set_change_info(&remove->rm_cinfo, &cstate->current_fh); in nfsd4_remove()
1048 struct nfsd4_rename *rename = &u->rename; in nfsd4_rename()
1053 status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname, in nfsd4_rename()
1054 rename->rn_snamelen, &cstate->current_fh, in nfsd4_rename()
1055 rename->rn_tname, rename->rn_tnamelen); in nfsd4_rename()
1058 set_change_info(&rename->rn_sinfo, &cstate->save_fh); in nfsd4_rename()
1059 set_change_info(&rename->rn_tinfo, &cstate->current_fh); in nfsd4_rename()
1067 struct nfsd4_secinfo *secinfo = &u->secinfo; in nfsd4_secinfo()
1072 err = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, NFSD_MAY_EXEC); in nfsd4_secinfo()
1075 err = nfsd_lookup_dentry(rqstp, &cstate->current_fh, in nfsd4_secinfo()
1076 secinfo->si_name, secinfo->si_namelen, in nfsd4_secinfo()
1084 secinfo->si_exp = exp; in nfsd4_secinfo()
1086 if (cstate->minorversion) in nfsd4_secinfo()
1088 fh_put(&cstate->current_fh); in nfsd4_secinfo()
1098 switch (u->secinfo_no_name.sin_style) { in nfsd4_secinfo_no_name()
1102 err = nfsd4_do_lookupp(rqstp, &cstate->current_fh); in nfsd4_secinfo_no_name()
1110 u->secinfo_no_name.sin_exp = exp_get(cstate->current_fh.fh_export); in nfsd4_secinfo_no_name()
1111 fh_put(&cstate->current_fh); in nfsd4_secinfo_no_name()
1118 if (u->secinfo.si_exp) in nfsd4_secinfo_release()
1119 exp_put(u->secinfo.si_exp); in nfsd4_secinfo_release()
1125 if (u->secinfo_no_name.sin_exp) in nfsd4_secinfo_no_name_release()
1126 exp_put(u->secinfo_no_name.sin_exp); in nfsd4_secinfo_no_name_release()
1133 struct nfsd4_setattr *setattr = &u->setattr; in nfsd4_setattr()
1135 .na_iattr = &setattr->sa_iattr, in nfsd4_setattr()
1136 .na_seclabel = &setattr->sa_label, in nfsd4_setattr()
1144 deleg_attrs = setattr->sa_bmval[2] & (FATTR4_WORD2_TIME_DELEG_ACCESS | in nfsd4_setattr()
1147 if (deleg_attrs || (setattr->sa_iattr.ia_valid & ATTR_SIZE)) { in nfsd4_setattr()
1150 if (setattr->sa_bmval[2] & FATTR4_WORD2_TIME_DELEG_ACCESS) in nfsd4_setattr()
1154 &cstate->current_fh, &setattr->sa_stateid, in nfsd4_setattr()
1162 if (st->sc_type & SC_TYPE_DELEG) { in nfsd4_setattr()
1166 if (deleg_attrs_deleg(dp->dl_type)) in nfsd4_setattr()
1175 err = fh_want_write(&cstate->current_fh); in nfsd4_setattr()
1180 status = check_attr_support(rqstp, cstate, setattr->sa_bmval, in nfsd4_setattr()
1185 inode = cstate->current_fh.fh_dentry->d_inode; in nfsd4_setattr()
1186 status = nfsd4_acl_to_attr(S_ISDIR(inode->i_mode) ? NF4DIR : NF4REG, in nfsd4_setattr()
1187 setattr->sa_acl, &attrs); in nfsd4_setattr()
1191 save_no_wcc = cstate->current_fh.fh_no_wcc; in nfsd4_setattr()
1192 cstate->current_fh.fh_no_wcc = true; in nfsd4_setattr()
1193 status = nfsd_setattr(rqstp, &cstate->current_fh, &attrs, NULL); in nfsd4_setattr()
1194 cstate->current_fh.fh_no_wcc = save_no_wcc; in nfsd4_setattr()
1201 fh_drop_write(&cstate->current_fh); in nfsd4_setattr()
1209 struct nfsd4_write *write = &u->write; in nfsd4_write()
1210 stateid_t *stateid = &write->wr_stateid; in nfsd4_write()
1216 if (write->wr_offset > (u64)OFFSET_MAX || in nfsd4_write()
1217 write->wr_offset + write->wr_buflen > (u64)OFFSET_MAX) in nfsd4_write()
1220 cnt = write->wr_buflen; in nfsd4_write()
1221 trace_nfsd_write_start(rqstp, &cstate->current_fh, in nfsd4_write()
1222 write->wr_offset, cnt); in nfsd4_write()
1223 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_write()
1228 write->wr_how_written = write->wr_stable_how; in nfsd4_write()
1230 nvecs = svc_fill_write_vector(rqstp, &write->wr_payload); in nfsd4_write()
1231 WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); in nfsd4_write()
1233 status = nfsd_vfs_write(rqstp, &cstate->current_fh, nf, in nfsd4_write()
1234 write->wr_offset, rqstp->rq_vec, nvecs, &cnt, in nfsd4_write()
1235 write->wr_how_written, in nfsd4_write()
1236 (__be32 *)write->wr_verifier.data); in nfsd4_write()
1239 write->wr_bytes_written = cnt; in nfsd4_write()
1240 trace_nfsd_write_done(rqstp, &cstate->current_fh, in nfsd4_write()
1241 write->wr_offset, cnt); in nfsd4_write()
1252 if (!cstate->save_fh.fh_dentry) in nfsd4_verify_copy()
1255 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh, in nfsd4_verify_copy()
1260 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_verify_copy()
1265 /* fix up for NFS-specific error code */ in nfsd4_verify_copy()
1266 if (!S_ISREG(file_inode((*src)->nf_file)->i_mode) || in nfsd4_verify_copy()
1267 !S_ISREG(file_inode((*dst)->nf_file)->i_mode)) { in nfsd4_verify_copy()
1287 struct nfsd4_clone *clone = &u->clone; in nfsd4_clone()
1291 status = nfsd4_verify_copy(rqstp, cstate, &clone->cl_src_stateid, &src, in nfsd4_clone()
1292 &clone->cl_dst_stateid, &dst); in nfsd4_clone()
1296 status = nfsd4_clone_file_range(rqstp, src, clone->cl_src_pos, in nfsd4_clone()
1297 dst, clone->cl_dst_pos, clone->cl_count, in nfsd4_clone()
1298 EX_ISSYNC(cstate->current_fh.fh_export)); in nfsd4_clone()
1307 * nfsd4_has_active_async_copies - Check for ongoing copy operations
1324 spin_lock(&clp->async_lock); in nfsd4_has_active_async_copies()
1325 list_for_each_entry(copy, &clp->async_copies, copies) { in nfsd4_has_active_async_copies()
1326 if (!test_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags) && in nfsd4_has_active_async_copies()
1327 !test_bit(NFSD4_COPY_F_STOPPED, &copy->cp_flags)) { in nfsd4_has_active_async_copies()
1332 spin_unlock(&clp->async_lock); in nfsd4_has_active_async_copies()
1337 * nfsd4_async_copy_reaper - Purge completed copies
1346 spin_lock(&nn->client_lock); in nfsd4_async_copy_reaper()
1347 list_for_each_entry(clp, &nn->client_lru, cl_lru) { in nfsd4_async_copy_reaper()
1350 spin_lock(&clp->async_lock); in nfsd4_async_copy_reaper()
1351 list_for_each_safe(pos, next, &clp->async_copies) { in nfsd4_async_copy_reaper()
1353 if (test_bit(NFSD4_COPY_F_OFFLOAD_DONE, &copy->cp_flags)) { in nfsd4_async_copy_reaper()
1354 if (--copy->cp_ttl) { in nfsd4_async_copy_reaper()
1355 list_del_init(&copy->copies); in nfsd4_async_copy_reaper()
1356 list_add(&copy->copies, &reaplist); in nfsd4_async_copy_reaper()
1360 spin_unlock(&clp->async_lock); in nfsd4_async_copy_reaper()
1362 spin_unlock(&nn->client_lock); in nfsd4_async_copy_reaper()
1366 list_del_init(&copy->copies); in nfsd4_async_copy_reaper()
1373 if (!refcount_dec_and_test(&copy->refcount)) in nfs4_put_copy()
1375 kfree(copy->cp_src); in nfs4_put_copy()
1382 if (!test_and_set_bit(NFSD4_COPY_F_STOPPED, &copy->cp_flags)) in nfsd4_stop_copy()
1383 kthread_stop(copy->copy_task); in nfsd4_stop_copy()
1391 spin_lock(&clp->async_lock); in nfsd4_unhash_copy()
1392 if (!list_empty(&clp->async_copies)) { in nfsd4_unhash_copy()
1393 copy = list_first_entry(&clp->async_copies, struct nfsd4_copy, in nfsd4_unhash_copy()
1395 refcount_inc(&copy->refcount); in nfsd4_unhash_copy()
1396 copy->cp_clp = NULL; in nfsd4_unhash_copy()
1397 if (!list_empty(&copy->copies)) in nfsd4_unhash_copy()
1398 list_del_init(&copy->copies); in nfsd4_unhash_copy()
1400 spin_unlock(&clp->async_lock); in nfsd4_unhash_copy()
1438 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1439 list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) { in nfsd4_ssc_setup_dul()
1440 if (strncmp(ni->nsui_ipaddr, ipaddr, sizeof(ni->nsui_ipaddr))) in nfsd4_ssc_setup_dul()
1443 if (ni->nsui_busy) { in nfsd4_ssc_setup_dul()
1444 /* wait - and try again */ in nfsd4_ssc_setup_dul()
1445 prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, TASK_IDLE); in nfsd4_ssc_setup_dul()
1446 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1448 /* allow 20secs for mount/unmount for now - revisit */ in nfsd4_ssc_setup_dul()
1451 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1455 finish_wait(&nn->nfsd_ssc_waitq, &wait); in nfsd4_ssc_setup_dul()
1459 refcount_inc(&ni->nsui_refcnt); in nfsd4_ssc_setup_dul()
1460 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1463 /* return vfsmount in (*nsui)->nsui_vfsmount */ in nfsd4_ssc_setup_dul()
1467 strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1); in nfsd4_ssc_setup_dul()
1468 refcount_set(&work->nsui_refcnt, 2); in nfsd4_ssc_setup_dul()
1469 work->nsui_busy = true; in nfsd4_ssc_setup_dul()
1470 list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_ssc_setup_dul()
1474 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_setup_dul()
1482 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1483 nsui->nsui_vfsmount = ss_mnt; in nfsd4_ssc_update_dul()
1484 nsui->nsui_busy = false; in nfsd4_ssc_update_dul()
1485 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_update_dul()
1486 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_update_dul()
1492 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1493 list_del(&nsui->nsui_list); in nfsd4_ssc_cancel_dul()
1494 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_cancel_dul()
1495 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_cancel_dul()
1517 naddr = &nss->u.nl4_addr; in nfsd4_interssc_connect()
1518 tmp_addrlen = rpc_uaddr2sockaddr(SVC_NET(rqstp), naddr->addr, in nfsd4_interssc_connect()
1519 naddr->addr_len, in nfsd4_interssc_connect()
1533 if (naddr->netid_len != match_netid_len || in nfsd4_interssc_connect()
1534 strncmp(naddr->netid, match_netid, naddr->netid_len)) in nfsd4_interssc_connect()
1568 if ((*nsui)->nsui_vfsmount) in nfsd4_interssc_connect()
1571 /* Use an 'internal' mount: SB_KERNMOUNT -> MNT_INTERNAL */ in nfsd4_interssc_connect()
1573 module_put(type->owner); in nfsd4_interssc_connect()
1608 stateid_t *s_stid = &copy->cp_src_stateid; in nfsd4_setup_inter_ssc()
1612 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_setup_inter_ssc()
1613 &copy->cp_dst_stateid, in nfsd4_setup_inter_ssc()
1614 WR_STATE, &copy->nf_dst, NULL); in nfsd4_setup_inter_ssc()
1618 status = nfsd4_interssc_connect(copy->cp_src, rqstp, &copy->ss_nsui); in nfsd4_setup_inter_ssc()
1622 s_fh = &cstate->save_fh; in nfsd4_setup_inter_ssc()
1624 copy->c_fh.size = s_fh->fh_handle.fh_size; in nfsd4_setup_inter_ssc()
1625 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_raw, copy->c_fh.size); in nfsd4_setup_inter_ssc()
1626 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); in nfsd4_setup_inter_ssc()
1627 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque, in nfsd4_setup_inter_ssc()
1639 struct nfsd_net *nn = net_generic(dst->nf_net, nfsd_net_id); in nfsd4_cleanup_inter_ssc()
1645 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1646 list_del(&nsui->nsui_list); in nfsd4_cleanup_inter_ssc()
1652 refcount_dec(&nsui->nsui_refcnt); in nfsd4_cleanup_inter_ssc()
1653 nsui->nsui_expire = jiffies + timeout; in nfsd4_cleanup_inter_ssc()
1654 list_add_tail(&nsui->nsui_list, &nn->nfsd_ssc_mount_list); in nfsd4_cleanup_inter_ssc()
1655 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_cleanup_inter_ssc()
1687 return nfsd4_verify_copy(rqstp, cstate, &copy->cp_src_stateid, in nfsd4_setup_intra_ssc()
1688 &copy->nf_src, &copy->cp_dst_stateid, in nfsd4_setup_intra_ssc()
1689 &copy->nf_dst); in nfsd4_setup_intra_ssc()
1699 set_bit(NFSD4_COPY_F_OFFLOAD_DONE, &copy->cp_flags); in nfsd4_cb_offload_release()
1708 trace_nfsd_cb_offload_done(&cbo->co_res.cb_stateid, task); in nfsd4_cb_offload_done()
1709 switch (task->tk_status) { in nfsd4_cb_offload_done()
1710 case -NFS4ERR_DELAY: in nfsd4_cb_offload_done()
1711 if (cbo->co_retries--) { in nfsd4_cb_offload_done()
1727 copy->cp_res.wr_stable_how = in nfsd4_init_copy_res()
1728 test_bit(NFSD4_COPY_F_COMMITTED, &copy->cp_flags) ? in nfsd4_init_copy_res()
1739 u64 bytes_total = copy->cp_count; in _nfsd_copy_file_range()
1740 u64 src_pos = copy->cp_src_pos; in _nfsd_copy_file_range()
1741 u64 dst_pos = copy->cp_dst_pos; in _nfsd_copy_file_range()
1756 bytes_total -= bytes_copied; in _nfsd_copy_file_range()
1757 copy->cp_res.wr_bytes_written += bytes_copied; in _nfsd_copy_file_range()
1761 /* for a non-zero asynchronous copy do a commit of data */ in _nfsd_copy_file_range()
1762 if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) { in _nfsd_copy_file_range()
1763 since = READ_ONCE(dst->f_wb_err); in _nfsd_copy_file_range()
1764 end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1; in _nfsd_copy_file_range()
1765 status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0); in _nfsd_copy_file_range()
1767 status = filemap_check_wb_err(dst->f_mapping, since); in _nfsd_copy_file_range()
1769 set_bit(NFSD4_COPY_F_COMMITTED, &copy->cp_flags); in _nfsd_copy_file_range()
1786 if (bytes < 0 && !copy->cp_res.wr_bytes_written) in nfsd4_do_copy()
1797 dst->cp_src_pos = src->cp_src_pos; in dup_copy_fields()
1798 dst->cp_dst_pos = src->cp_dst_pos; in dup_copy_fields()
1799 dst->cp_count = src->cp_count; in dup_copy_fields()
1800 dst->cp_flags = src->cp_flags; in dup_copy_fields()
1801 memcpy(&dst->cp_res, &src->cp_res, sizeof(src->cp_res)); in dup_copy_fields()
1802 memcpy(&dst->fh, &src->fh, sizeof(src->fh)); in dup_copy_fields()
1803 dst->cp_clp = src->cp_clp; in dup_copy_fields()
1804 dst->nf_dst = nfsd_file_get(src->nf_dst); in dup_copy_fields()
1807 dst->nf_src = nfsd_file_get(src->nf_src); in dup_copy_fields()
1809 memcpy(&dst->cp_stateid, &src->cp_stateid, sizeof(src->cp_stateid)); in dup_copy_fields()
1810 memcpy(dst->cp_src, src->cp_src, sizeof(struct nl4_server)); in dup_copy_fields()
1811 memcpy(&dst->stateid, &src->stateid, sizeof(src->stateid)); in dup_copy_fields()
1812 memcpy(&dst->c_fh, &src->c_fh, sizeof(src->c_fh)); in dup_copy_fields()
1813 dst->ss_nsui = src->ss_nsui; in dup_copy_fields()
1818 if (copy->nf_src) in release_copy_files()
1819 nfsd_file_put(copy->nf_src); in release_copy_files()
1820 if (copy->nf_dst) in release_copy_files()
1821 nfsd_file_put(copy->nf_dst); in release_copy_files()
1828 if (copy->cp_clp) { in cleanup_async_copy()
1829 spin_lock(&copy->cp_clp->async_lock); in cleanup_async_copy()
1830 if (!list_empty(&copy->copies)) in cleanup_async_copy()
1831 list_del_init(&copy->copies); in cleanup_async_copy()
1832 spin_unlock(&copy->cp_clp->async_lock); in cleanup_async_copy()
1839 struct nfsd4_cb_offload *cbo = &copy->cp_cb_offload; in nfsd4_send_cb_offload()
1841 memcpy(&cbo->co_res, &copy->cp_res, sizeof(copy->cp_res)); in nfsd4_send_cb_offload()
1842 memcpy(&cbo->co_fh, &copy->fh, sizeof(copy->fh)); in nfsd4_send_cb_offload()
1843 cbo->co_nfserr = copy->nfserr; in nfsd4_send_cb_offload()
1844 cbo->co_retries = 5; in nfsd4_send_cb_offload()
1846 nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops, in nfsd4_send_cb_offload()
1848 trace_nfsd_cb_offload(copy->cp_clp, &cbo->co_res.cb_stateid, in nfsd4_send_cb_offload()
1849 &cbo->co_fh, copy->cp_count, copy->nfserr); in nfsd4_send_cb_offload()
1850 nfsd4_run_cb(&cbo->co_cb); in nfsd4_send_cb_offload()
1854 * nfsd4_do_async_copy - kthread function for background server-side COPY
1868 filp = nfs42_ssc_open(copy->ss_nsui->nsui_vfsmount, in nfsd4_do_async_copy()
1869 &copy->c_fh, &copy->stateid); in nfsd4_do_async_copy()
1872 case -EBADF: in nfsd4_do_async_copy()
1873 copy->nfserr = nfserr_wrong_type; in nfsd4_do_async_copy()
1876 copy->nfserr = nfserr_offload_denied; in nfsd4_do_async_copy()
1881 copy->nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file, in nfsd4_do_async_copy()
1883 nfsd4_cleanup_inter_ssc(copy->ss_nsui, filp, copy->nf_dst); in nfsd4_do_async_copy()
1885 copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_do_async_copy()
1886 copy->nf_dst->nf_file, false); in nfsd4_do_async_copy()
1892 set_bit(NFSD4_COPY_F_STOPPED, &copy->cp_flags); in nfsd4_do_async_copy()
1894 set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags); in nfsd4_do_async_copy()
1897 atomic_dec(&copy->cp_nn->pending_async_copies); in nfsd4_do_async_copy()
1907 struct nfsd4_copy *copy = &u->copy; in nfsd4_copy()
1918 result = &copy->cp_res; in nfsd4_copy()
1919 nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn); in nfsd4_copy()
1921 copy->cp_clp = cstate->clp; in nfsd4_copy()
1942 memcpy(&copy->fh, &cstate->current_fh.fh_handle, in nfsd4_copy()
1948 async_copy->cp_nn = nn; in nfsd4_copy()
1949 INIT_LIST_HEAD(&async_copy->copies); in nfsd4_copy()
1950 refcount_set(&async_copy->refcount, 1); in nfsd4_copy()
1951 async_copy->cp_ttl = NFSD_COPY_INITIAL_TTL; in nfsd4_copy()
1953 if (atomic_inc_return(&nn->pending_async_copies) > in nfsd4_copy()
1954 (int)rqstp->rq_pool->sp_nrthreads) in nfsd4_copy()
1956 async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); in nfsd4_copy()
1957 if (!async_copy->cp_src) in nfsd4_copy()
1961 memcpy(&result->cb_stateid, &copy->cp_stateid.cs_stid, in nfsd4_copy()
1962 sizeof(result->cb_stateid)); in nfsd4_copy()
1964 async_copy->copy_task = kthread_create(nfsd4_do_async_copy, in nfsd4_copy()
1966 if (IS_ERR(async_copy->copy_task)) in nfsd4_copy()
1968 spin_lock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1969 list_add(&async_copy->copies, in nfsd4_copy()
1970 &async_copy->cp_clp->async_copies); in nfsd4_copy()
1971 spin_unlock(&async_copy->cp_clp->async_lock); in nfsd4_copy()
1972 wake_up_process(async_copy->copy_task); in nfsd4_copy()
1975 status = nfsd4_do_copy(copy, copy->nf_src->nf_file, in nfsd4_copy()
1976 copy->nf_dst->nf_file, true); in nfsd4_copy()
1984 atomic_dec(&nn->pending_async_copies); in nfsd4_copy()
1988 * Source's vfsmount of inter-copy will be unmounted in nfsd4_copy()
1990 * since async_copy->ss_nsui might not be set yet. in nfsd4_copy()
1992 refcount_dec(&copy->ss_nsui->nsui_refcnt); in nfsd4_copy()
2005 lockdep_assert_held(&clp->async_lock); in find_async_copy_locked()
2007 list_for_each_entry(copy, &clp->async_copies, copies) { in find_async_copy_locked()
2008 if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE)) in find_async_copy_locked()
2020 spin_lock(&clp->async_lock); in find_async_copy()
2023 refcount_inc(&copy->refcount); in find_async_copy()
2024 spin_unlock(&clp->async_lock); in find_async_copy()
2033 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_cancel()
2035 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_cancel()
2037 copy = find_async_copy(clp, &os->stateid); in nfsd4_offload_cancel()
2041 return manage_cpntf_state(nn, &os->stateid, clp, NULL); in nfsd4_offload_cancel()
2052 struct nfsd4_copy_notify *cn = &u->copy_notify; in nfsd4_copy_notify()
2057 struct nfs4_client *clp = cstate->clp; in nfsd4_copy_notify()
2059 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_copy_notify()
2060 &cn->cpn_src_stateid, RD_STATE, NULL, in nfsd4_copy_notify()
2067 cn->cpn_lease_time.tv_sec = nn->nfsd4_lease; in nfsd4_copy_notify()
2068 cn->cpn_lease_time.tv_nsec = 0; in nfsd4_copy_notify()
2070 status = nfserrno(-ENOMEM); in nfsd4_copy_notify()
2074 memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t)); in nfsd4_copy_notify()
2075 memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t)); in nfsd4_copy_notify()
2076 memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t)); in nfsd4_copy_notify()
2081 cn->cpn_src->nl4_type = NL4_NETADDR; in nfsd4_copy_notify()
2082 status = nfsd4_set_netaddr((struct sockaddr *)&rqstp->rq_daddr, in nfsd4_copy_notify()
2083 &cn->cpn_src->u.nl4_addr); in nfsd4_copy_notify()
2101 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_fallocate()
2102 &fallocate->falloc_stateid, in nfsd4_fallocate()
2107 status = nfsd4_vfs_fallocate(rqstp, &cstate->current_fh, nf->nf_file, in nfsd4_fallocate()
2108 fallocate->falloc_offset, in nfsd4_fallocate()
2109 fallocate->falloc_length, in nfsd4_fallocate()
2120 struct nfsd4_offload_status *os = &u->offload_status; in nfsd4_offload_status()
2123 struct nfs4_client *clp = cstate->clp; in nfsd4_offload_status()
2125 os->completed = false; in nfsd4_offload_status()
2126 spin_lock(&clp->async_lock); in nfsd4_offload_status()
2127 copy = find_async_copy_locked(clp, &os->stateid); in nfsd4_offload_status()
2129 os->count = copy->cp_res.wr_bytes_written; in nfsd4_offload_status()
2130 if (test_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags)) { in nfsd4_offload_status()
2131 os->completed = true; in nfsd4_offload_status()
2132 os->status = copy->nfserr; in nfsd4_offload_status()
2136 spin_unlock(&clp->async_lock); in nfsd4_offload_status()
2145 return nfsd4_fallocate(rqstp, cstate, &u->allocate, 0); in nfsd4_allocate()
2152 return nfsd4_fallocate(rqstp, cstate, &u->deallocate, in nfsd4_deallocate()
2160 struct nfsd4_seek *seek = &u->seek; in nfsd4_seek()
2165 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh, in nfsd4_seek()
2166 &seek->seek_stateid, in nfsd4_seek()
2171 switch (seek->seek_whence) { in nfsd4_seek()
2184 * Note: This call does change file->f_pos, but nothing in NFSD in nfsd4_seek()
2185 * should ever file->f_pos. in nfsd4_seek()
2187 seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence); in nfsd4_seek()
2188 if (seek->seek_pos < 0) in nfsd4_seek()
2189 status = nfserrno(seek->seek_pos); in nfsd4_seek()
2190 else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file))) in nfsd4_seek()
2191 seek->seek_eof = true; in nfsd4_seek()
2211 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); in _nfsd4_verify()
2215 status = check_attr_support(rqstp, cstate, verify->ve_bmval, NULL); in _nfsd4_verify()
2219 if ((verify->ve_bmval[0] & FATTR4_WORD0_RDATTR_ERROR) in _nfsd4_verify()
2220 || (verify->ve_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)) in _nfsd4_verify()
2222 if (verify->ve_attrlen & 3) in _nfsd4_verify()
2228 count = 4 + (verify->ve_attrlen >> 2); in _nfsd4_verify()
2234 status = nfsd4_encode_fattr_to_buf(&p, count, &cstate->current_fh, in _nfsd4_verify()
2235 cstate->current_fh.fh_export, in _nfsd4_verify()
2236 cstate->current_fh.fh_dentry, in _nfsd4_verify()
2237 verify->ve_bmval, in _nfsd4_verify()
2251 if (ntohl(*p++) != verify->ve_attrlen) in _nfsd4_verify()
2253 if (!memcmp(p, verify->ve_attrval, verify->ve_attrlen)) in _nfsd4_verify()
2267 status = _nfsd4_verify(rqstp, cstate, &u->verify); in nfsd4_nverify()
2277 status = _nfsd4_verify(rqstp, cstate, &u->nverify); in nfsd4_verify()
2286 struct nfsd4_get_dir_delegation *gdd = &u->get_dir_delegation; in nfsd4_get_dir_delegation()
2294 * This is sub-optimal, since it means that the server would need to in nfsd4_get_dir_delegation()
2295 * abort compound processing just because the delegation wasn't in nfsd4_get_dir_delegation()
2297 * return NFS4_OK with a non-fatal status of GDD4_UNAVAIL in this in nfsd4_get_dir_delegation()
2300 gdd->gddrnf_status = GDD4_UNAVAIL; in nfsd4_get_dir_delegation()
2308 if (!exp->ex_layout_types) { in nfsd4_layout_verify()
2314 !(exp->ex_layout_types & (1 << layout_type))) { in nfsd4_layout_verify()
2327 struct nfsd4_getdeviceinfo *gdp = &u->getdeviceinfo; in nfsd4_getdeviceinfo()
2335 gdp->gd_layout_type, in nfsd4_getdeviceinfo()
2336 gdp->gd_devid.fsid_idx, gdp->gd_devid.generation, in nfsd4_getdeviceinfo()
2337 gdp->gd_maxcount); in nfsd4_getdeviceinfo()
2339 map = nfsd4_find_devid_map(gdp->gd_devid.fsid_idx); in nfsd4_getdeviceinfo()
2341 dprintk("%s: couldn't find device ID to export mapping!\n", in nfsd4_getdeviceinfo()
2346 exp = rqst_exp_find(&rqstp->rq_chandle, SVC_NET(rqstp), in nfsd4_getdeviceinfo()
2347 rqstp->rq_client, rqstp->rq_gssclient, in nfsd4_getdeviceinfo()
2348 map->fsid_type, map->fsid); in nfsd4_getdeviceinfo()
2350 dprintk("%s: could not find device id\n", __func__); in nfsd4_getdeviceinfo()
2355 ops = nfsd4_layout_verify(exp, gdp->gd_layout_type); in nfsd4_getdeviceinfo()
2360 if (gdp->gd_maxcount != 0) { in nfsd4_getdeviceinfo()
2361 nfserr = ops->proc_getdeviceinfo(exp->ex_path.mnt->mnt_sb, in nfsd4_getdeviceinfo()
2362 rqstp, cstate->clp, gdp); in nfsd4_getdeviceinfo()
2365 gdp->gd_notify_types &= ops->notify_types; in nfsd4_getdeviceinfo()
2374 kfree(u->getdeviceinfo.gd_device); in nfsd4_getdeviceinfo_release()
2381 struct nfsd4_layoutget *lgp = &u->layoutget; in nfsd4_layoutget()
2382 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutget()
2388 switch (lgp->lg_seg.iomode) { in nfsd4_layoutget()
2397 __func__, lgp->lg_seg.iomode); in nfsd4_layoutget()
2407 ops = nfsd4_layout_verify(current_fh->fh_export, lgp->lg_layout_type); in nfsd4_layoutget()
2423 if (lgp->lg_seg.length < lgp->lg_minlength || in nfsd4_layoutget()
2424 (lgp->lg_minlength != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2425 lgp->lg_minlength > NFS4_MAX_UINT64 - lgp->lg_seg.offset) || in nfsd4_layoutget()
2426 (lgp->lg_seg.length != NFS4_MAX_UINT64 && in nfsd4_layoutget()
2427 lgp->lg_seg.length > NFS4_MAX_UINT64 - lgp->lg_seg.offset)) in nfsd4_layoutget()
2429 if (lgp->lg_seg.length == 0) in nfsd4_layoutget()
2432 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid, in nfsd4_layoutget()
2433 true, lgp->lg_layout_type, &ls); in nfsd4_layoutget()
2435 trace_nfsd_layout_get_lookup_fail(&lgp->lg_sid); in nfsd4_layoutget()
2440 if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls)) in nfsd4_layoutget()
2443 nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry), in nfsd4_layoutget()
2451 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutget()
2452 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutget()
2460 kfree(u->layoutget.lg_content); in nfsd4_layoutget_release()
2467 struct nfsd4_layoutcommit *lcp = &u->layoutcommit; in nfsd4_layoutcommit()
2468 const struct nfsd4_layout_seg *seg = &lcp->lc_seg; in nfsd4_layoutcommit()
2469 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutcommit()
2471 loff_t new_size = lcp->lc_last_wr + 1; in nfsd4_layoutcommit()
2482 ops = nfsd4_layout_verify(current_fh->fh_export, lcp->lc_layout_type); in nfsd4_layoutcommit()
2485 inode = d_inode(current_fh->fh_dentry); in nfsd4_layoutcommit()
2488 if (new_size <= seg->offset) { in nfsd4_layoutcommit()
2492 if (new_size > seg->offset + seg->length) { in nfsd4_layoutcommit()
2496 if (!lcp->lc_newoffset && new_size > i_size_read(inode)) { in nfsd4_layoutcommit()
2501 nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lcp->lc_sid, in nfsd4_layoutcommit()
2502 false, lcp->lc_layout_type, in nfsd4_layoutcommit()
2505 trace_nfsd_layout_commit_lookup_fail(&lcp->lc_sid); in nfsd4_layoutcommit()
2513 mutex_unlock(&ls->ls_mutex); in nfsd4_layoutcommit()
2516 lcp->lc_size_chg = true; in nfsd4_layoutcommit()
2517 lcp->lc_newsize = new_size; in nfsd4_layoutcommit()
2519 lcp->lc_size_chg = false; in nfsd4_layoutcommit()
2522 nfserr = ops->proc_layoutcommit(inode, lcp); in nfsd4_layoutcommit()
2523 nfs4_put_stid(&ls->ls_stid); in nfsd4_layoutcommit()
2532 struct nfsd4_layoutreturn *lrp = &u->layoutreturn; in nfsd4_layoutreturn()
2533 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_layoutreturn()
2541 if (!nfsd4_layout_verify(current_fh->fh_export, lrp->lr_layout_type)) in nfsd4_layoutreturn()
2544 switch (lrp->lr_seg.iomode) { in nfsd4_layoutreturn()
2551 lrp->lr_seg.iomode); in nfsd4_layoutreturn()
2556 switch (lrp->lr_return_type) { in nfsd4_layoutreturn()
2566 lrp->lr_return_type); in nfsd4_layoutreturn()
2579 struct nfsd4_getxattr *getxattr = &u->getxattr; in nfsd4_getxattr()
2581 return nfsd_getxattr(rqstp, &cstate->current_fh, in nfsd4_getxattr()
2582 getxattr->getxa_name, &getxattr->getxa_buf, in nfsd4_getxattr()
2583 &getxattr->getxa_len); in nfsd4_getxattr()
2590 struct nfsd4_setxattr *setxattr = &u->setxattr; in nfsd4_setxattr()
2596 ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name, in nfsd4_setxattr()
2597 setxattr->setxa_buf, setxattr->setxa_len, in nfsd4_setxattr()
2598 setxattr->setxa_flags); in nfsd4_setxattr()
2601 set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh); in nfsd4_setxattr()
2614 return nfsd_listxattr(rqstp, &cstate->current_fh, in nfsd4_listxattrs()
2615 &u->listxattrs.lsxa_buf, &u->listxattrs.lsxa_len); in nfsd4_listxattrs()
2622 struct nfsd4_removexattr *removexattr = &u->removexattr; in nfsd4_removexattr()
2628 ret = nfsd_removexattr(rqstp, &cstate->current_fh, in nfsd4_removexattr()
2629 removexattr->rmxa_name); in nfsd4_removexattr()
2632 set_change_info(&removexattr->rmxa_cinfo, &cstate->current_fh); in nfsd4_removexattr()
2649 percpu_counter_inc(&nn->counter[NFSD_STATS_NFS4_OP(opnum)]); in nfsd4_increment_op_stats()
2657 * Enforce NFSv4.1 COMPOUND ordering rules:
2660 * - SEQUENCE other than as first op results in
2662 * - BIND_CONN_TO_SESSION must be the only op in its compound.
2664 * - DESTROY_SESSION must be the final operation in a compound, if
2670 struct nfsd4_op *first_op = &args->ops[0]; in nfs41_check_op_ordering()
2673 if (args->minorversion == 0) in nfs41_check_op_ordering()
2676 if (args->opcnt == 0) in nfs41_check_op_ordering()
2678 if (first_op->status == nfserr_op_illegal) in nfs41_check_op_ordering()
2680 if (!(nfsd4_ops[first_op->opnum].op_flags & ALLOWED_AS_FIRST_OP)) in nfs41_check_op_ordering()
2682 if (first_op->opnum == OP_SEQUENCE) in nfs41_check_op_ordering()
2687 * compound: in nfs41_check_op_ordering()
2689 if (args->opcnt != 1) in nfs41_check_op_ordering()
2696 return &nfsd4_ops[op->opnum]; in OPDESC()
2701 if (op->opnum == OP_ILLEGAL) in nfsd4_cache_this_op()
2703 return OPDESC(op)->op_flags & OP_CACHEME; in nfsd4_cache_this_op()
2708 struct nfsd4_compoundres *resp = rqstp->rq_resp; in need_wrongsec_check()
2709 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in need_wrongsec_check()
2710 struct nfsd4_op *this = &argp->ops[resp->opcnt - 1]; in need_wrongsec_check()
2711 struct nfsd4_op *next = &argp->ops[resp->opcnt]; in need_wrongsec_check()
2716 * Most ops check wronsec on our own; only the putfh-like ops in need_wrongsec_check()
2719 if (!(thisd->op_flags & OP_IS_PUTFH_LIKE)) in need_wrongsec_check()
2723 * put-filehandle operation if we're not going to use the in need_wrongsec_check()
2726 if (argp->opcnt == resp->opcnt) in need_wrongsec_check()
2728 if (next->opnum == OP_ILLEGAL) in need_wrongsec_check()
2736 return !(nextd->op_flags & OP_HANDLES_WRONGSEC); in need_wrongsec_check()
2748 /* traverse all operation and if it's a COPY compound, mark the in check_if_stalefh_allowed()
2751 for (i = 0; i < args->opcnt; i++) { in check_if_stalefh_allowed()
2752 op = &args->ops[i]; in check_if_stalefh_allowed()
2753 if (op->opnum == OP_PUTFH) in check_if_stalefh_allowed()
2755 else if (op->opnum == OP_SAVEFH) in check_if_stalefh_allowed()
2757 else if (op->opnum == OP_RESTOREFH) in check_if_stalefh_allowed()
2759 else if (op->opnum == OP_COPY) { in check_if_stalefh_allowed()
2760 copy = (struct nfsd4_copy *)&op->u; in check_if_stalefh_allowed()
2762 op->status = nfserr_nofilehandle; in check_if_stalefh_allowed()
2765 putfh = (struct nfsd4_putfh *)&saved_op->u; in check_if_stalefh_allowed()
2767 putfh->no_verify = true; in check_if_stalefh_allowed()
2779 * COMPOUND call.
2784 struct nfsd4_compoundargs *args = rqstp->rq_argp; in nfsd4_proc_compound()
2785 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_proc_compound()
2787 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_proc_compound()
2788 struct svc_fh *current_fh = &cstate->current_fh; in nfsd4_proc_compound()
2789 struct svc_fh *save_fh = &cstate->save_fh; in nfsd4_proc_compound()
2793 resp->xdr = &rqstp->rq_res_stream; in nfsd4_proc_compound()
2794 resp->statusp = resp->xdr->p; in nfsd4_proc_compound()
2797 xdr_reserve_space(resp->xdr, XDR_UNIT); in nfsd4_proc_compound()
2800 xdr_reserve_space(resp->xdr, XDR_UNIT * 2 + args->taglen); in nfsd4_proc_compound()
2801 resp->taglen = args->taglen; in nfsd4_proc_compound()
2802 resp->tag = args->tag; in nfsd4_proc_compound()
2803 resp->rqstp = rqstp; in nfsd4_proc_compound()
2804 cstate->minorversion = args->minorversion; in nfsd4_proc_compound()
2809 * too hard to avoid non-idempotency problems. in nfsd4_proc_compound()
2811 clear_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2817 if (nfsd_minorversion(nn, args->minorversion, NFSD_TEST) <= 0) in nfsd4_proc_compound()
2822 op = &args->ops[0]; in nfsd4_proc_compound()
2823 op->status = status; in nfsd4_proc_compound()
2824 resp->opcnt = 1; in nfsd4_proc_compound()
2829 rqstp->rq_lease_breaker = (void **)&cstate->clp; in nfsd4_proc_compound()
2831 trace_nfsd_compound(rqstp, args->tag, args->taglen, args->client_opcnt); in nfsd4_proc_compound()
2832 while (!status && resp->opcnt < args->opcnt) { in nfsd4_proc_compound()
2833 op = &args->ops[resp->opcnt++]; in nfsd4_proc_compound()
2835 if (unlikely(resp->opcnt == NFSD_MAX_OPS_PER_COMPOUND)) { in nfsd4_proc_compound()
2838 if (cstate->minorversion == 0 && in nfsd4_proc_compound()
2839 args->client_opcnt > resp->opcnt) { in nfsd4_proc_compound()
2840 op->status = nfserr_resource; in nfsd4_proc_compound()
2846 * The XDR decode routines may have pre-set op->status; in nfsd4_proc_compound()
2850 if (op->status) { in nfsd4_proc_compound()
2851 if (op->opnum == OP_OPEN) in nfsd4_proc_compound()
2852 op->status = nfsd4_open_omfg(rqstp, cstate, op); in nfsd4_proc_compound()
2855 if (!current_fh->fh_dentry && in nfsd4_proc_compound()
2857 if (!(op->opdesc->op_flags & ALLOWED_WITHOUT_FH)) { in nfsd4_proc_compound()
2858 op->status = nfserr_nofilehandle; in nfsd4_proc_compound()
2861 } else if (current_fh->fh_export && in nfsd4_proc_compound()
2862 current_fh->fh_export->ex_fslocs.migrated && in nfsd4_proc_compound()
2863 !(op->opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) { in nfsd4_proc_compound()
2864 op->status = nfserr_moved; in nfsd4_proc_compound()
2870 /* If op is non-idempotent */ in nfsd4_proc_compound()
2871 if (op->opdesc->op_flags & OP_MODIFIES_SOMETHING) { in nfsd4_proc_compound()
2876 u32 plen = op->opdesc->op_rsize_bop(rqstp, op); in nfsd4_proc_compound()
2881 if (resp->opcnt < args->opcnt) in nfsd4_proc_compound()
2883 op->status = nfsd4_check_resp_size(resp, plen); in nfsd4_proc_compound()
2886 if (op->status) in nfsd4_proc_compound()
2889 if (op->opdesc->op_get_currentstateid) in nfsd4_proc_compound()
2890 op->opdesc->op_get_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2891 op->status = op->opdesc->op_func(rqstp, cstate, &op->u); in nfsd4_proc_compound()
2892 trace_nfsd_compound_op_err(rqstp, op->opnum, op->status); in nfsd4_proc_compound()
2895 if (cstate->status == nfserr_replay_cache) { in nfsd4_proc_compound()
2897 status = op->status; in nfsd4_proc_compound()
2900 if (!op->status) { in nfsd4_proc_compound()
2901 if (op->opdesc->op_set_currentstateid) in nfsd4_proc_compound()
2902 op->opdesc->op_set_currentstateid(cstate, &op->u); in nfsd4_proc_compound()
2904 if (op->opdesc->op_flags & OP_CLEAR_STATEID) in nfsd4_proc_compound()
2907 if (current_fh->fh_export && in nfsd4_proc_compound()
2909 op->status = check_nfsd_access(current_fh->fh_export, rqstp, false); in nfsd4_proc_compound()
2912 if (op->status == nfserr_replay_me) { in nfsd4_proc_compound()
2913 op->replay = &cstate->replay_owner->so_replay; in nfsd4_proc_compound()
2914 nfsd4_encode_replay(resp->xdr, op); in nfsd4_proc_compound()
2915 status = op->status = op->replay->rp_status; in nfsd4_proc_compound()
2918 status = op->status; in nfsd4_proc_compound()
2921 trace_nfsd_compound_status(args->client_opcnt, resp->opcnt, in nfsd4_proc_compound()
2922 status, nfsd4_op_name(op->opnum)); in nfsd4_proc_compound()
2925 nfsd4_increment_op_stats(nn, op->opnum); in nfsd4_proc_compound()
2930 BUG_ON(cstate->replay_owner); in nfsd4_proc_compound()
2932 cstate->status = status; in nfsd4_proc_compound()
2934 set_bit(RQ_USEDEFERRAL, &rqstp->rq_flags); in nfsd4_proc_compound()
2957 * The _rsize() helpers are invoked by the NFSv4 COMPOUND decoder, which
2966 buflen = (rqstp->rq_page_end - rqstp->rq_next_page) * PAGE_SIZE; in nfsd4_max_payload()
2967 buflen -= rqstp->rq_auth_slack; in nfsd4_max_payload()
2968 buflen -= rqstp->rq_res.head[0].iov_len; in nfsd4_max_payload()
3012 const u32 *bmap = op->u.getattr.ga_bmval; in nfsd4_getattr_rsize()
3079 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_rsize()
3087 u32 rlen = min(op->u.read.rd_length, nfsd4_max_payload(rqstp)); in nfsd4_read_plus_rsize()
3101 u32 rlen = min(op->u.readdir.rd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_readdir_rsize()
3137 return (op_encode_hdr_size + 1 + op->u.test_stateid.ts_num_ids) in nfsd4_test_stateid_rsize()
3252 u32 rlen = min(op->u.getdeviceinfo.gd_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_getdeviceinfo_rsize()
3316 u32 rlen = min(op->u.listxattrs.lsxa_maxcount, nfsd4_max_payload(rqstp)); in nfsd4_listxattrs_rsize()
3751 * nfsd4_spo_must_allow - Determine if the compound op contains an
3756 * Checks to see if the compound contains a spo_must_allow op
3762 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_spo_must_allow()
3763 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in nfsd4_spo_must_allow()
3765 struct nfsd4_compound_state *cstate = &resp->cstate; in nfsd4_spo_must_allow()
3766 struct nfs4_op_map *allow = &cstate->clp->cl_spo_must_allow; in nfsd4_spo_must_allow()
3769 if (!cstate->minorversion) in nfsd4_spo_must_allow()
3772 if (cstate->spo_must_allowed) in nfsd4_spo_must_allow()
3775 opiter = resp->opcnt; in nfsd4_spo_must_allow()
3776 while (opiter < argp->opcnt) { in nfsd4_spo_must_allow()
3777 this = &argp->ops[opiter++]; in nfsd4_spo_must_allow()
3778 if (test_bit(this->opnum, allow->u.longs) && in nfsd4_spo_must_allow()
3779 cstate->clp->cl_mach_cred && in nfsd4_spo_must_allow()
3780 nfsd4_mach_creds_match(cstate->clp, rqstp)) { in nfsd4_spo_must_allow()
3781 cstate->spo_must_allowed = true; in nfsd4_spo_must_allow()
3785 cstate->spo_must_allowed = false; in nfsd4_spo_must_allow()
3791 if (op->opnum == OP_ILLEGAL || op->status == nfserr_notsupp) in nfsd4_max_reply()
3794 BUG_ON(OPDESC(op)->op_rsize_bop == NULL); in nfsd4_max_reply()
3795 return OPDESC(op)->op_rsize_bop(rqstp, op); in nfsd4_max_reply()
3800 if (OPDESC(op)->op_flags & OP_MODIFIES_SOMETHING) { in warn_on_nonidempotent_op()
3802 op->opnum, nfsd4_op_name(op->opnum)); in warn_on_nonidempotent_op()
3836 .pc_name = "COMPOUND",