Lines Matching +full:chg +full:- +full:done

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
92 static pid_t nfsd_master_pid = (pid_t)-1;
196 * on all DS servers before this increase is done.
206 if (error != 0 || req->newptr == NULL) in sysctl_dsdirsize()
232 if (error != 0 || req->newptr == NULL) in sysctl_srvmaxio()
244 if ((newsrvmaxio & (newsrvmaxio - 1)) != 0) { in sysctl_srvmaxio()
271 tval += MCLBYTES - 1; /* Round up divide. */ in sysctl_srvmaxio()
303 if (error != 0 || req->newptr == NULL) in sysctl_dolocallocks()
307 if (jailed(curthread->td_ucred)) in sysctl_dolocallocks()
354 while (try--) { in nfsrv_sequential_heuristic()
360 --nfsheur[hi].nh_use; in nfsrv_sequential_heuristic()
362 if (nfsheur[hi].nh_use < nh->nh_use) in nfsrv_sequential_heuristic()
367 if (nh->nh_vp != vp) { in nfsrv_sequential_heuristic()
368 nh->nh_vp = vp; in nfsrv_sequential_heuristic()
369 nh->nh_nextoff = uio->uio_offset; in nfsrv_sequential_heuristic()
370 nh->nh_use = NHUSE_INIT; in nfsrv_sequential_heuristic()
371 if (uio->uio_offset == 0) in nfsrv_sequential_heuristic()
372 nh->nh_seqcount = 4; in nfsrv_sequential_heuristic()
374 nh->nh_seqcount = 1; in nfsrv_sequential_heuristic()
378 if ((uio->uio_offset == 0 && nh->nh_seqcount > 0) || in nfsrv_sequential_heuristic()
379 uio->uio_offset == nh->nh_nextoff) { in nfsrv_sequential_heuristic()
381 nh->nh_seqcount += howmany(uio->uio_resid, 16384); in nfsrv_sequential_heuristic()
382 if (nh->nh_seqcount > IO_SEQMAX) in nfsrv_sequential_heuristic()
383 nh->nh_seqcount = IO_SEQMAX; in nfsrv_sequential_heuristic()
384 } else if (qabs(uio->uio_offset - nh->nh_nextoff) <= MAX_REORDERED_RPC * in nfsrv_sequential_heuristic()
385 imax(vp->v_mount->mnt_stat.f_iosize, uio->uio_resid)) { in nfsrv_sequential_heuristic()
387 } else if (nh->nh_seqcount > 1) { in nfsrv_sequential_heuristic()
388 nh->nh_seqcount /= 2; in nfsrv_sequential_heuristic()
390 nh->nh_seqcount = 0; in nfsrv_sequential_heuristic()
392 nh->nh_use += NHUSE_INC; in nfsrv_sequential_heuristic()
393 if (nh->nh_use > NHUSE_MAX) in nfsrv_sequential_heuristic()
394 nh->nh_use = NHUSE_MAX; in nfsrv_sequential_heuristic()
424 * This needs to be done for regular files if: in nfsvno_getattr()
425 * - non-NFSv4 RPCs or in nfsvno_getattr()
426 * - when attrbitp == NULL or in nfsvno_getattr()
427 * - an NFSv4 RPC with any of the above attributes in attrbitp. in nfsvno_getattr()
433 if (vp->v_type == VREG && nfsrv_devidcnt > 0 && (attrbitp == NULL || in nfsvno_getattr()
434 (nd->nd_flag & ND_NFSV4) == 0 || in nfsvno_getattr()
440 error = nfsrv_proxyds(vp, 0, 0, nd->nd_cred, p, in nfsvno_getattr()
447 error = VOP_GETATTR(vp, &nvap->na_vattr, nd->nd_cred); in nfsvno_getattr()
456 nvap->na_atime = na.na_atime; in nfsvno_getattr()
457 nvap->na_mtime = na.na_mtime; in nfsvno_getattr()
458 nvap->na_filerev = na.na_filerev; in nfsvno_getattr()
459 nvap->na_size = na.na_size; in nfsvno_getattr()
460 nvap->na_bytes = na.na_bytes; in nfsvno_getattr()
462 NFSD_DEBUG(4, "nfsvno_getattr: gotattr=%d err=%d chg=%ju\n", gotattr, in nfsvno_getattr()
478 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; in nfsvno_getfh()
479 error = VOP_VPTOFH(vp, &fhp->fh_fid); in nfsvno_getfh()
489 * 1 - You must check for exported rdonly as well as MNT_RDONLY for the write
491 * 2 - The owner is to be given access irrespective of mode bits for some
512 * Disallow write attempts on read-only file systems; in nfsvno_accchk()
517 (vp->v_mount->mnt_flag & MNT_RDONLY)) { in nfsvno_accchk()
518 switch (vp->v_type) { in nfsvno_accchk()
552 if (vp->v_type == VDIR) { in nfsvno_accchk()
568 if (cred->cr_uid == 0 && (override & NFSACCCHK_ALLOWROOT)) in nfsvno_accchk()
572 if (getret == 0 && cred->cr_uid == vattr.va_uid) in nfsvno_accchk()
601 if (vp->v_type == VREG && (vp->v_mount->mnt_flag & MNT_EXPORTED) != 0 && in nfsvno_setattr()
602 nfsrv_devidcnt != 0 && nvap->na_vattr.va_size != VNOVAL && in nfsvno_setattr()
603 nvap->na_vattr.va_size > 0) { in nfsvno_setattr()
604 savsize = nvap->na_vattr.va_size; in nfsvno_setattr()
605 nvap->na_vattr.va_size = VNOVAL; in nfsvno_setattr()
606 if (nvap->na_vattr.va_uid != (uid_t)VNOVAL || in nfsvno_setattr()
607 nvap->na_vattr.va_gid != (gid_t)VNOVAL || in nfsvno_setattr()
608 nvap->na_vattr.va_mode != (mode_t)VNOVAL || in nfsvno_setattr()
609 nvap->na_vattr.va_atime.tv_sec != VNOVAL || in nfsvno_setattr()
610 nvap->na_vattr.va_mtime.tv_sec != VNOVAL) in nfsvno_setattr()
616 error = VOP_SETATTR(vp, &nvap->na_vattr, cred); in nfsvno_setattr()
618 nvap->na_vattr.va_size = savsize; in nfsvno_setattr()
619 if (error == 0 && (nvap->na_vattr.va_uid != (uid_t)VNOVAL || in nfsvno_setattr()
620 nvap->na_vattr.va_gid != (gid_t)VNOVAL || in nfsvno_setattr()
621 nvap->na_vattr.va_size != VNOVAL || in nfsvno_setattr()
622 nvap->na_vattr.va_mode != (mode_t)VNOVAL || in nfsvno_setattr()
623 nvap->na_vattr.va_atime.tv_sec != VNOVAL || in nfsvno_setattr()
624 nvap->na_vattr.va_mtime.tv_sec != VNOVAL)) { in nfsvno_setattr()
626 savbtime = nvap->na_vattr.va_birthtime.tv_sec; in nfsvno_setattr()
627 nvap->na_vattr.va_birthtime.tv_sec = VNOVAL; in nfsvno_setattr()
631 nvap->na_vattr.va_birthtime.tv_sec = savbtime; in nfsvno_setattr()
647 struct componentname *cnp = &ndp->ni_cnd; in nfsvno_namei()
651 int lockleaf = (cnp->cn_flags & LOCKLEAF) != 0, linklen; in nfsvno_namei()
656 cnp->cn_nameptr = cnp->cn_pnbuf; in nfsvno_namei()
657 ndp->ni_lcf = 0; in nfsvno_namei()
661 if (dp->v_type != VDIR) { in nfsvno_namei()
675 cnp->cn_flags |= RDONLY; in nfsvno_namei()
676 ndp->ni_segflg = UIO_SYSSPACE; in nfsvno_namei()
678 if (nd->nd_flag & ND_PUBLOOKUP) { in nfsvno_namei()
679 ndp->ni_loopcnt = 0; in nfsvno_namei()
680 if (cnp->cn_pnbuf[0] == '/') { in nfsvno_namei()
686 for (i = 1; i < ndp->ni_pathlen; i++) in nfsvno_namei()
687 if (cnp->cn_pnbuf[i] != '/') in nfsvno_namei()
689 if (i == ndp->ni_pathlen) { in nfsvno_namei()
697 (nd->nd_flag & ND_NFSV4) == 0) { in nfsvno_namei()
703 cnp->cn_flags |= NOCROSSMOUNT; in nfsvno_namei()
711 ndp->ni_startdir = dp; in nfsvno_namei()
712 ndp->ni_rootdir = rootvnode; in nfsvno_namei()
713 ndp->ni_topdir = NULL; in nfsvno_namei()
716 cnp->cn_flags |= LOCKLEAF; in nfsvno_namei()
718 cnp->cn_nameptr = cnp->cn_pnbuf; in nfsvno_namei()
721 * ndp->ni_vp and ni_dvp are left uninitialized or NULL and in nfsvno_namei()
734 if ((cnp->cn_flags & ISSYMLINK) == 0) { in nfsvno_namei()
735 if (ndp->ni_vp && !lockleaf) in nfsvno_namei()
736 NFSVOPUNLOCK(ndp->ni_vp); in nfsvno_namei()
743 if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1) in nfsvno_namei()
744 NFSVOPUNLOCK(ndp->ni_dvp); in nfsvno_namei()
745 if (!(nd->nd_flag & ND_PUBLOOKUP)) { in nfsvno_namei()
750 if (ndp->ni_loopcnt++ >= MAXSYMLINKS) { in nfsvno_namei()
754 if (ndp->ni_pathlen > 1) in nfsvno_namei()
757 cp = cnp->cn_pnbuf; in nfsvno_namei()
767 error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred); in nfsvno_namei()
770 if (ndp->ni_pathlen > 1) in nfsvno_namei()
773 vrele(ndp->ni_dvp); in nfsvno_namei()
774 vput(ndp->ni_vp); in nfsvno_namei()
777 linklen = MAXPATHLEN - auio.uio_resid; in nfsvno_namei()
782 if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { in nfsvno_namei()
790 if (ndp->ni_pathlen > 1) { in nfsvno_namei()
791 NFSBCOPY(ndp->ni_next, cp + linklen, ndp->ni_pathlen); in nfsvno_namei()
792 uma_zfree(namei_zone, cnp->cn_pnbuf); in nfsvno_namei()
793 cnp->cn_pnbuf = cp; in nfsvno_namei()
795 cnp->cn_pnbuf[linklen] = '\0'; in nfsvno_namei()
796 ndp->ni_pathlen += linklen; in nfsvno_namei()
805 vput(ndp->ni_vp); in nfsvno_namei()
806 ndp->ni_vp = NULL; in nfsvno_namei()
808 if (cnp->cn_pnbuf[0] == '/') { in nfsvno_namei()
809 vrele(ndp->ni_dvp); in nfsvno_namei()
810 ndp->ni_dvp = ndp->ni_rootdir; in nfsvno_namei()
811 VREF(ndp->ni_dvp); in nfsvno_namei()
813 ndp->ni_startdir = ndp->ni_dvp; in nfsvno_namei()
814 ndp->ni_dvp = NULL; in nfsvno_namei()
817 cnp->cn_flags &= ~LOCKLEAF; in nfsvno_namei()
822 ndp->ni_vp = NULL; in nfsvno_namei()
823 ndp->ni_dvp = NULL; in nfsvno_namei()
824 ndp->ni_startdir = NULL; in nfsvno_namei()
825 } else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) { in nfsvno_namei()
826 ndp->ni_dvp = NULL; in nfsvno_namei()
841 struct componentname *cnp = &ndp->ni_cnd; in nfsvno_setpathbuf()
843 cnp->cn_flags |= (NOMACCHECK); in nfsvno_setpathbuf()
844 cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); in nfsvno_setpathbuf()
847 *bufpp = cnp->cn_pnbuf; in nfsvno_setpathbuf()
857 uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf); in nfsvno_relpathbuf()
858 ndp->ni_cnd.cn_pnbuf = NULL; in nfsvno_relpathbuf()
875 uiop->uio_iovcnt = nfsrv_createiovec_extpgs(len, maxextsiz, in nfsvno_readlink()
878 uiop->uio_iovcnt = nfsrv_createiovec(len, &mp3, &mp, &iv); in nfsvno_readlink()
879 uiop->uio_iov = iv; in nfsvno_readlink()
880 uiop->uio_offset = 0; in nfsvno_readlink()
881 uiop->uio_resid = len; in nfsvno_readlink()
882 uiop->uio_rw = UIO_READ; in nfsvno_readlink()
883 uiop->uio_segflg = UIO_SYSSPACE; in nfsvno_readlink()
884 uiop->uio_td = NULL; in nfsvno_readlink()
892 if (uiop->uio_resid > 0) { in nfsvno_readlink()
893 len -= uiop->uio_resid; in nfsvno_readlink()
899 mp = nfsrv_adj(mp3, NFS_MAXPATHLEN - tlen, in nfsvno_readlink()
900 tlen - len); in nfsvno_readlink()
934 m->m_len = 0; in nfsrv_createiovec()
936 left -= siz; in nfsrv_createiovec()
939 m2->m_next = m; in nfsrv_createiovec()
953 iv->iov_base = mtod(m, caddr_t) + m->m_len; in nfsrv_createiovec()
954 iv->iov_len = siz; in nfsrv_createiovec()
955 m->m_len += siz; in nfsrv_createiovec()
956 left -= siz; in nfsrv_createiovec()
960 m = m->m_next; in nfsrv_createiovec()
991 left -= siz; in nfsrv_createiovec_extpgs()
992 i += m->m_epg_npgs; in nfsrv_createiovec_extpgs()
994 m2->m_next = m; in nfsrv_createiovec_extpgs()
1009 iv->iov_base = (void *)PHYS_TO_DMAP(m->m_epg_pa[pgno]); in nfsrv_createiovec_extpgs()
1010 iv->iov_len = siz; in nfsrv_createiovec_extpgs()
1011 m->m_len += siz; in nfsrv_createiovec_extpgs()
1012 if (pgno == m->m_epg_npgs - 1) in nfsrv_createiovec_extpgs()
1013 m->m_epg_last_len = siz; in nfsrv_createiovec_extpgs()
1014 left -= siz; in nfsrv_createiovec_extpgs()
1019 if (pgno == m->m_epg_npgs && left > 0) { in nfsrv_createiovec_extpgs()
1020 m = m->m_next; in nfsrv_createiovec_extpgs()
1057 uiop->uio_iovcnt = nfsrv_createiovec_extpgs(len, maxextsiz, in nfsvno_read()
1060 uiop->uio_iovcnt = nfsrv_createiovec(len, &m3, &m, &iv); in nfsvno_read()
1061 uiop->uio_iov = iv; in nfsvno_read()
1062 uiop->uio_offset = off; in nfsvno_read()
1063 uiop->uio_resid = len; in nfsvno_read()
1064 uiop->uio_rw = UIO_READ; in nfsvno_read()
1065 uiop->uio_segflg = UIO_SYSSPACE; in nfsvno_read()
1066 uiop->uio_td = NULL; in nfsvno_read()
1068 ioflag |= nh->nh_seqcount << IO_SEQSHIFT; in nfsvno_read()
1070 NFSD_VNET(nfsstatsv1_p)->srvbytes[NFSV4OP_READ] += uiop->uio_resid; in nfsvno_read()
1078 nh->nh_nextoff = uiop->uio_offset; in nfsvno_read()
1079 tlen = len - uiop->uio_resid; in nfsvno_read()
1086 m = nfsrv_adj(m3, len - tlen, tlen - cnt); in nfsvno_read()
1115 i = mtod(mp, caddr_t) + mp->m_len - cp; in nfsrv_createiovecw()
1118 len -= i; in nfsrv_createiovecw()
1121 mp = mp->m_next; in nfsrv_createiovecw()
1126 i = mp->m_len; in nfsrv_createiovecw()
1134 i = mtod(mp, caddr_t) + mp->m_len - cp; in nfsrv_createiovecw()
1141 ivp->iov_base = cp; in nfsrv_createiovecw()
1142 ivp->iov_len = i; in nfsrv_createiovecw()
1144 len -= i; in nfsrv_createiovecw()
1146 mp = mp->m_next; in nfsrv_createiovecw()
1148 i = mp->m_len; in nfsrv_createiovecw()
1185 uiop->uio_iov = iv; in nfsvno_write()
1186 uiop->uio_iovcnt = cnt; in nfsvno_write()
1187 uiop->uio_resid = retlen; in nfsvno_write()
1188 uiop->uio_rw = UIO_WRITE; in nfsvno_write()
1189 uiop->uio_segflg = UIO_SYSSPACE; in nfsvno_write()
1191 uiop->uio_offset = off; in nfsvno_write()
1193 ioflags |= nh->nh_seqcount << IO_SEQSHIFT; in nfsvno_write()
1195 NFSD_VNET(nfsstatsv1_p)->srvbytes[NFSV4OP_WRITE] += uiop->uio_resid; in nfsvno_write()
1198 nh->nh_nextoff = uiop->uio_offset; in nfsvno_write()
1217 error = nd->nd_repstat; in nfsvno_createsub()
1218 if (!error && ndp->ni_vp == NULL) { in nfsvno_createsub()
1219 if (nvap->na_type == VREG || nvap->na_type == VSOCK) { in nfsvno_createsub()
1220 error = VOP_CREATE(ndp->ni_dvp, in nfsvno_createsub()
1221 &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); in nfsvno_createsub()
1223 if (error == 0 && nvap->na_type == VREG) { in nfsvno_createsub()
1229 nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, in nfsvno_createsub()
1230 nd->nd_cred, p); in nfsvno_createsub()
1232 VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : in nfsvno_createsub()
1239 nvap->na_atime.tv_sec = cverf[0]; in nfsvno_createsub()
1240 nvap->na_atime.tv_nsec = cverf[1]; in nfsvno_createsub()
1241 error = VOP_SETATTR(ndp->ni_vp, in nfsvno_createsub()
1242 &nvap->na_vattr, nd->nd_cred); in nfsvno_createsub()
1244 vput(ndp->ni_vp); in nfsvno_createsub()
1245 ndp->ni_vp = NULL; in nfsvno_createsub()
1254 } else if (nvap->na_type == VCHR || nvap->na_type == VBLK || in nfsvno_createsub()
1255 nvap->na_type == VFIFO) { in nfsvno_createsub()
1256 if (nvap->na_type == VCHR && rdev == 0xffffffff) in nfsvno_createsub()
1257 nvap->na_type = VFIFO; in nfsvno_createsub()
1258 if (nvap->na_type != VFIFO && in nfsvno_createsub()
1259 (error = priv_check_cred(nd->nd_cred, PRIV_VFS_MKNOD_DEV))) { in nfsvno_createsub()
1261 vput(ndp->ni_dvp); in nfsvno_createsub()
1264 nvap->na_rdev = rdev; in nfsvno_createsub()
1265 error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, in nfsvno_createsub()
1266 &ndp->ni_cnd, &nvap->na_vattr); in nfsvno_createsub()
1267 VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : in nfsvno_createsub()
1274 vput(ndp->ni_dvp); in nfsvno_createsub()
1278 *vpp = ndp->ni_vp; in nfsvno_createsub()
1283 * 1 - clean up the lookup in nfsvno_createsub()
1284 * 2 - iff !error and na_size set, truncate it in nfsvno_createsub()
1287 *vpp = ndp->ni_vp; in nfsvno_createsub()
1288 if (ndp->ni_dvp == *vpp) in nfsvno_createsub()
1289 vrele(ndp->ni_dvp); in nfsvno_createsub()
1291 vput(ndp->ni_dvp); in nfsvno_createsub()
1292 if (!error && nvap->na_size != VNOVAL) { in nfsvno_createsub()
1294 nd->nd_cred, exp, p, NFSACCCHK_NOOVERRIDE, in nfsvno_createsub()
1297 tempsize = nvap->na_size; in nfsvno_createsub()
1299 nvap->na_size = tempsize; in nfsvno_createsub()
1301 nd->nd_cred, p, exp); in nfsvno_createsub()
1323 vtyp = nvap->na_type; in nfsvno_mknod()
1327 if (ndp->ni_vp) { in nfsvno_mknod()
1329 vput(ndp->ni_dvp); in nfsvno_mknod()
1330 vrele(ndp->ni_vp); in nfsvno_mknod()
1336 vput(ndp->ni_dvp); in nfsvno_mknod()
1341 error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp, in nfsvno_mknod()
1342 &ndp->ni_cnd, &nvap->na_vattr); in nfsvno_mknod()
1343 VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, in nfsvno_mknod()
1347 if (nvap->na_type != VFIFO && in nfsvno_mknod()
1350 vput(ndp->ni_dvp); in nfsvno_mknod()
1353 error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, in nfsvno_mknod()
1354 &ndp->ni_cnd, &nvap->na_vattr); in nfsvno_mknod()
1355 VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, in nfsvno_mknod()
1378 if (ndp->ni_vp != NULL) { in nfsvno_mkdir()
1379 if (ndp->ni_dvp == ndp->ni_vp) in nfsvno_mkdir()
1380 vrele(ndp->ni_dvp); in nfsvno_mkdir()
1382 vput(ndp->ni_dvp); in nfsvno_mkdir()
1383 vrele(ndp->ni_vp); in nfsvno_mkdir()
1388 error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, in nfsvno_mkdir()
1389 &nvap->na_vattr); in nfsvno_mkdir()
1390 VOP_VPUT_PAIR(ndp->ni_dvp, error == 0 ? &ndp->ni_vp : NULL, false); in nfsvno_mkdir()
1408 if (ndp->ni_vp) { in nfsvno_symlink()
1410 if (ndp->ni_dvp == ndp->ni_vp) in nfsvno_symlink()
1411 vrele(ndp->ni_dvp); in nfsvno_symlink()
1413 vput(ndp->ni_dvp); in nfsvno_symlink()
1414 vrele(ndp->ni_vp); in nfsvno_symlink()
1419 error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, in nfsvno_symlink()
1420 &nvap->na_vattr, pathcp); in nfsvno_symlink()
1427 VOP_VPUT_PAIR(ndp->ni_dvp, &ndp->ni_vp, !not_v2 && error == 0); in nfsvno_symlink()
1439 * So, if it returns with uiop->uio_iov->iov_base != NULL, that must
1453 if ((nd->nd_flag & ND_NFSV3) && in nfsvno_getsymlink()
1466 if (nd->nd_flag & ND_NFSV2) { in nfsvno_getsymlink()
1468 nvap->na_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); in nfsvno_getsymlink()
1482 * Remove a non-directory object.
1493 vp = ndp->ni_vp; in nfsvno_removesub()
1495 if (vp->v_type == VDIR) in nfsvno_removesub()
1503 error = VOP_REMOVE(ndp->ni_dvp, vp, &ndp->ni_cnd); in nfsvno_removesub()
1506 if (ndp->ni_dvp == vp) in nfsvno_removesub()
1507 vrele(ndp->ni_dvp); in nfsvno_removesub()
1509 vput(ndp->ni_dvp); in nfsvno_removesub()
1526 vp = ndp->ni_vp; in nfsvno_rmdirsub()
1527 if (vp->v_type != VDIR) { in nfsvno_rmdirsub()
1534 if (ndp->ni_dvp == vp) { in nfsvno_rmdirsub()
1541 if (vp->v_vflag & VV_ROOT) in nfsvno_rmdirsub()
1545 error = VOP_RMDIR(ndp->ni_dvp, vp, &ndp->ni_cnd); in nfsvno_rmdirsub()
1546 if (ndp->ni_dvp == vp) in nfsvno_rmdirsub()
1547 vrele(ndp->ni_dvp); in nfsvno_rmdirsub()
1549 vput(ndp->ni_dvp); in nfsvno_rmdirsub()
1569 fvp = fromndp->ni_vp; in nfsvno_rename()
1571 vrele(fromndp->ni_dvp); in nfsvno_rename()
1576 tdvp = tondp->ni_dvp; in nfsvno_rename()
1577 tvp = tondp->ni_vp; in nfsvno_rename()
1579 if (fvp->v_type == VDIR && tvp->v_type != VDIR) { in nfsvno_rename()
1582 } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) { in nfsvno_rename()
1586 if (tvp->v_type == VDIR && tvp->v_mountedhere) { in nfsvno_rename()
1596 if ((tondp->ni_cnd.cn_namelen == 1 && in nfsvno_rename()
1597 tondp->ni_cnd.cn_nameptr[0] == '.') || in nfsvno_rename()
1598 (tondp->ni_cnd.cn_namelen == 2 && in nfsvno_rename()
1599 tondp->ni_cnd.cn_nameptr[0] == '.' && in nfsvno_rename()
1600 tondp->ni_cnd.cn_nameptr[1] == '.')) { in nfsvno_rename()
1605 if (fvp->v_type == VDIR && fvp->v_mountedhere) { in nfsvno_rename()
1609 if (fvp->v_mount != tdvp->v_mount) { in nfsvno_rename()
1620 * do. Set error to -1 to indicate this. in nfsvno_rename()
1622 error = -1; in nfsvno_rename()
1652 error = VOP_RENAME(fromndp->ni_dvp, fromndp->ni_vp, in nfsvno_rename()
1653 &fromndp->ni_cnd, tondp->ni_dvp, tondp->ni_vp, in nfsvno_rename()
1654 &tondp->ni_cnd); in nfsvno_rename()
1662 vrele(fromndp->ni_dvp); in nfsvno_rename()
1664 if (error == -1) in nfsvno_rename()
1695 xp = ndp->ni_vp; in nfsvno_link()
1699 xp = ndp->ni_dvp; in nfsvno_link()
1700 if (vp->v_mount != xp->v_mount) in nfsvno_link()
1708 error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd); in nfsvno_link()
1711 if (ndp->ni_dvp == vp) { in nfsvno_link()
1712 vrele(ndp->ni_dvp); in nfsvno_link()
1716 VOP_VPUT_PAIR(ndp->ni_dvp, &vp, true); in nfsvno_link()
1719 if (ndp->ni_dvp == ndp->ni_vp) in nfsvno_link()
1720 vrele(ndp->ni_dvp); in nfsvno_link()
1722 vput(ndp->ni_dvp); in nfsvno_link()
1723 if (ndp->ni_vp) in nfsvno_link()
1724 vrele(ndp->ni_vp); in nfsvno_link()
1742 * file is done. At this time VOP_FSYNC does not accept offset and in nfsvno_fsync()
1749 (vp->v_mount->mnt_kern_flag & MNTK_USES_BCACHE) == 0) { in nfsvno_fsync()
1761 int iosize = vp->v_mount->mnt_stat.f_iosize; in nfsvno_fsync()
1762 int iomask = iosize - 1; in nfsvno_fsync()
1767 * Align to iosize boundary, super-align to page boundary. in nfsvno_fsync()
1779 if (vp->v_object && vm_object_mightbedirty(vp->v_object)) { in nfsvno_fsync()
1780 VM_OBJECT_WLOCK(vp->v_object); in nfsvno_fsync()
1781 vm_object_page_clean(vp->v_object, off, off + cnt, in nfsvno_fsync()
1783 VM_OBJECT_WUNLOCK(vp->v_object); in nfsvno_fsync()
1786 bo = &vp->v_bufobj; in nfsvno_fsync()
1801 if ((bp = gbincore(&vp->v_bufobj, lblkno)) != NULL) { in nfsvno_fsync()
1807 if ((bp->b_flags & (B_DELWRI|B_INVAL)) == in nfsvno_fsync()
1810 bp->b_flags &= ~B_ASYNC; in nfsvno_fsync()
1820 cnt -= iosize; in nfsvno_fsync()
1842 error = nfsrv_pnfsstatfs(tsf, vp->v_mount); in nfsvno_statfs()
1848 error = VFS_STATFS(vp->v_mount, sf); in nfsvno_statfs()
1851 sf->f_blocks = tsf->f_blocks; in nfsvno_statfs()
1852 sf->f_bavail = tsf->f_bavail; in nfsvno_statfs()
1853 sf->f_bfree = tsf->f_bfree; in nfsvno_statfs()
1854 sf->f_bsize = tsf->f_bsize; in nfsvno_statfs()
1863 if (sf->f_bavail < 0) in nfsvno_statfs()
1864 sf->f_bavail = 0; in nfsvno_statfs()
1865 if (sf->f_ffree < 0) in nfsvno_statfs()
1866 sf->f_ffree = 0; in nfsvno_statfs()
1890 if (ndp->ni_vp == NULL) { in nfsvno_open()
1895 oldrepstat = nd->nd_repstat; in nfsvno_open()
1896 nd->nd_repstat = nfsrv_opencheck(clientid, in nfsvno_open()
1897 stateidp, stp, NULL, nd, p, nd->nd_repstat); in nfsvno_open()
1898 if (nd->nd_repstat != 0 && oldrepstat == 0) in nfsvno_open()
1901 if (!nd->nd_repstat) { in nfsvno_open()
1902 if (ndp->ni_vp == NULL) { in nfsvno_open()
1903 nd->nd_repstat = VOP_CREATE(ndp->ni_dvp, in nfsvno_open()
1904 &ndp->ni_vp, &ndp->ni_cnd, &nvap->na_vattr); in nfsvno_open()
1906 if (nd->nd_repstat == 0) { in nfsvno_open()
1912 nfsrv_pnfscreate(ndp->ni_vp, &nvap->na_vattr, in nfsvno_open()
1915 VOP_VPUT_PAIR(ndp->ni_dvp, nd->nd_repstat == 0 ? in nfsvno_open()
1916 &ndp->ni_vp : NULL, false); in nfsvno_open()
1918 if (!nd->nd_repstat) { in nfsvno_open()
1922 nvap->na_atime.tv_sec = cverf[0]; in nfsvno_open()
1923 nvap->na_atime.tv_nsec = cverf[1]; in nfsvno_open()
1924 nd->nd_repstat = VOP_SETATTR(ndp->ni_vp, in nfsvno_open()
1925 &nvap->na_vattr, cred); in nfsvno_open()
1926 if (nd->nd_repstat != 0) { in nfsvno_open()
1927 vput(ndp->ni_vp); in nfsvno_open()
1928 ndp->ni_vp = NULL; in nfsvno_open()
1929 nd->nd_repstat = NFSERR_NOTSUPP; in nfsvno_open()
1934 nfsrv_fixattr(nd, ndp->ni_vp, nvap, in nfsvno_open()
1938 vp = ndp->ni_vp; in nfsvno_open()
1941 vp = ndp->ni_vp; in nfsvno_open()
1943 if (ndp->ni_dvp == vp) in nfsvno_open()
1944 vrele(ndp->ni_dvp); in nfsvno_open()
1946 vput(ndp->ni_dvp); in nfsvno_open()
1948 if (NFSVNO_ISSETSIZE(nvap) && vp->v_type == VREG) { in nfsvno_open()
1949 if (ndp->ni_cnd.cn_flags & RDONLY) in nfsvno_open()
1953 nd->nd_repstat = nfsvno_accchk(vp, in nfsvno_open()
1957 nd->nd_repstat = nfsrv_opencheck(clientid, in nfsvno_open()
1958 stateidp, stp, vp, nd, p, nd->nd_repstat); in nfsvno_open()
1959 if (!nd->nd_repstat) { in nfsvno_open()
1960 tempsize = nvap->na_size; in nfsvno_open()
1962 nvap->na_size = tempsize; in nfsvno_open()
1963 nd->nd_repstat = nfsvno_setattr(vp, in nfsvno_open()
1966 } else if (vp->v_type == VREG) { in nfsvno_open()
1967 nd->nd_repstat = nfsrv_opencheck(clientid, in nfsvno_open()
1968 stateidp, stp, vp, nd, p, nd->nd_repstat); in nfsvno_open()
1981 if (ndp->ni_dvp == ndp->ni_vp) in nfsvno_open()
1982 vrele(ndp->ni_dvp); in nfsvno_open()
1984 vput(ndp->ni_dvp); in nfsvno_open()
1985 if (ndp->ni_vp) in nfsvno_open()
1986 vput(ndp->ni_vp); in nfsvno_open()
2012 (void) VOP_SETATTR(vp, &va, nd->nd_cred); in nfsvno_updfilerev()
2041 error = nfsv4_fillattr(nd, mp, vp, NULL, &nvap->na_vattr, fhp, rderror, in nfsvno_fillattr()
2052 * - mallocs what it thinks is enough to read
2054 * - calls VOP_READDIR()
2055 * - loops around building the reply
2059 * - it trims out records with d_fileno == 0
2062 * - it trims out records with d_type == DT_WHT
2091 if (nd->nd_repstat) { in nfsrvd_readdir()
2095 if (nd->nd_flag & ND_NFSV2) { in nfsrvd_readdir()
2109 siz = ((cnt + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); in nfsrvd_readdir()
2111 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdir()
2112 nd->nd_repstat = getret = nfsvno_getattr(vp, &at, nd, p, 1, in nfsrvd_readdir()
2121 if (!nd->nd_repstat && toff && verf != at.na_filerev) in nfsrvd_readdir()
2122 nd->nd_repstat = NFSERR_BAD_COOKIE; in nfsrvd_readdir()
2125 if (!nd->nd_repstat && vp->v_type != VDIR) in nfsrvd_readdir()
2126 nd->nd_repstat = NFSERR_NOTDIR; in nfsrvd_readdir()
2127 if (nd->nd_repstat == 0 && cnt == 0) { in nfsrvd_readdir()
2128 if (nd->nd_flag & ND_NFSV2) in nfsrvd_readdir()
2130 nd->nd_repstat = EPERM; in nfsrvd_readdir()
2132 nd->nd_repstat = NFSERR_TOOSMALL; in nfsrvd_readdir()
2134 if (!nd->nd_repstat) in nfsrvd_readdir()
2135 nd->nd_repstat = nfsvno_accchk(vp, VEXEC, in nfsrvd_readdir()
2136 nd->nd_cred, exp, p, NFSACCCHK_NOOVERRIDE, in nfsrvd_readdir()
2138 if (nd->nd_repstat) { in nfsrvd_readdir()
2140 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdir()
2144 is_ufs = strcmp(vp->v_mount->mnt_vfc->vfc_name, "ufs") == 0; in nfsrvd_readdir()
2162 nd->nd_repstat = VOP_READDIR(vp, &io, nd->nd_cred, &eofflag, &ncookies, in nfsrvd_readdir()
2166 siz -= io.uio_resid; in nfsrvd_readdir()
2168 if (!cookies && !nd->nd_repstat) in nfsrvd_readdir()
2169 nd->nd_repstat = NFSERR_PERM; in nfsrvd_readdir()
2170 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdir()
2172 if (!nd->nd_repstat) in nfsrvd_readdir()
2173 nd->nd_repstat = getret; in nfsrvd_readdir()
2177 * Handles the failed cases. nd->nd_repstat == 0 past here. in nfsrvd_readdir()
2179 if (nd->nd_repstat) { in nfsrvd_readdir()
2184 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdir()
2194 if (nd->nd_flag & ND_NFSV2) { in nfsrvd_readdir()
2226 (dp->d_fileno == 0 || dp->d_type == DT_WHT || in nfsrvd_readdir()
2228 cpos += dp->d_reclen; in nfsrvd_readdir()
2231 ncookies--; in nfsrvd_readdir()
2247 (nd->nd_flag & (ND_TLS | ND_EXTPG | ND_SAVEREPLY)) == ND_TLS && in nfsrvd_readdir()
2248 (nd->nd_flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4) in nfsrvd_readdir()
2249 nd->nd_flag |= ND_EXTPG; in nfsrvd_readdir()
2257 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdir()
2268 nlen = dp->d_namlen; in nfsrvd_readdir()
2269 if (dp->d_fileno != 0 && dp->d_type != DT_WHT && in nfsrvd_readdir()
2271 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdir()
2284 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdir()
2287 txdr_hyper(dp->d_fileno, tl); in nfsrvd_readdir()
2291 *tl = txdr_unsigned(dp->d_fileno); in nfsrvd_readdir()
2293 (void) nfsm_strtom(nd, dp->d_name, nlen); in nfsrvd_readdir()
2294 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdir()
2302 cpos += dp->d_reclen; in nfsrvd_readdir()
2305 ncookies--; in nfsrvd_readdir()
2358 if (nd->nd_repstat) { in nfsrvd_readdirplus()
2392 siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); in nfsrvd_readdirplus()
2394 if (nd->nd_flag & ND_NFSV4) { in nfsrvd_readdirplus()
2417 nd->nd_repstat = getret = nfsvno_getattr(vp, &at, nd, p, 1, NULL); in nfsrvd_readdirplus()
2419 if (!nd->nd_repstat) { in nfsrvd_readdirplus()
2427 if (nd->nd_flag & ND_NFSV4) { in nfsrvd_readdirplus()
2428 nd->nd_repstat = NFSERR_NOTSAME; in nfsrvd_readdirplus()
2430 nd->nd_repstat = NFSERR_BAD_COOKIE; in nfsrvd_readdirplus()
2435 if (!nd->nd_repstat && vp->v_type != VDIR) in nfsrvd_readdirplus()
2436 nd->nd_repstat = NFSERR_NOTDIR; in nfsrvd_readdirplus()
2437 if (!nd->nd_repstat && cnt == 0) in nfsrvd_readdirplus()
2438 nd->nd_repstat = NFSERR_TOOSMALL; in nfsrvd_readdirplus()
2439 if (!nd->nd_repstat) in nfsrvd_readdirplus()
2440 nd->nd_repstat = nfsvno_accchk(vp, VEXEC, in nfsrvd_readdirplus()
2441 nd->nd_cred, exp, p, NFSACCCHK_NOOVERRIDE, in nfsrvd_readdirplus()
2443 if (nd->nd_repstat) { in nfsrvd_readdirplus()
2445 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdirplus()
2449 is_ufs = strcmp(vp->v_mount->mnt_vfc->vfc_name, "ufs") == 0; in nfsrvd_readdirplus()
2450 is_zfs = strcmp(vp->v_mount->mnt_vfc->vfc_name, "zfs") == 0; in nfsrvd_readdirplus()
2469 nd->nd_repstat = VOP_READDIR(vp, &io, nd->nd_cred, &eofflag, &ncookies, in nfsrvd_readdirplus()
2473 siz -= io.uio_resid; in nfsrvd_readdirplus()
2477 if (!cookies && !nd->nd_repstat) in nfsrvd_readdirplus()
2478 nd->nd_repstat = NFSERR_PERM; in nfsrvd_readdirplus()
2479 if (!nd->nd_repstat) in nfsrvd_readdirplus()
2480 nd->nd_repstat = getret; in nfsrvd_readdirplus()
2481 if (nd->nd_repstat) { in nfsrvd_readdirplus()
2486 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdirplus()
2496 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdirplus()
2525 (dp->d_fileno == 0 || dp->d_type == DT_WHT || in nfsrvd_readdirplus()
2527 ((nd->nd_flag & ND_NFSV4) && in nfsrvd_readdirplus()
2528 ((dp->d_namlen == 1 && dp->d_name[0] == '.') || in nfsrvd_readdirplus()
2529 (dp->d_namlen==2 && dp->d_name[0]=='.' && dp->d_name[1]=='.'))))) { in nfsrvd_readdirplus()
2530 cpos += dp->d_reclen; in nfsrvd_readdirplus()
2533 ncookies--; in nfsrvd_readdirplus()
2545 mp = vp->v_mount; in nfsrvd_readdirplus()
2548 nd->nd_repstat = vfs_busy(mp, 0); in nfsrvd_readdirplus()
2550 if (nd->nd_repstat != 0) { in nfsrvd_readdirplus()
2554 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdirplus()
2564 * be done. in nfsrvd_readdirplus()
2565 * This needs to be done here for NFSv4, since NFSv4 never does in nfsrvd_readdirplus()
2574 cn.cn_cred = nd->nd_cred; in nfsrvd_readdirplus()
2589 (nd->nd_flag & (ND_TLS | ND_EXTPG | ND_SAVEREPLY)) == ND_TLS && in nfsrvd_readdirplus()
2590 (nd->nd_flag & (ND_NFSV4 | ND_NFSV41)) != ND_NFSV4) in nfsrvd_readdirplus()
2591 nd->nd_flag |= ND_EXTPG; in nfsrvd_readdirplus()
2597 mb0 = nd->nd_mb; in nfsrvd_readdirplus()
2598 bpos0 = nd->nd_bpos; in nfsrvd_readdirplus()
2599 bextpg0 = nd->nd_bextpg; in nfsrvd_readdirplus()
2600 bextpgsiz0 = nd->nd_bextpgsiz; in nfsrvd_readdirplus()
2608 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdirplus()
2620 mb1 = nd->nd_mb; in nfsrvd_readdirplus()
2621 bpos1 = nd->nd_bpos; in nfsrvd_readdirplus()
2622 bextpg1 = nd->nd_bextpg; in nfsrvd_readdirplus()
2623 bextpgsiz1 = nd->nd_bextpgsiz; in nfsrvd_readdirplus()
2628 nlen = dp->d_namlen; in nfsrvd_readdirplus()
2629 if (dp->d_fileno != 0 && dp->d_type != DT_WHT && in nfsrvd_readdirplus()
2631 ((nd->nd_flag & ND_NFSV3) || nlen > 2 || in nfsrvd_readdirplus()
2632 (nlen==2 && (dp->d_name[0]!='.' || dp->d_name[1]!='.')) in nfsrvd_readdirplus()
2633 || (nlen == 1 && dp->d_name[0] != '.'))) { in nfsrvd_readdirplus()
2638 mb1 = nd->nd_mb; in nfsrvd_readdirplus()
2639 bpos1 = nd->nd_bpos; in nfsrvd_readdirplus()
2640 bextpg1 = nd->nd_bextpg; in nfsrvd_readdirplus()
2641 bextpgsiz1 = nd->nd_bextpgsiz; in nfsrvd_readdirplus()
2653 mounted_on_fileno = (uint64_t)dp->d_fileno; in nfsrvd_readdirplus()
2654 if ((nd->nd_flag & ND_NFSV3) || in nfsrvd_readdirplus()
2656 dp->d_type == DT_UNKNOWN || in nfsrvd_readdirplus()
2657 (dp->d_type == DT_DIR && in nfsrvd_readdirplus()
2659 if (nd->nd_flag & ND_NFSV4) in nfsrvd_readdirplus()
2661 vp, dp->d_fileno); in nfsrvd_readdirplus()
2664 r = VFS_VGET(mp, dp->d_fileno, in nfsrvd_readdirplus()
2676 nd->nd_cred; in nfsrvd_readdirplus()
2678 cn.cn_nameptr = dp->d_name; in nfsrvd_readdirplus()
2683 dp->d_name[0] == '.' && in nfsrvd_readdirplus()
2684 dp->d_name[1] == '.') in nfsrvd_readdirplus()
2689 nd->nd_repstat = EPERM; in nfsrvd_readdirplus()
2692 if ((vp->v_vflag & VV_ROOT) != 0 in nfsrvd_readdirplus()
2713 (nd->nd_flag & ND_NFSV4) != 0 && in nfsrvd_readdirplus()
2714 nvp->v_type == VDIR && in nfsrvd_readdirplus()
2715 nvp->v_mountedhere != NULL) { in nfsrvd_readdirplus()
2716 new_mp = nvp->v_mountedhere; in nfsrvd_readdirplus()
2743 ((nd->nd_flag & ND_NFSV3) || in nfsrvd_readdirplus()
2751 (nd->nd_flag & ND_NFSV4) != 0 && in nfsrvd_readdirplus()
2752 nvp->v_type == VDIR && in nfsrvd_readdirplus()
2753 vp->v_mount != nvp->v_mount) { in nfsrvd_readdirplus()
2763 new_mp = nvp->v_mount; in nfsrvd_readdirplus()
2788 if ((nd->nd_flag & ND_NFSV3) || in nfsrvd_readdirplus()
2791 nd->nd_repstat = r; in nfsrvd_readdirplus()
2797 VATTR_NULL(&nvap->na_vattr); in nfsrvd_readdirplus()
2798 nvap->na_fileid = dp->d_fileno; in nfsrvd_readdirplus()
2799 nvap->na_type = NFS_DTYPETOVTYPE(dp->d_type); in nfsrvd_readdirplus()
2805 if (nd->nd_flag & ND_NFSV3) { in nfsrvd_readdirplus()
2808 txdr_hyper(dp->d_fileno, tl); in nfsrvd_readdirplus()
2809 dirlen += nfsm_strtom(nd, dp->d_name, nlen); in nfsrvd_readdirplus()
2822 dirlen += nfsm_strtom(nd, dp->d_name, nlen); in nfsrvd_readdirplus()
2832 &nd->nd_repstat); in nfsrvd_readdirplus()
2833 if (nd->nd_repstat) { in nfsrvd_readdirplus()
2843 nd->nd_cred, p, isdgram, 0, in nfsrvd_readdirplus()
2849 nd->nd_cred, p, isdgram, 0, in nfsrvd_readdirplus()
2863 cpos += dp->d_reclen; in nfsrvd_readdirplus()
2866 ncookies--; in nfsrvd_readdirplus()
2875 if (dirlen > cnt || nd->nd_repstat) { in nfsrvd_readdirplus()
2876 if (!nd->nd_repstat && entrycnt == 0) in nfsrvd_readdirplus()
2877 nd->nd_repstat = NFSERR_TOOSMALL; in nfsrvd_readdirplus()
2878 if (nd->nd_repstat) { in nfsrvd_readdirplus()
2880 if (nd->nd_flag & ND_NFSV3) in nfsrvd_readdirplus()
2887 if (!nd->nd_repstat) { in nfsrvd_readdirplus()
2919 switch (nd->nd_flag & (ND_NFSV2 | ND_NFSV3 | ND_NFSV4)) { in nfsrv_sattr()
2924 * --> check the low order 2 bytes for 0xffff in nfsrv_sattr()
2926 if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff) in nfsrv_sattr()
2927 nvap->na_mode = nfstov_mode(sp->sa_mode); in nfsrv_sattr()
2928 if (sp->sa_uid != newnfs_xdrneg1) in nfsrv_sattr()
2929 nvap->na_uid = fxdr_unsigned(uid_t, sp->sa_uid); in nfsrv_sattr()
2930 if (sp->sa_gid != newnfs_xdrneg1) in nfsrv_sattr()
2931 nvap->na_gid = fxdr_unsigned(gid_t, sp->sa_gid); in nfsrv_sattr()
2932 if (sp->sa_size != newnfs_xdrneg1) in nfsrv_sattr()
2933 nvap->na_size = fxdr_unsigned(u_quad_t, sp->sa_size); in nfsrv_sattr()
2934 if (sp->sa_atime.nfsv2_sec != newnfs_xdrneg1) { in nfsrv_sattr()
2936 fxdr_nfsv2time(&sp->sa_atime, &nvap->na_atime); in nfsrv_sattr()
2938 nvap->na_atime.tv_sec = in nfsrv_sattr()
2939 fxdr_unsigned(u_int32_t,sp->sa_atime.nfsv2_sec); in nfsrv_sattr()
2940 nvap->na_atime.tv_nsec = 0; in nfsrv_sattr()
2943 if (sp->sa_mtime.nfsv2_sec != newnfs_xdrneg1) in nfsrv_sattr()
2944 fxdr_nfsv2time(&sp->sa_mtime, &nvap->na_mtime); in nfsrv_sattr()
2950 nvap->na_mode = nfstov_mode(*tl); in nfsrv_sattr()
2955 nvap->na_uid = fxdr_unsigned(uid_t, *tl); in nfsrv_sattr()
2960 nvap->na_gid = fxdr_unsigned(gid_t, *tl); in nfsrv_sattr()
2965 nvap->na_size = fxdr_hyper(tl); in nfsrv_sattr()
2971 fxdr_nfsv3time(tl, &nvap->na_atime); in nfsrv_sattr()
2975 vfs_timestamp(&nvap->na_atime); in nfsrv_sattr()
2976 nvap->na_vaflags |= VA_UTIMES_NULL; in nfsrv_sattr()
2983 fxdr_nfsv3time(tl, &nvap->na_mtime); in nfsrv_sattr()
2984 nvap->na_vaflags &= ~VA_UTIMES_NULL; in nfsrv_sattr()
2987 vfs_timestamp(&nvap->na_mtime); in nfsrv_sattr()
2989 nvap->na_vaflags |= VA_UTIMES_NULL; in nfsrv_sattr()
3033 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3048 if (!nd->nd_repstat) { in nfsv4_sattr()
3049 if (vp != NULL && vp->v_type != VREG) in nfsv4_sattr()
3050 nd->nd_repstat = (vp->v_type == VDIR) ? in nfsv4_sattr()
3053 nvap->na_size = fxdr_hyper(tl); in nfsv4_sattr()
3062 if (aceerr && !nd->nd_repstat) in nfsv4_sattr()
3063 nd->nd_repstat = aceerr; in nfsv4_sattr()
3068 if (!nd->nd_repstat) in nfsv4_sattr()
3069 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3074 if (!nd->nd_repstat) in nfsv4_sattr()
3075 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3081 error = nfsm_advance(nd, NFSM_RNDUP(i), -1); in nfsv4_sattr()
3084 if (!nd->nd_repstat) in nfsv4_sattr()
3085 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3091 if (!nd->nd_repstat) in nfsv4_sattr()
3092 nvap->na_mode = nfstov_mode(*tl); in nfsv4_sattr()
3112 if (!nd->nd_repstat) { in nfsv4_sattr()
3113 nd->nd_repstat = nfsv4_strtouid(nd, cp, j, in nfsv4_sattr()
3115 if (!nd->nd_repstat) in nfsv4_sattr()
3116 nvap->na_uid = uid; in nfsv4_sattr()
3139 if (!nd->nd_repstat) { in nfsv4_sattr()
3140 nd->nd_repstat = nfsv4_strtogid(nd, cp, j, in nfsv4_sattr()
3142 if (!nd->nd_repstat) in nfsv4_sattr()
3143 nvap->na_gid = gid; in nfsv4_sattr()
3151 if (!nd->nd_repstat) in nfsv4_sattr()
3152 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3160 if (!nd->nd_repstat) in nfsv4_sattr()
3161 fxdr_nfsv4time(tl, &nvap->na_atime); in nfsv4_sattr()
3164 } else if (!nd->nd_repstat) { in nfsv4_sattr()
3165 vfs_timestamp(&nvap->na_atime); in nfsv4_sattr()
3166 nvap->na_vaflags |= VA_UTIMES_NULL; in nfsv4_sattr()
3171 if (!nd->nd_repstat) in nfsv4_sattr()
3172 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3177 if (!nd->nd_repstat) in nfsv4_sattr()
3178 fxdr_nfsv4time(tl, &nvap->na_btime); in nfsv4_sattr()
3186 if (!nd->nd_repstat) in nfsv4_sattr()
3187 fxdr_nfsv4time(tl, &nvap->na_mtime); in nfsv4_sattr()
3188 nvap->na_vaflags &= ~VA_UTIMES_NULL; in nfsv4_sattr()
3190 } else if (!nd->nd_repstat) { in nfsv4_sattr()
3191 vfs_timestamp(&nvap->na_mtime); in nfsv4_sattr()
3193 nvap->na_vaflags |= VA_UTIMES_NULL; in nfsv4_sattr()
3205 * specified and this attribute cannot be done in the in nfsv4_sattr()
3208 if (!nd->nd_repstat) { in nfsv4_sattr()
3209 if ((nd->nd_flag & ND_NFSV41) == 0) in nfsv4_sattr()
3210 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3213 nd->nd_repstat = NFSERR_INVAL; in nfsv4_sattr()
3216 nd->nd_cred); in nfsv4_sattr()
3218 nvap->na_mode = (mode & mask) | in nfsv4_sattr()
3221 nd->nd_repstat = moderet; in nfsv4_sattr()
3230 * If moderet != 0, mode has already been done. in nfsv4_sattr()
3233 if (!nd->nd_repstat) { in nfsv4_sattr()
3234 if ((nd->nd_flag & ND_NFSV42) == 0) in nfsv4_sattr()
3235 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3238 nd->nd_repstat = NFSERR_INVAL; in nfsv4_sattr()
3240 nvap->na_mode = (mode & ~mask); in nfsv4_sattr()
3245 nd->nd_repstat = NFSERR_ATTRNOTSUPP; in nfsv4_sattr()
3256 * padding. This also skips over unparsed non-supported attributes. in nfsv4_sattr()
3263 error = nfsm_advance(nd, attrsize - attrsum, -1); in nfsv4_sattr()
3282 if (nd->nd_flag & ND_GSS) in nfsd_excred()
3283 exp->nes_exflag &= ~MNT_EXPORTANON; in nfsd_excred()
3298 if (NFSVNO_EXV4ONLY(exp) && !(nd->nd_flag & ND_NFSV4)) { in nfsd_excred()
3310 if (((nd->nd_flag & ND_GSS) == 0 && nd->nd_cred->cr_uid == 0) || in nfsd_excred()
3312 (nd->nd_flag & ND_AUTHNONE) != 0) { in nfsd_excred()
3313 nd->nd_cred->cr_uid = credanon->cr_uid; in nfsd_excred()
3319 crsetgroups(nd->nd_cred, credanon->cr_ngroups, in nfsd_excred()
3320 credanon->cr_groups); in nfsd_excred()
3321 } else if ((nd->nd_flag & ND_GSS) == 0) { in nfsd_excred()
3325 * list set up by "nfsuserd -manage-gids". in nfsd_excred()
3329 nd->nd_cred = nfsrv_getgrpscred(nd->nd_cred); in nfsd_excred()
3350 if (mp->mnt_exjail == NULL || in nfsvno_checkexp()
3351 mp->mnt_exjail->cr_prison != curthread->td_ucred->cr_prison) in nfsvno_checkexp()
3355 error = VFS_CHECKEXP(mp, nam, &exp->nes_exflag, credp, in nfsvno_checkexp()
3356 &exp->nes_numsecflavor, exp->nes_secflavors); in nfsvno_checkexp()
3359 exp->nes_exflag = 0; in nfsvno_checkexp()
3360 exp->nes_numsecflavor = 0; in nfsvno_checkexp()
3363 } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > in nfsvno_checkexp()
3366 exp->nes_numsecflavor = 0; in nfsvno_checkexp()
3384 exp->nes_numsecflavor = 0; in nfsvno_fhtovp()
3385 error = VFS_FHTOVP(mp, &fhp->fh_fid, lktype, vpp); in nfsvno_fhtovp()
3391 if (mp->mnt_exjail == NULL || in nfsvno_fhtovp()
3392 mp->mnt_exjail->cr_prison != curthread->td_ucred->cr_prison) in nfsvno_fhtovp()
3396 error = VFS_CHECKEXP(mp, nam, &exp->nes_exflag, credp, in nfsvno_fhtovp()
3397 &exp->nes_numsecflavor, exp->nes_secflavors); in nfsvno_fhtovp()
3400 exp->nes_exflag = 0; in nfsvno_fhtovp()
3401 exp->nes_numsecflavor = 0; in nfsvno_fhtovp()
3406 } else if (exp->nes_numsecflavor < 1 || exp->nes_numsecflavor > in nfsvno_fhtovp()
3409 exp->nes_numsecflavor = 0; in nfsvno_fhtovp()
3419 * nfsd_fhtovp() - convert a fh to a vnode ptr
3420 * - look up fsid in mount list (if not found ret error)
3421 * - get vp and export rights by calling nfsvno_fhtovp()
3422 * - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
3424 * - if mpp != NULL, return the mount point so that it can
3440 fhp = (fhandle_t *)nfp->nfsrvfh_data; in nfsd_fhtovp()
3441 mp = vfs_busyfs(&fhp->fh_fsid); in nfsd_fhtovp()
3443 nd->nd_repstat = ESTALE; in nfsd_fhtovp()
3453 nd->nd_repstat = ESTALE; in nfsd_fhtovp()
3461 nd->nd_repstat = nfsvno_fhtovp(mp, fhp, nd->nd_nam, lktype, vpp, exp, in nfsd_fhtovp()
3469 if (!nd->nd_repstat && exp->nes_exflag == 0 && in nfsd_fhtovp()
3470 !(nd->nd_flag & ND_NFSV4)) { in nfsd_fhtovp()
3473 nd->nd_repstat = EACCES; in nfsd_fhtovp()
3488 * that there be a way to turn that off--> ifdef'd. in nfsd_fhtovp()
3491 if (!nd->nd_repstat) { in nfsd_fhtovp()
3495 saddr = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in *); in nfsd_fhtovp()
3496 saddr6 = NFSSOCKADDR(nd->nd_nam, struct sockaddr_in6 *); in nfsd_fhtovp()
3497 if (!(nd->nd_flag & ND_NFSV4) && in nfsd_fhtovp()
3498 ((saddr->sin_family == AF_INET && in nfsd_fhtovp()
3499 ntohs(saddr->sin_port) >= IPPORT_RESERVED) || in nfsd_fhtovp()
3500 (saddr6->sin6_family == AF_INET6 && in nfsd_fhtovp()
3501 ntohs(saddr6->sin6_port) >= IPPORT_RESERVED))) { in nfsd_fhtovp()
3503 nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK); in nfsd_fhtovp()
3511 if (!nd->nd_repstat) { in nfsd_fhtovp()
3512 nd->nd_saveduid = nd->nd_cred->cr_uid; in nfsd_fhtovp()
3513 nd->nd_repstat = nfsd_excred(nd, exp, credanon, in nfsd_fhtovp()
3514 nfsrv_checkwrongsec(nd, nextop, (*vpp)->v_type)); in nfsd_fhtovp()
3515 if (nd->nd_repstat) in nfsd_fhtovp()
3520 if (nd->nd_repstat) { in nfsd_fhtovp()
3541 fdp = p->td_proc->p_fd; in fp_getfvp()
3542 if (fd < 0 || fd >= fdp->fd_nfiles || in fp_getfvp()
3543 (fp = fdp->fd_ofiles[fd].fde_file) == NULL) { in fp_getfvp()
3556 * vfs_export(). This has to be done, since the v4 root fake fs isn't
3567 error = vfs_export(NFSD_VNET(nfsv4root_mnt), &nfsexargp->export, false); in nfsrv_v4rootexport()
3568 if ((nfsexargp->export.ex_flags & MNT_DELEXPORT) != 0) in nfsrv_v4rootexport()
3571 if (nfsexargp->fspec == NULL) { in nfsrv_v4rootexport()
3578 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, nfsexargp->fspec); in nfsrv_v4rootexport()
3636 NFSD_VNET(nfsv4root_mnt)->mnt_flag = (MNT_RDONLY | MNT_EXPORTED); in nfsd_mntinit()
3637 mtx_init(&NFSD_VNET(nfsv4root_mnt)->mnt_mtx, "nfs4mnt", NULL, MTX_DEF); in nfsd_mntinit()
3638 lockinit(&NFSD_VNET(nfsv4root_mnt)->mnt_explock, PVFS, "explock", 0, 0); in nfsd_mntinit()
3639 TAILQ_INIT(&NFSD_VNET(nfsv4root_mnt)->mnt_nvnodelist); in nfsd_mntinit()
3640 TAILQ_INIT(&NFSD_VNET(nfsv4root_mnt)->mnt_lazyvnodelist); in nfsd_mntinit()
3641 NFSD_VNET(nfsv4root_mnt)->mnt_export = NULL; in nfsd_mntinit()
3644 NFSD_VNET(nfsv4root_mnt)->mnt_opt = &NFSD_VNET(nfsv4root_opt); in nfsd_mntinit()
3645 NFSD_VNET(nfsv4root_mnt)->mnt_optnew = &NFSD_VNET(nfsv4root_newopt); in nfsd_mntinit()
3646 NFSD_VNET(nfsv4root_mnt)->mnt_nvnodelistsize = 0; in nfsd_mntinit()
3647 NFSD_VNET(nfsv4root_mnt)->mnt_lazyvnodelistsize = 0; in nfsd_mntinit()
3677 mp = vfs_busyfs(&fhp->fh_fsid); in nfsvno_getvp()
3680 error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, &vp); in nfsvno_getvp()
3708 tlen = end - first; in nfsvno_advlock()
3725 error = VOP_ADVLOCK(vp, (caddr_t)td->td_proc, F_UNLCK, &fl, in nfsvno_advlock()
3728 error = VOP_ADVLOCK(vp, (caddr_t)td->td_proc, F_SETLK, &fl, in nfsvno_advlock()
3746 error = vfs_stdcheckexp(NFSD_VNET(nfsv4root_mnt), nd->nd_nam, &exflags, in nfsvno_v4rootexport()
3756 nd->nd_flag |= ND_EXAUTHSYS; in nfsvno_v4rootexport()
3758 nd->nd_flag |= ND_EXGSS; in nfsvno_v4rootexport()
3760 nd->nd_flag |= ND_EXGSSINTEGRITY; in nfsvno_v4rootexport()
3762 nd->nd_flag |= ND_EXGSSPRIVACY; in nfsvno_v4rootexport()
3767 nd->nd_flag |= ND_EXTLS; in nfsvno_v4rootexport()
3769 nd->nd_flag |= ND_EXTLSCERT; in nfsvno_v4rootexport()
3771 nd->nd_flag |= ND_EXTLSCERTUSER; in nfsvno_v4rootexport()
3802 if (uap->flag & NFSSVC_NFSDADDSOCK) { in nfssvc_nfsd()
3803 error = copyin(uap->argp, (caddr_t)&sockarg, sizeof (sockarg)); in nfssvc_nfsd()
3815 if (fp->f_type != DTYPE_SOCKET) { in nfssvc_nfsd()
3822 } else if (uap->flag & NFSSVC_NFSDNFSD) { in nfssvc_nfsd()
3823 if (uap->argp == NULL) { in nfssvc_nfsd()
3827 if ((uap->flag & NFSSVC_NEWSTRUCT) == 0) { in nfssvc_nfsd()
3828 error = copyin(uap->argp, &onfsdarg, sizeof(onfsdarg)); in nfssvc_nfsd()
3845 error = copyin(uap->argp, &nfsdarg, sizeof(nfsdarg)); in nfssvc_nfsd()
3916 } else if (uap->flag & NFSSVC_PNFSDS) { in nfssvc_nfsd()
3917 error = copyin(uap->argp, &pnfsdarg, sizeof(pnfsdarg)); in nfssvc_nfsd()
3957 if (pf->dsf_dir >= nfsrv_dsdirsize) { in nfssvc_nfsd()
3959 pf->dsf_dir = 0; in nfssvc_nfsd()
3963 ds->nfsdev_dsdir[pf->dsf_dir], ds, pf, in nfssvc_nfsd()
3965 buflen / sizeof(*pf), td->td_ucred, td); in nfssvc_nfsd()
3969 curdvp = fds->nfsdev_dsdir[pf->dsf_dir]; in nfssvc_nfsd()
3973 td->td_ucred, td); in nfssvc_nfsd()
3985 error = nfssvc_srvcall(td, uap, td->td_ucred); in nfssvc_nfsd()
4012 if (uap->flag & NFSSVC_PUBLICFH) { in nfssvc_srvcall()
4015 error = copyin(uap->argp, in nfssvc_srvcall()
4019 } else if ((uap->flag & (NFSSVC_V4ROOTEXPORT | NFSSVC_NEWSTRUCT)) == in nfssvc_srvcall()
4021 error = copyin(uap->argp,(caddr_t)&export, in nfssvc_srvcall()
4040 } else if ((uap->flag & (NFSSVC_V4ROOTEXPORT | NFSSVC_NEWSTRUCT)) == in nfssvc_srvcall()
4042 error = copyin(uap->argp,(caddr_t)&oexp, in nfssvc_srvcall()
4084 } else if (uap->flag & NFSSVC_NOPUBLICFH) { in nfssvc_srvcall()
4087 } else if (uap->flag & NFSSVC_STABLERESTART) { in nfssvc_srvcall()
4088 error = copyin(uap->argp, (caddr_t)&stablefd, in nfssvc_srvcall()
4100 } else if (uap->flag & NFSSVC_ADMINREVOKE) { in nfssvc_srvcall()
4101 error = copyin(uap->argp, (caddr_t)&adminrevoke, in nfssvc_srvcall()
4105 } else if (uap->flag & NFSSVC_DUMPCLIENTS) { in nfssvc_srvcall()
4106 error = copyin(uap->argp, (caddr_t)&dumplist, in nfssvc_srvcall()
4118 } else if (uap->flag & NFSSVC_DUMPLOCKS) { in nfssvc_srvcall()
4119 error = copyin(uap->argp, (caddr_t)&dumplocklist, in nfssvc_srvcall()
4138 } else if (uap->flag & NFSSVC_BACKUPSTABLE) { in nfssvc_srvcall()
4139 procp = p->td_proc; in nfssvc_srvcall()
4141 nfsd_master_pid = procp->p_pid; in nfssvc_srvcall()
4142 bcopy(procp->p_comm, nfsd_master_comm, MAXCOMLEN + 1); in nfssvc_srvcall()
4143 nfsd_master_start = procp->p_stats->p_start; in nfssvc_srvcall()
4146 } else if ((uap->flag & NFSSVC_SUSPENDNFSD) != 0) { in nfssvc_srvcall()
4160 } else if ((uap->flag & NFSSVC_RESUMENFSD) != 0) { in nfssvc_srvcall()
4183 if ((NFSVNO_EXTLS(exp) && (nd->nd_flag & ND_TLS) == 0) || in nfsvno_testexp()
4185 (nd->nd_flag & ND_TLSCERT) == 0) || in nfsvno_testexp()
4187 (nd->nd_flag & ND_TLSCERTUSER) == 0)) { in nfsvno_testexp()
4188 if ((nd->nd_flag & ND_NFSV4) != 0) in nfsvno_testexp()
4192 else if ((nd->nd_flag & ND_TLS) == 0) in nfsvno_testexp()
4205 if ((nd->nd_flag & ND_NFSV3) != 0 && nd->nd_procnum == NFSPROC_FSINFO) in nfsvno_testexp()
4210 * list is empty. This happens when NFSv4 is traversing non-exported in nfsvno_testexp()
4211 * file systems. Exported file systems should always have a non-empty in nfsvno_testexp()
4214 if (exp->nes_numsecflavor == 0) in nfsvno_testexp()
4217 for (i = 0; i < exp->nes_numsecflavor; i++) { in nfsvno_testexp()
4222 if (exp->nes_secflavors[i] == RPCSEC_GSS_KRB5P && in nfsvno_testexp()
4223 (nd->nd_flag & ND_GSSPRIVACY)) in nfsvno_testexp()
4225 if (exp->nes_secflavors[i] == RPCSEC_GSS_KRB5I && in nfsvno_testexp()
4226 (nd->nd_flag & ND_GSSINTEGRITY)) in nfsvno_testexp()
4228 if (exp->nes_secflavors[i] == RPCSEC_GSS_KRB5 && in nfsvno_testexp()
4229 (nd->nd_flag & ND_GSS)) in nfsvno_testexp()
4231 if (exp->nes_secflavors[i] == AUTH_SYS && in nfsvno_testexp()
4232 (nd->nd_flag & ND_GSS) == 0) in nfsvno_testexp()
4235 if ((nd->nd_flag & ND_NFSV4) != 0) in nfsvno_testexp()
4248 hashval = hash32_buf(&fhp->fh_fid, sizeof(struct fid), 0); in nfsrv_hashfh()
4276 procp->p_stats->p_start.tv_sec == in nfsrv_backupstable()
4278 procp->p_stats->p_start.tv_usec == in nfsrv_backupstable()
4280 strcmp(procp->p_comm, nfsd_master_comm) == 0) in nfsrv_backupstable()
4296 int done; member
4345 " setattr-uid=%d\n", error); in nfsrv_dscreate()
4355 nmp = VFSTONFS(nvp->v_mount); in nfsrv_dscreate()
4356 if (strcmp(nvp->v_mount->mnt_vfc->vfc_name, "nfs") in nfsrv_dscreate()
4357 != 0 || nmp->nm_nam->sa_len > sizeof( in nfsrv_dscreate()
4359 np->n_fhp->nfh_len != NFSX_MYFH) { in nfsrv_dscreate()
4362 nvp->v_mount->mnt_vfc->vfc_name, in nfsrv_dscreate()
4363 nmp->nm_nam->sa_len, np->n_fhp->nfh_len); in nfsrv_dscreate()
4372 dsa->dsa_filerev = va.va_filerev; in nfsrv_dscreate()
4373 dsa->dsa_size = va.va_size; in nfsrv_dscreate()
4374 dsa->dsa_atime = va.va_atime; in nfsrv_dscreate()
4375 dsa->dsa_mtime = va.va_mtime; in nfsrv_dscreate()
4376 dsa->dsa_bytes = va.va_bytes; in nfsrv_dscreate()
4380 NFSBCOPY(np->n_fhp->nfh_fh, &pf->dsf_fh, in nfsrv_dscreate()
4382 NFSBCOPY(nmp->nm_nam, &pf->dsf_sin, in nfsrv_dscreate()
4383 nmp->nm_nam->sa_len); in nfsrv_dscreate()
4385 pf->dsf_filename, in nfsrv_dscreate()
4386 sizeof(pf->dsf_filename)); in nfsrv_dscreate()
4409 dsc->err = nfsrv_dscreate(dsc->dvp, &dsc->createva, &dsc->va, &dsc->fh, in start_dscreate()
4410 dsc->pf, NULL, NULL, dsc->tcred, dsc->p, NULL); in start_dscreate()
4411 dsc->done = 1; in start_dscreate()
4412 NFSD_DEBUG(4, "start_dscreate: err=%d\n", dsc->err); in start_dscreate()
4438 /* Get a DS server directory in a round-robin order. */ in nfsrv_pnfscreate()
4440 mp = vp->v_mount; in nfsrv_pnfscreate()
4448 if (tds->nfsdev_nmp != NULL) { in nfsrv_pnfscreate()
4449 if (tds->nfsdev_mdsisset == 0 && ds == NULL) in nfsrv_pnfscreate()
4451 else if (tds->nfsdev_mdsisset != 0 && fsidcmp( in nfsrv_pnfscreate()
4452 &mp->mnt_stat.f_fsid, &tds->nfsdev_mdsfsid) == 0) { in nfsrv_pnfscreate()
4463 i = dsdir[0] = ds->nfsdev_nextdir; in nfsrv_pnfscreate()
4464 ds->nfsdev_nextdir = (ds->nfsdev_nextdir + 1) % nfsrv_dsdirsize; in nfsrv_pnfscreate()
4465 dvp[0] = ds->nfsdev_dsdir[i]; in nfsrv_pnfscreate()
4469 if (tds->nfsdev_nmp != NULL && in nfsrv_pnfscreate()
4470 ((tds->nfsdev_mdsisset == 0 && fds == NULL) || in nfsrv_pnfscreate()
4471 (tds->nfsdev_mdsisset != 0 && fds != NULL && in nfsrv_pnfscreate()
4472 fsidcmp(&mp->mnt_stat.f_fsid, in nfsrv_pnfscreate()
4473 &tds->nfsdev_mdsfsid) == 0))) { in nfsrv_pnfscreate()
4475 dvp[mirrorcnt] = tds->nfsdev_dsdir[i]; in nfsrv_pnfscreate()
4482 /* Put at end of list to implement round-robin usage. */ in nfsrv_pnfscreate()
4488 tdsc = dsc = malloc(sizeof(*dsc) * (mirrorcnt - 1), M_TEMP, in nfsrv_pnfscreate()
4509 NFSD_DEBUG(4, "nfsrv_pnfscreate: cruid=%d crgid=%d\n", cred->cr_uid, in nfsrv_pnfscreate()
4510 cred->cr_gid); in nfsrv_pnfscreate()
4518 failpos = -1; in nfsrv_pnfscreate()
4519 for (i = 0; i < mirrorcnt - 1 && error == 0; i++, tpf++, tdsc++) { in nfsrv_pnfscreate()
4520 tpf->dsf_dir = dsdir[i]; in nfsrv_pnfscreate()
4521 tdsc->tcred = tcred; in nfsrv_pnfscreate()
4522 tdsc->p = p; in nfsrv_pnfscreate()
4523 tdsc->pf = tpf; in nfsrv_pnfscreate()
4524 tdsc->createva = *vap; in nfsrv_pnfscreate()
4525 NFSBCOPY(&fh, &tdsc->fh, sizeof(fh)); in nfsrv_pnfscreate()
4526 tdsc->va = va; in nfsrv_pnfscreate()
4527 tdsc->dvp = dvp[i]; in nfsrv_pnfscreate()
4528 tdsc->done = 0; in nfsrv_pnfscreate()
4529 tdsc->inprog = 0; in nfsrv_pnfscreate()
4530 tdsc->err = 0; in nfsrv_pnfscreate()
4542 if (failpos == -1 && nfsds_failerr(ret)) in nfsrv_pnfscreate()
4550 tpf->dsf_dir = dsdir[mirrorcnt - 1]; in nfsrv_pnfscreate()
4551 error = nfsrv_dscreate(dvp[mirrorcnt - 1], vap, &va, &fh, tpf, in nfsrv_pnfscreate()
4553 if (failpos == -1 && mirrorcnt > 1 && nfsds_failerr(error)) { in nfsrv_pnfscreate()
4554 failpos = mirrorcnt - 1; in nfsrv_pnfscreate()
4562 for (tdsc = dsc, i = 0; i < mirrorcnt - 1; i++, tdsc++) { in nfsrv_pnfscreate()
4563 while (tdsc->inprog != 0 && tdsc->done == 0) in nfsrv_pnfscreate()
4564 tsleep(&tdsc->tsk, PVFS, "srvdcr", timo); in nfsrv_pnfscreate()
4565 if (tdsc->err != 0) { in nfsrv_pnfscreate()
4566 if (failpos == -1 && nfsds_failerr(tdsc->err)) in nfsrv_pnfscreate()
4569 error = tdsc->err; in nfsrv_pnfscreate()
4578 nmp = VFSTONFS(dvp[failpos]->v_mount); in nfsrv_pnfscreate()
4580 if ((nmp->nm_privflag & (NFSMNTP_FORCEDISM | in nfsrv_pnfscreate()
4582 nmp->nm_privflag |= NFSMNTP_CANCELRPCS; in nfsrv_pnfscreate()
4590 nmp->nm_privflag &= ~NFSMNTP_CANCELRPCS; in nfsrv_pnfscreate()
4609 tpf->dsf_sin.sin_family = AF_INET; in nfsrv_pnfscreate()
4610 tpf->dsf_sin.sin_len = sizeof(struct sockaddr_in); in nfsrv_pnfscreate()
4611 tpf->dsf_sin.sin_addr.s_addr = 0; in nfsrv_pnfscreate()
4612 tpf->dsf_sin.sin_port = 0; in nfsrv_pnfscreate()
4633 * Metadata file. Upon success, ddvp is set non-NULL to the locked
4634 * DS directory vnode. The caller must unlock *ddvp when done with it.
4647 if (vp->v_type != VREG || (vp->v_mount->mnt_flag & MNT_EXPORTED) == 0 || in nfsrv_pnfsremovesetup()
4684 int done; member
4738 dsrm->err = nfsrv_dsremove(dsrm->dvp, dsrm->fname, dsrm->tcred, in start_dsremove()
4739 dsrm->p); in start_dsremove()
4740 dsrm->done = 1; in start_dsremove()
4741 NFSD_DEBUG(4, "start_dsremove: err=%d\n", dsrm->err); in start_dsremove()
4762 dsrm = malloc(sizeof(*dsrm) * mirrorcnt - 1, M_TEMP, M_WAITOK); in nfsrv_pnfsremove()
4767 failpos = -1; in nfsrv_pnfsremove()
4768 for (tdsrm = dsrm, i = 0; i < mirrorcnt - 1; i++, tdsrm++) { in nfsrv_pnfsremove()
4769 tdsrm->tcred = tcred; in nfsrv_pnfsremove()
4770 tdsrm->p = p; in nfsrv_pnfsremove()
4771 tdsrm->dvp = dvp[i]; in nfsrv_pnfsremove()
4772 strlcpy(tdsrm->fname, fname, PNFS_FILENAME_LEN + 1); in nfsrv_pnfsremove()
4773 tdsrm->inprog = 0; in nfsrv_pnfsremove()
4774 tdsrm->done = 0; in nfsrv_pnfsremove()
4775 tdsrm->err = 0; in nfsrv_pnfsremove()
4783 if (failpos == -1 && nfsds_failerr(ret)) in nfsrv_pnfsremove()
4787 ret = nfsrv_dsremove(dvp[mirrorcnt - 1], fname, tcred, p); in nfsrv_pnfsremove()
4788 if (failpos == -1 && mirrorcnt > 1 && nfsds_failerr(ret)) in nfsrv_pnfsremove()
4789 failpos = mirrorcnt - 1; in nfsrv_pnfsremove()
4794 for (tdsrm = dsrm, i = 0; i < mirrorcnt - 1; i++, tdsrm++) { in nfsrv_pnfsremove()
4795 while (tdsrm->inprog != 0 && tdsrm->done == 0) in nfsrv_pnfsremove()
4796 tsleep(&tdsrm->tsk, PVFS, "srvdsrm", timo); in nfsrv_pnfsremove()
4797 if (failpos == -1 && nfsds_failerr(tdsrm->err)) in nfsrv_pnfsremove()
4806 nmp = VFSTONFS(dvp[failpos]->v_mount); in nfsrv_pnfsremove()
4808 if ((nmp->nm_privflag & (NFSMNTP_FORCEDISM | in nfsrv_pnfsremove()
4810 nmp->nm_privflag |= NFSMNTP_CANCELRPCS; in nfsrv_pnfsremove()
4818 nmp->nm_privflag &= ~NFSMNTP_CANCELRPCS; in nfsrv_pnfsremove()
4905 if (vp->v_type != VREG || (vp->v_mount->mnt_flag & MNT_EXPORTED) == 0 || in nfsrv_proxyds()
4924 nap->na_filerev = odsattr.dsa_filerev; in nfsrv_proxyds()
4925 nap->na_size = odsattr.dsa_size; in nfsrv_proxyds()
4926 nap->na_atime = odsattr.dsa_atime; in nfsrv_proxyds()
4927 nap->na_mtime = odsattr.dsa_mtime; in nfsrv_proxyds()
4933 nap->na_bytes = (odsattr.dsa_size + in nfsrv_proxyds()
4934 BLKDEV_IOSIZE - 1) & ~(BLKDEV_IOSIZE - 1); in nfsrv_proxyds()
4937 nap->na_filerev = dsattr.dsa_filerev; in nfsrv_proxyds()
4938 nap->na_size = dsattr.dsa_size; in nfsrv_proxyds()
4939 nap->na_atime = dsattr.dsa_atime; in nfsrv_proxyds()
4940 nap->na_mtime = dsattr.dsa_mtime; in nfsrv_proxyds()
4941 nap->na_bytes = dsattr.dsa_bytes; in nfsrv_proxyds()
4969 origmircnt = -1; in nfsrv_proxyds()
4982 nmp[i] = VFSTONFS(dvp[i]->v_mount); in nfsrv_proxyds()
4988 failpos = -1; in nfsrv_proxyds()
4989 if (origmircnt == -1) in nfsrv_proxyds()
5046 error = nfsrv_getattrdsrpc(&fh[mirrorcnt - 1], cred, p, in nfsrv_proxyds()
5047 vp, nmp[mirrorcnt - 1], nap); in nfsrv_proxyds()
5054 failpos = mirrorcnt - 1; in nfsrv_proxyds()
5063 if ((failnmp->nm_privflag & (NFSMNTP_FORCEDISM | in nfsrv_proxyds()
5065 failnmp->nm_privflag |= NFSMNTP_CANCELRPCS; in nfsrv_proxyds()
5074 failnmp->nm_privflag &= ~NFSMNTP_CANCELRPCS; in nfsrv_proxyds()
5098 * newnmpp - If it points to a non-NULL nmp, that is the destination and needs
5101 * curnmp - If non-NULL, it is the source mount for the copy.
5127 *ippos = -1; in nfsrv_dsgetsockmnt()
5132 mp = vp->v_mount; in nfsrv_dsgetsockmnt()
5145 sad = (struct sockaddr *)&pf->dsf_sin; in nfsrv_dsgetsockmnt()
5146 if (nfsaddr2_match(sad, curnmp->nm_nam)) { in nfsrv_dsgetsockmnt()
5163 sad = (struct sockaddr *)&pf->dsf_sin; in nfsrv_dsgetsockmnt()
5164 sin = &pf->dsf_sin; in nfsrv_dsgetsockmnt()
5165 dsdir = pf->dsf_dir; in nfsrv_dsgetsockmnt()
5170 nfsaddr2_match(sad, newnmp->nm_nam)) in nfsrv_dsgetsockmnt()
5174 sad->sa_family == AF_INET && in nfsrv_dsgetsockmnt()
5175 sin->sin_addr.s_addr == 0) in nfsrv_dsgetsockmnt()
5177 if (NFSBCMP(&zerofh, &pf->dsf_fh, sizeof(zerofh)) == 0) in nfsrv_dsgetsockmnt()
5184 if (ds->nfsdev_nmp != NULL) { in nfsrv_dsgetsockmnt()
5185 dvp = ds->nfsdev_dvp; in nfsrv_dsgetsockmnt()
5186 nmp = VFSTONFS(dvp->v_mount); in nfsrv_dsgetsockmnt()
5187 if (nmp != ds->nfsdev_nmp) in nfsrv_dsgetsockmnt()
5189 nmp, ds->nfsdev_nmp); in nfsrv_dsgetsockmnt()
5190 if (nfsaddr2_match(sad, nmp->nm_nam)) { in nfsrv_dsgetsockmnt()
5201 if (tds->nfsdev_nmp != NULL && in nfsrv_dsgetsockmnt()
5203 ((tds->nfsdev_mdsisset == 0 && in nfsrv_dsgetsockmnt()
5204 fndds->nfsdev_mdsisset == 0) || in nfsrv_dsgetsockmnt()
5205 (tds->nfsdev_mdsisset != 0 && in nfsrv_dsgetsockmnt()
5206 fndds->nfsdev_mdsisset != 0 && in nfsrv_dsgetsockmnt()
5207 fsidcmp(&tds->nfsdev_mdsfsid, in nfsrv_dsgetsockmnt()
5208 &mp->mnt_stat.f_fsid) == 0))) { in nfsrv_dsgetsockmnt()
5209 *newnmpp = tds->nfsdev_nmp; in nfsrv_dsgetsockmnt()
5227 dvp = fndds->nfsdev_dsdir[dsdir]; in nfsrv_dsgetsockmnt()
5270 NFSBCOPY(fndds->nfsdev_deviceid, in nfsrv_dsgetsockmnt()
5277 NFSBCOPY(&pf->dsf_fh, fhp++, in nfsrv_dsgetsockmnt()
5281 pf->dsf_filename, in nfsrv_dsgetsockmnt()
5282 sizeof(pf->dsf_filename)); in nfsrv_dsgetsockmnt()
5330 dsattr.dsa_filerev = nap->na_filerev; in nfsrv_setextattr()
5331 dsattr.dsa_size = nap->na_size; in nfsrv_setextattr()
5332 dsattr.dsa_atime = nap->na_atime; in nfsrv_setextattr()
5333 dsattr.dsa_mtime = nap->na_mtime; in nfsrv_setextattr()
5334 dsattr.dsa_bytes = nap->na_bytes; in nfsrv_setextattr()
5359 * MDS->DS proxy operation. in nfsrv_readdsrpc()
5371 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, in nfsrv_readdsrpc()
5377 if (nd->nd_repstat == 0) { in nfsrv_readdsrpc()
5381 /* Trim off the pre-data XDR from the mbuf chain. */ in nfsrv_readdsrpc()
5382 m = nd->nd_mrep; in nfsrv_readdsrpc()
5383 while (m != NULL && m != nd->nd_md) { in nfsrv_readdsrpc()
5384 if (m->m_next == nd->nd_md) { in nfsrv_readdsrpc()
5385 m->m_next = NULL; in nfsrv_readdsrpc()
5386 m_freem(nd->nd_mrep); in nfsrv_readdsrpc()
5387 nd->nd_mrep = m = nd->nd_md; in nfsrv_readdsrpc()
5389 m = m->m_next; in nfsrv_readdsrpc()
5401 trimlen = nd->nd_dpos - mtod(m, char *); in nfsrv_readdsrpc()
5403 m->m_len -= trimlen; in nfsrv_readdsrpc()
5414 if (m->m_len >= tlen) { in nfsrv_readdsrpc()
5415 m->m_len = tlen; in nfsrv_readdsrpc()
5417 m2 = m->m_next; in nfsrv_readdsrpc()
5418 m->m_next = NULL; in nfsrv_readdsrpc()
5422 tlen -= m->m_len; in nfsrv_readdsrpc()
5423 m = m->m_next; in nfsrv_readdsrpc()
5430 *mpp = nd->nd_mrep; in nfsrv_readdsrpc()
5432 nd->nd_mrep = NULL; in nfsrv_readdsrpc()
5435 error = nd->nd_repstat; in nfsrv_readdsrpc()
5437 /* If nd->nd_mrep is already NULL, this is a no-op. */ in nfsrv_readdsrpc()
5438 m_freem(nd->nd_mrep); in nfsrv_readdsrpc()
5449 int done; member
5480 * MDS->DS proxy operation. in nfsrv_writedsdorpc()
5501 nd->nd_mb->m_next = m; in nfsrv_writedsdorpc()
5504 while (m->m_next != NULL) in nfsrv_writedsdorpc()
5505 m = m->m_next; in nfsrv_writedsdorpc()
5506 nd->nd_mb = m; in nfsrv_writedsdorpc()
5507 nfsm_set(nd, m->m_len); in nfsrv_writedsdorpc()
5508 NFSD_DEBUG(4, "nfsrv_writedsdorpc: lastmb len=%d\n", m->m_len); in nfsrv_writedsdorpc()
5520 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, in nfsrv_writedsdorpc()
5526 NFSD_DEBUG(4, "nfsrv_writedsdorpc: aft writerpc=%d\n", nd->nd_repstat); in nfsrv_writedsdorpc()
5528 if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) == in nfsrv_writedsdorpc()
5540 nd->nd_flag |= ND_NOMOREDATA; in nfsrv_writedsdorpc()
5542 if (nd->nd_repstat == 0) { in nfsrv_writedsdorpc()
5551 error = nd->nd_repstat; in nfsrv_writedsdorpc()
5566 m_freem(nd->nd_mrep); in nfsrv_writedsdorpc()
5581 drpc->err = nfsrv_writedsdorpc(drpc->nmp, &drpc->fh, drpc->off, in start_writedsdorpc()
5582 drpc->len, NULL, drpc->m, drpc->cred, drpc->p); in start_writedsdorpc()
5583 drpc->done = 1; in start_writedsdorpc()
5584 NFSD_DEBUG(4, "start_writedsdorpc: err=%d\n", drpc->err); in start_writedsdorpc()
5601 tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, in nfsrv_writedsrpc()
5605 offs = cp - mtod(*mpp, char *); in nfsrv_writedsrpc()
5613 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_writedsrpc()
5614 tdrpc->done = 0; in nfsrv_writedsrpc()
5615 NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); in nfsrv_writedsrpc()
5616 tdrpc->off = off; in nfsrv_writedsrpc()
5617 tdrpc->len = len; in nfsrv_writedsrpc()
5618 tdrpc->nmp = *nmpp; in nfsrv_writedsrpc()
5619 tdrpc->cred = cred; in nfsrv_writedsrpc()
5620 tdrpc->p = p; in nfsrv_writedsrpc()
5621 tdrpc->inprog = 0; in nfsrv_writedsrpc()
5622 tdrpc->err = 0; in nfsrv_writedsrpc()
5623 tdrpc->m = m_copym(*mpp, offs, NFSM_RNDUP(len), M_WAITOK); in nfsrv_writedsrpc()
5632 tdrpc->m, cred, p); in nfsrv_writedsrpc()
5633 if (nfsds_failerr(ret) && *failposp == -1) in nfsrv_writedsrpc()
5643 if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) in nfsrv_writedsrpc()
5644 *failposp = mirrorcnt - 1; in nfsrv_writedsrpc()
5654 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_writedsrpc()
5656 while (tdrpc->inprog != 0 && tdrpc->done == 0) in nfsrv_writedsrpc()
5657 tsleep(&tdrpc->tsk, PVFS, "srvwrds", timo); in nfsrv_writedsrpc()
5658 if (nfsds_failerr(tdrpc->err) && *failposp == -1) in nfsrv_writedsrpc()
5660 else if (error == 0 && tdrpc->err != 0) in nfsrv_writedsrpc()
5661 error = tdrpc->err; in nfsrv_writedsrpc()
5672 int done; member
5702 * MDS->DS proxy operation. in nfsrv_allocatedsdorpc()
5717 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, in nfsrv_allocatedsdorpc()
5724 nd->nd_repstat); in nfsrv_allocatedsdorpc()
5725 if (nd->nd_repstat == 0) { in nfsrv_allocatedsdorpc()
5730 error = nd->nd_repstat; in nfsrv_allocatedsdorpc()
5733 m_freem(nd->nd_mrep); in nfsrv_allocatedsdorpc()
5748 drpc->err = nfsrv_allocatedsdorpc(drpc->nmp, &drpc->fh, drpc->off, in start_allocatedsdorpc()
5749 drpc->len, NULL, drpc->cred, drpc->p); in start_allocatedsdorpc()
5750 drpc->done = 1; in start_allocatedsdorpc()
5751 NFSD_DEBUG(4, "start_allocatedsdorpc: err=%d\n", drpc->err); in start_allocatedsdorpc()
5766 tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, in nfsrv_allocatedsrpc()
5774 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_allocatedsrpc()
5775 tdrpc->done = 0; in nfsrv_allocatedsrpc()
5776 NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); in nfsrv_allocatedsrpc()
5777 tdrpc->off = off; in nfsrv_allocatedsrpc()
5778 tdrpc->len = len; in nfsrv_allocatedsrpc()
5779 tdrpc->nmp = *nmpp; in nfsrv_allocatedsrpc()
5780 tdrpc->cred = cred; in nfsrv_allocatedsrpc()
5781 tdrpc->p = p; in nfsrv_allocatedsrpc()
5782 tdrpc->inprog = 0; in nfsrv_allocatedsrpc()
5783 tdrpc->err = 0; in nfsrv_allocatedsrpc()
5793 if (nfsds_failerr(ret) && *failposp == -1) in nfsrv_allocatedsrpc()
5802 if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) in nfsrv_allocatedsrpc()
5803 *failposp = mirrorcnt - 1; in nfsrv_allocatedsrpc()
5813 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_allocatedsrpc()
5815 while (tdrpc->inprog != 0 && tdrpc->done == 0) in nfsrv_allocatedsrpc()
5816 tsleep(&tdrpc->tsk, PVFS, "srvalds", timo); in nfsrv_allocatedsrpc()
5817 if (nfsds_failerr(tdrpc->err) && *failposp == -1) in nfsrv_allocatedsrpc()
5819 else if (error == 0 && tdrpc->err != 0) in nfsrv_allocatedsrpc()
5820 error = tdrpc->err; in nfsrv_allocatedsrpc()
5832 int done; member
5862 * MDS->DS proxy operation. in nfsrv_deallocatedsdorpc()
5883 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, in nfsrv_deallocatedsdorpc()
5890 nd->nd_repstat); in nfsrv_deallocatedsdorpc()
5892 if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) == in nfsrv_deallocatedsdorpc()
5904 nd->nd_flag |= ND_NOMOREDATA; in nfsrv_deallocatedsdorpc()
5906 if (nd->nd_repstat == 0) { in nfsrv_deallocatedsdorpc()
5911 error = nd->nd_repstat; in nfsrv_deallocatedsdorpc()
5914 m_freem(nd->nd_mrep); in nfsrv_deallocatedsdorpc()
5929 drpc->err = nfsrv_deallocatedsdorpc(drpc->nmp, &drpc->fh, drpc->off, in start_deallocatedsdorpc()
5930 drpc->len, NULL, drpc->cred, drpc->p); in start_deallocatedsdorpc()
5931 drpc->done = 1; in start_deallocatedsdorpc()
5932 NFSD_DEBUG(4, "start_deallocatedsdorpc: err=%d\n", drpc->err); in start_deallocatedsdorpc()
5947 tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, in nfsrv_deallocatedsrpc()
5955 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_deallocatedsrpc()
5956 tdrpc->done = 0; in nfsrv_deallocatedsrpc()
5957 NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); in nfsrv_deallocatedsrpc()
5958 tdrpc->off = off; in nfsrv_deallocatedsrpc()
5959 tdrpc->len = len; in nfsrv_deallocatedsrpc()
5960 tdrpc->nmp = *nmpp; in nfsrv_deallocatedsrpc()
5961 tdrpc->cred = cred; in nfsrv_deallocatedsrpc()
5962 tdrpc->p = p; in nfsrv_deallocatedsrpc()
5963 tdrpc->inprog = 0; in nfsrv_deallocatedsrpc()
5964 tdrpc->err = 0; in nfsrv_deallocatedsrpc()
5974 if (nfsds_failerr(ret) && *failposp == -1) in nfsrv_deallocatedsrpc()
5983 if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) in nfsrv_deallocatedsrpc()
5984 *failposp = mirrorcnt - 1; in nfsrv_deallocatedsrpc()
5994 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_deallocatedsrpc()
5996 while (tdrpc->inprog != 0 && tdrpc->done == 0) in nfsrv_deallocatedsrpc()
5997 tsleep(&tdrpc->tsk, PVFS, "srvalds", timo); in nfsrv_deallocatedsrpc()
5998 if (nfsds_failerr(tdrpc->err) && *failposp == -1) in nfsrv_deallocatedsrpc()
6000 else if (error == 0 && tdrpc->err != 0) in nfsrv_deallocatedsrpc()
6001 error = tdrpc->err; in nfsrv_deallocatedsrpc()
6024 * MDS->DS proxy operation. in nfsrv_setattrdsdorpc()
6033 nfscl_fillsattr(nd, &nap->na_vattr, vp, NFSSATTR_FULL, 0); in nfsrv_setattrdsdorpc()
6045 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, in nfsrv_setattrdsdorpc()
6052 nd->nd_repstat); in nfsrv_setattrdsdorpc()
6054 if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) == in nfsrv_setattrdsdorpc()
6066 nd->nd_flag |= ND_NOMOREDATA; in nfsrv_setattrdsdorpc()
6071 if (nd->nd_repstat != 0) in nfsrv_setattrdsdorpc()
6072 error = nd->nd_repstat; in nfsrv_setattrdsdorpc()
6085 m_freem(nd->nd_mrep); in nfsrv_setattrdsdorpc()
6092 int done; member
6114 drpc->err = nfsrv_setattrdsdorpc(&drpc->fh, drpc->cred, drpc->p, in start_setattrdsdorpc()
6115 drpc->vp, drpc->nmp, &drpc->na, &drpc->dsna); in start_setattrdsdorpc()
6116 drpc->done = 1; in start_setattrdsdorpc()
6131 tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, in nfsrv_setattrdsrpc()
6139 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_setattrdsrpc()
6140 tdrpc->done = 0; in nfsrv_setattrdsrpc()
6141 tdrpc->inprog = 0; in nfsrv_setattrdsrpc()
6142 NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); in nfsrv_setattrdsrpc()
6143 tdrpc->nmp = *nmpp; in nfsrv_setattrdsrpc()
6144 tdrpc->vp = vp; in nfsrv_setattrdsrpc()
6145 tdrpc->cred = cred; in nfsrv_setattrdsrpc()
6146 tdrpc->p = p; in nfsrv_setattrdsrpc()
6147 tdrpc->na = *nap; in nfsrv_setattrdsrpc()
6148 tdrpc->err = 0; in nfsrv_setattrdsrpc()
6158 if (nfsds_failerr(ret) && *failposp == -1) in nfsrv_setattrdsrpc()
6167 if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) in nfsrv_setattrdsrpc()
6168 *failposp = mirrorcnt - 1; in nfsrv_setattrdsrpc()
6178 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_setattrdsrpc()
6180 while (tdrpc->inprog != 0 && tdrpc->done == 0) in nfsrv_setattrdsrpc()
6181 tsleep(&tdrpc->tsk, PVFS, "srvsads", timo); in nfsrv_setattrdsrpc()
6182 if (nfsds_failerr(tdrpc->err) && *failposp == -1) in nfsrv_setattrdsrpc()
6184 else if (error == 0 && tdrpc->err != 0) in nfsrv_setattrdsrpc()
6185 error = tdrpc->err; in nfsrv_setattrdsrpc()
6209 * MDS->DS proxy operation. in nfsrv_setacldsdorpc()
6227 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, in nfsrv_setacldsdorpc()
6234 nd->nd_repstat); in nfsrv_setacldsdorpc()
6235 error = nd->nd_repstat; in nfsrv_setacldsdorpc()
6236 m_freem(nd->nd_mrep); in nfsrv_setacldsdorpc()
6242 int done; member
6263 drpc->err = nfsrv_setacldsdorpc(&drpc->fh, drpc->cred, drpc->p, in start_setacldsdorpc()
6264 drpc->vp, drpc->nmp, drpc->aclp); in start_setacldsdorpc()
6265 drpc->done = 1; in start_setacldsdorpc()
6279 tdrpc = drpc = malloc(sizeof(*drpc) * (mirrorcnt - 1), M_TEMP, in nfsrv_setacldsrpc()
6287 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_setacldsrpc()
6288 tdrpc->done = 0; in nfsrv_setacldsrpc()
6289 tdrpc->inprog = 0; in nfsrv_setacldsrpc()
6290 NFSBCOPY(fhp, &tdrpc->fh, sizeof(*fhp)); in nfsrv_setacldsrpc()
6291 tdrpc->nmp = *nmpp; in nfsrv_setacldsrpc()
6292 tdrpc->vp = vp; in nfsrv_setacldsrpc()
6293 tdrpc->cred = cred; in nfsrv_setacldsrpc()
6294 tdrpc->p = p; in nfsrv_setacldsrpc()
6295 tdrpc->aclp = aclp; in nfsrv_setacldsrpc()
6296 tdrpc->err = 0; in nfsrv_setacldsrpc()
6306 if (nfsds_failerr(ret) && *failposp == -1) in nfsrv_setacldsrpc()
6315 if (nfsds_failerr(ret) && *failposp == -1 && mirrorcnt > 1) in nfsrv_setacldsrpc()
6316 *failposp = mirrorcnt - 1; in nfsrv_setacldsrpc()
6324 for (i = 0; i < mirrorcnt - 1; i++, tdrpc++) { in nfsrv_setacldsrpc()
6326 while (tdrpc->inprog != 0 && tdrpc->done == 0) in nfsrv_setacldsrpc()
6327 tsleep(&tdrpc->tsk, PVFS, "srvacds", timo); in nfsrv_setacldsrpc()
6328 if (nfsds_failerr(tdrpc->err) && *failposp == -1) in nfsrv_setacldsrpc()
6330 else if (error == 0 && tdrpc->err != 0) in nfsrv_setacldsrpc()
6331 error = tdrpc->err; in nfsrv_setacldsrpc()
6359 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, in nfsrv_getattrdsrpc()
6366 nd->nd_repstat); in nfsrv_getattrdsrpc()
6367 if (nd->nd_repstat == 0) { in nfsrv_getattrdsrpc()
6387 error = nd->nd_repstat; in nfsrv_getattrdsrpc()
6388 m_freem(nd->nd_mrep); in nfsrv_getattrdsrpc()
6411 * MDS->DS proxy operation. in nfsrv_seekdsrpc()
6424 error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred, in nfsrv_seekdsrpc()
6430 NFSD_DEBUG(4, "nfsrv_seekdsrpc: aft seekrpc=%d\n", nd->nd_repstat); in nfsrv_seekdsrpc()
6431 if (nd->nd_repstat == 0) { in nfsrv_seekdsrpc()
6439 error = nd->nd_repstat; in nfsrv_seekdsrpc()
6441 m_freem(nd->nd_mrep); in nfsrv_seekdsrpc()
6486 named.ni_cnd.cn_namelen = strlen(pf->dsf_filename); in nfsrv_pnfslookupds()
6487 strlcpy(bufp, pf->dsf_filename, NAME_MAX); in nfsrv_pnfslookupds()
6510 NFSBCOPY(np->n_fhp->nfh_fh, &pf->dsf_fh, NFSX_MYFH); in nfsrv_pnfssetfh()
6513 * locked and vn_start_write() has been done. If devid != NULL or in nfsrv_pnfssetfh()
6515 * may not have been done. in nfsrv_pnfssetfh()
6516 * If not done now, it will be done on a future call. in nfsrv_pnfssetfh()
6540 * on the mounted-on vnode (such as "df" or in nfsrv_killrpcs()
6541 * a non-forced "umount") to fail. in nfsrv_killrpcs()
6542 * This will unlock the mounted-on vnode so in nfsrv_killrpcs()
6574 if (ds->nfsdev_nmp != NULL && ds->nfsdev_mdsisset != 0 && in nfsrv_pnfsstatfs()
6575 fsidcmp(&ds->nfsdev_mdsfsid, &mp->mnt_stat.f_fsid) == 0) { in nfsrv_pnfsstatfs()
6578 *tdvpp++ = ds->nfsdev_dvp; in nfsrv_pnfsstatfs()
6587 if (ds->nfsdev_nmp != NULL && in nfsrv_pnfsstatfs()
6588 ds->nfsdev_mdsisset == 0) { in nfsrv_pnfsstatfs()
6591 *tdvpp++ = ds->nfsdev_dvp; in nfsrv_pnfsstatfs()
6602 error = VFS_STATFS(dvp->v_mount, tsf); in nfsrv_pnfsstatfs()
6604 if (sf->f_bsize == 0) { in nfsrv_pnfsstatfs()
6605 if (tsf->f_bsize > 0) in nfsrv_pnfsstatfs()
6606 sf->f_bsize = tsf->f_bsize; in nfsrv_pnfsstatfs()
6608 sf->f_bsize = 8192; in nfsrv_pnfsstatfs()
6610 if (tsf->f_blocks > 0) { in nfsrv_pnfsstatfs()
6611 if (sf->f_bsize != tsf->f_bsize) { in nfsrv_pnfsstatfs()
6612 tot = tsf->f_blocks * tsf->f_bsize; in nfsrv_pnfsstatfs()
6613 sf->f_blocks += (tot / sf->f_bsize); in nfsrv_pnfsstatfs()
6615 sf->f_blocks += tsf->f_blocks; in nfsrv_pnfsstatfs()
6617 if (tsf->f_bfree > 0) { in nfsrv_pnfsstatfs()
6618 if (sf->f_bsize != tsf->f_bsize) { in nfsrv_pnfsstatfs()
6619 tot = tsf->f_bfree * tsf->f_bsize; in nfsrv_pnfsstatfs()
6620 sf->f_bfree += (tot / sf->f_bsize); in nfsrv_pnfsstatfs()
6622 sf->f_bfree += tsf->f_bfree; in nfsrv_pnfsstatfs()
6624 if (tsf->f_bavail > 0) { in nfsrv_pnfsstatfs()
6625 if (sf->f_bsize != tsf->f_bsize) { in nfsrv_pnfsstatfs()
6626 tot = tsf->f_bavail * tsf->f_bsize; in nfsrv_pnfsstatfs()
6627 sf->f_bavail += (tot / sf->f_bsize); in nfsrv_pnfsstatfs()
6629 sf->f_bavail += tsf->f_bavail; in nfsrv_pnfsstatfs()
6652 * Make sure it has enough room for that - splitting every entry in nfsrv_setacl()
6654 * Cribbed out of kern/vfs_acl.c - Rick M. in nfsrv_setacl()
6656 if (aclp->acl_cnt > (ACL_MAX_ENTRIES - 6) / 2) { in nfsrv_setacl()
6810 if (siz > maxresp - NFS_MAXXDR) in nfsvno_getxattr()
6825 uiop->uio_iovcnt = nfsrv_createiovec_extpgs(tlen, in nfsvno_getxattr()
6828 uiop->uio_iovcnt = nfsrv_createiovec(tlen, &m, &m2, in nfsvno_getxattr()
6830 uiop->uio_iov = iv; in nfsvno_getxattr()
6832 uiop->uio_iovcnt = 0; in nfsvno_getxattr()
6833 uiop->uio_iov = iv = NULL; in nfsvno_getxattr()
6836 uiop->uio_offset = 0; in nfsvno_getxattr()
6837 uiop->uio_resid = tlen; in nfsvno_getxattr()
6838 uiop->uio_rw = UIO_READ; in nfsvno_getxattr()
6839 uiop->uio_segflg = UIO_SYSSPACE; in nfsvno_getxattr()
6840 uiop->uio_td = p; in nfsvno_getxattr()
6853 if (uiop->uio_resid > 0) { in nfsvno_getxattr()
6855 len = tlen - uiop->uio_resid; in nfsvno_getxattr()
6863 m2 = nfsrv_adj(m, alen - tlen, tlen - len); in nfsvno_getxattr()
6899 uiop->uio_rw = UIO_WRITE; in nfsvno_setxattr()
6900 uiop->uio_segflg = UIO_SYSSPACE; in nfsvno_setxattr()
6901 uiop->uio_td = p; in nfsvno_setxattr()
6902 uiop->uio_offset = 0; in nfsvno_setxattr()
6903 uiop->uio_resid = len; in nfsvno_setxattr()
6906 uiop->uio_iov = iv; in nfsvno_setxattr()
6907 uiop->uio_iovcnt = cnt; in nfsvno_setxattr()
6909 uiop->uio_iov = iv = NULL; in nfsvno_setxattr()
6910 uiop->uio_iovcnt = 0; in nfsvno_setxattr()
6916 if (vp->v_type == VREG && nfsrv_devidcnt != 0) in nfsvno_setxattr()
6934 * It does result in two MDS->DS RPCs, but creating
6936 * Setxattr/Rmxattr will not be done that frequently.
6977 * but RFC-8276 says so. in nfsvno_rmxattr()
6979 error = nfsrv_checkremove(vp, 0, nd, nd->nd_clientid, p); in nfsvno_rmxattr()
6994 if (vp->v_type == VREG && nfsrv_devidcnt != 0) in nfsvno_rmxattr()
7057 siz -= io.uio_resid; in nfsvno_listxattr()
7079 if (mb->m_next != NULL) { in nfsm_trimtrailing()
7080 m_freem(mb->m_next); in nfsm_trimtrailing()
7081 mb->m_next = NULL; in nfsm_trimtrailing()
7083 if ((mb->m_flags & M_EXTPG) != 0) { in nfsm_trimtrailing()
7084 KASSERT(bextpg >= 0 && bextpg < mb->m_epg_npgs, in nfsm_trimtrailing()
7087 PHYS_TO_DMAP(mb->m_epg_pa[bextpg]) + PAGE_SIZE - bextpgsiz, in nfsm_trimtrailing()
7091 for (i = mb->m_epg_npgs - 1; i > bextpg; i--) { in nfsm_trimtrailing()
7092 pg = PHYS_TO_VM_PAGE(mb->m_epg_pa[i]); in nfsm_trimtrailing()
7096 mb->m_epg_npgs = bextpg + 1; in nfsm_trimtrailing()
7098 fullpgsiz = PAGE_SIZE - mb->m_epg_1st_off; in nfsm_trimtrailing()
7101 mb->m_epg_last_len = fullpgsiz - bextpgsiz; in nfsm_trimtrailing()
7102 mb->m_len = m_epg_pagelen(mb, 0, mb->m_epg_1st_off); in nfsm_trimtrailing()
7103 for (i = 1; i < mb->m_epg_npgs; i++) in nfsm_trimtrailing()
7104 mb->m_len += m_epg_pagelen(mb, i, 0); in nfsm_trimtrailing()
7105 nd->nd_bextpgsiz = bextpgsiz; in nfsm_trimtrailing()
7106 nd->nd_bextpg = bextpg; in nfsm_trimtrailing()
7108 mb->m_len = bpos - mtod(mb, char *); in nfsm_trimtrailing()
7109 nd->nd_mb = mb; in nfsm_trimtrailing()
7110 nd->nd_bpos = bpos; in nfsm_trimtrailing()
7125 if ((nd->nd_flag & ND_NFSV4) == 0) in nfsrv_checkwrongsec()
7128 if ((nd->nd_flag & ND_LASTOP) != 0) in nfsrv_checkwrongsec()
7166 if (ds->nfsdev_nmp != NULL && ds->nfsdev_nospc) { in nfsrv_checknospc()
7169 *tdvpp++ = ds->nfsdev_dvp; in nfsrv_checknospc()
7170 NFSBCOPY(ds->nfsdev_deviceid, tdevid, NFSX_V4DEVICEID); in nfsrv_checknospc()
7182 error = VFS_STATFS(dvp->v_mount, tsf); in nfsrv_checknospc()
7183 if (error == 0 && tsf->f_bavail > 0) { in nfsrv_checknospc()
7208 * done when the jail is destroyed or the module unloaded.
7230 if (NFSD_VNET(nfsv4root_mnt)->mnt_export != NULL) { in nfsrv_cleanup()
7231 vfs_free_addrlist(NFSD_VNET(nfsv4root_mnt)->mnt_export); in nfsrv_cleanup()
7232 free(NFSD_VNET(nfsv4root_mnt)->mnt_export, M_MOUNT); in nfsrv_cleanup()
7233 NFSD_VNET(nfsv4root_mnt)->mnt_export = NULL; in nfsrv_cleanup()
7245 mtx_destroy(&NFSD_VNET(nfsv4root_mnt)->mnt_mtx); in nfsrv_cleanup()
7248 lockdestroy(&NFSD_VNET(nfsv4root_mnt)->mnt_explock); in nfsrv_cleanup()