diff options
Diffstat (limited to 'sys/nfsserver')
-rw-r--r-- | sys/nfsserver/nfs.h | 2 | ||||
-rw-r--r-- | sys/nfsserver/nfs_serv.c | 197 | ||||
-rw-r--r-- | sys/nfsserver/nfs_srvsubs.c | 43 |
3 files changed, 30 insertions, 212 deletions
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h index 4bdceda..3d01923 100644 --- a/sys/nfsserver/nfs.h +++ b/sys/nfsserver/nfs.h @@ -268,7 +268,7 @@ int nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct mbuf **mrq); int nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct mbuf **mrq); -int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, int *, +int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, struct nfsrv_descript *, struct nfssvc_sock *, struct sockaddr *, int *); int nfsrv_setpublicfs(struct mount *, struct netexport *, diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index ae8f6d6..f0da468 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -162,32 +162,6 @@ ndclear(struct nameidata *nd) } /* - * Takes two vfslocked integers and returns with at most one - * reference to giant. The return value indicates whether giant - * is held by either lock. This simplifies nfsrv ops by allowing - * them to track only one vfslocked var. - */ -static __inline int -nfsrv_lockedpair(int vfs1, int vfs2) -{ - - if (vfs1 && vfs2) - VFS_UNLOCK_GIANT(vfs2); - - return (vfs1 | vfs2); -} - -static __inline int -nfsrv_lockedpair_nd(int vfs1, struct nameidata *nd) -{ - int vfs2; - - vfs2 = NDHASGIANT(nd); - - return nfsrv_lockedpair(vfs1, vfs2); -} - -/* * Heuristic to detect sequential operation. */ static struct nfsheur * @@ -265,16 +239,14 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct vattr vattr, *vap = &vattr; u_long testmode, nfsmode; int v3 = (nfsd->nd_flag & ND_NFSV3); - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); if (!v3) panic("nfsrv3_access: v3 proc called on a v2 connection"); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); tl = nfsm_dissect_nonblock(u_int32_t *, NFSX_UNSIGNED); - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(1, NULL); @@ -310,7 +282,6 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -334,13 +305,11 @@ nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, caddr_t bpos; int error = 0, rdonly; struct mbuf *mb, *mreq; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(0); error = 0; @@ -362,7 +331,6 @@ nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -391,18 +359,14 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct mbuf *mb, *mreq; struct timespec guard = { 0, 0 }; struct mount *mp = NULL; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) { error = ESTALE; goto out; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ VATTR_NULL(vap); @@ -448,8 +412,7 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, /* * Now that we have all the fields, lets do it. */ - error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly); - vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); if (v3) @@ -519,7 +482,6 @@ nfsmout: if (vp) vput(vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -544,12 +506,9 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag; struct mbuf *mb, *mreq; struct vattr va, dirattr, *vap = &va; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -559,10 +518,9 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = LOOKUP; - nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART | MPSAFE; + nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirattr, &dirattr_ret, pubflag); - vfslocked = NDHASGIANT(&nd); /* * namei failure, only dirp to cleanup. Clear out garbarge from @@ -609,14 +567,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfs_pub.np_index; ind.ni_startdir = nd.ni_vp; VREF(ind.ni_startdir); - ind.ni_cnd.cn_flags &= ~GIANTHELD; - tvfslocked = VFS_LOCK_GIANT(ind.ni_startdir->v_mount); - if (tvfslocked) - nd.ni_cnd.cn_flags |= GIANTHELD; error = lookup(&ind); ind.ni_dvp = NULL; - vfslocked = nfsrv_lockedpair_nd(vfslocked, &ind); - ind.ni_cnd.cn_flags &= ~GIANTHELD; if (error == 0) { /* @@ -703,7 +655,6 @@ nfsmout: vrele(ndp->ni_startdir); } NDFREE(&nd, NDF_ONLY_PNBUF); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -731,10 +682,8 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh; fhandle_t *fhp; struct uio io, *uiop = &io; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; #ifndef nolint mp = NULL; #endif @@ -770,7 +719,7 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_td = NULL; - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); if (v3) @@ -809,7 +758,6 @@ nfsmout: m_freem(mp3); if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -843,11 +791,8 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct nfsheur *nh; off_t off; int ioflag = 0; - int vfslocked; - nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (v3) { @@ -865,7 +810,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, * as well. */ - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { vp = NULL; nfsm_reply(2 * NFSX_UNSIGNED); @@ -1004,7 +949,6 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -1040,11 +984,8 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct uio io, *uiop = &io; off_t off; struct mount *mntp = NULL; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; if (mrep == NULL) { *mrq = NULL; error = 0; @@ -1056,7 +997,6 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mntp); (void) vn_start_write(NULL, &mntp, V_WAIT); vfs_rel(mntp); /* The write holds a ref. */ if (v3) { @@ -1112,8 +1052,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = 0; goto nfsmout; } - error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly); - vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { vp = NULL; nfsm_reply(2 * NFSX_UNSIGNED); @@ -1226,7 +1165,6 @@ nfsmout: if (vp) vput(vp); vn_finished_write(mntp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -1258,11 +1196,8 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, u_quad_t tempsize; struct timespec cverf; struct mount *mp = NULL; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; #ifndef nolint rdev = 0; #endif @@ -1274,14 +1209,13 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; - nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; /* * Call namei and do initial cleanup to get a few things @@ -1294,7 +1228,6 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, */ error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (dirp && !v3) { vrele(dirp); dirp = NULL; @@ -1430,13 +1363,8 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nd.ni_cnd.cn_flags &= ~(LOCKPARENT); nd.ni_cnd.cn_thread = curthread; nd.ni_cnd.cn_cred = cred; - tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount); - if (tvfslocked) - nd.ni_cnd.cn_flags |= GIANTHELD; error = lookup(&nd); nd.ni_dvp = NULL; - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); - nd.ni_cnd.cn_flags &= ~GIANTHELD; if (error) goto ereply; @@ -1524,7 +1452,6 @@ nfsmout: vrele(dirp); NDFREE(&nd, NDF_ONLY_PNBUF); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1554,11 +1481,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhandle_t *fhp; struct mount *mp = NULL; int v3 = (nfsd->nd_flag & ND_NFSV3); - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; if (!v3) panic("nfsrv_mknod: v3 proc called on a v2 connection"); ndclear(&nd); @@ -1569,14 +1493,13 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; - nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; /* * Handle nfs_namei() call. If an error occurs, the nd structure @@ -1586,7 +1509,6 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); @@ -1646,13 +1568,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nd.ni_cnd.cn_flags &= ~(LOCKPARENT); nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = td->td_ucred; - tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount); - if (tvfslocked) - nd.ni_cnd.cn_flags |= GIANTHELD; error = lookup(&nd); nd.ni_dvp = NULL; - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); - nd.ni_cnd.cn_flags &= ~GIANTHELD; if (error) goto out; @@ -1704,7 +1621,6 @@ ereply: nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (0); nfsmout: if (nd.ni_dvp) { @@ -1721,7 +1637,6 @@ nfsmout: vrele(nd.ni_startdir); NDFREE(&nd, NDF_ONLY_PNBUF); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1746,11 +1661,9 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh; fhandle_t *fhp; struct mount *mp = NULL; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -1758,17 +1671,15 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; - nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (dirp && !v3) { vrele(dirp); dirp = NULL; @@ -1830,7 +1741,6 @@ nfsmout: if (nd.ni_vp) vput(nd.ni_vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -1858,10 +1768,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhandle_t *ffhp, *tfhp; uid_t saved_uid; struct mount *mp = NULL; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; #ifndef nolint fvp = NULL; #endif @@ -1880,7 +1788,6 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto out1; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); @@ -1891,10 +1798,9 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, saved_uid = cred->cr_uid; fromnd.ni_cnd.cn_cred = cred; fromnd.ni_cnd.cn_nameiop = DELETE; - fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART | MPSAFE; + fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; error = nfs_namei(&fromnd, nfsd, ffhp, len, slp, nam, &md, &dpos, &fdirp, v3, &fdirfor, &fdirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &fromnd); if (fdirp && !v3) { vrele(fdirp); fdirp = NULL; @@ -1914,10 +1820,9 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, cred->cr_uid = saved_uid; tond.ni_cnd.cn_cred = cred; tond.ni_cnd.cn_nameiop = RENAME; - tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | MPSAFE; + tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; error = nfs_namei(&tond, nfsd, tfhp, len2, slp, nam, &md, &dpos, &tdirp, v3, &tdirfor, &tdirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &tond); if (tdirp && !v3) { vrele(tdirp); tdirp = NULL; @@ -2063,7 +1968,6 @@ nfsmout: vrele(fromnd.ni_vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2088,12 +1992,9 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh, dnfh; fhandle_t *fhp, *dfhp; struct mount *mp = NULL; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; dfhp = &dnfh.fh_generic; @@ -2102,14 +2003,12 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvmtofh(dfhp); nfsm_srvnamesiz(len); - error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly); - vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { @@ -2129,10 +2028,9 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, VOP_UNLOCK(vp, 0); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; - nd.ni_cnd.cn_flags = LOCKPARENT | MPSAFE | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, nfsd, dfhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (dirp && !v3) { vrele(dirp); dirp = NULL; @@ -2210,7 +2108,6 @@ nfsmout: if (nd.ni_vp) vrele(nd.ni_vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -2239,12 +2136,9 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh; fhandle_t *fhp; struct mount *mp = NULL; - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2252,16 +2146,14 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto out; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; - nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (error == 0) { VATTR_NULL(vap); if (v3) @@ -2327,13 +2219,8 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); nd.ni_cnd.cn_thread = curthread; nd.ni_cnd.cn_cred = cred; - tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount); - if (tvfslocked) - nd.ni_cnd.cn_flags |= GIANTHELD; error = lookup(&nd); nd.ni_dvp = NULL; - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); - nd.ni_cnd.cn_flags &= ~GIANTHELD; if (error == 0) { bzero((caddr_t)fhp, sizeof(nfh)); @@ -2393,7 +2280,6 @@ nfsmout: free(pathcp, M_TEMP); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2422,11 +2308,9 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh; fhandle_t *fhp; struct mount *mp = NULL; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2434,17 +2318,15 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto out; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; - nd.ni_cnd.cn_flags = LOCKPARENT | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (dirp && !v3) { vrele(dirp); dirp = NULL; @@ -2556,7 +2438,6 @@ nfsmout: if (dirp) vrele(dirp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2581,11 +2462,9 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhandle_t *fhp; struct nameidata nd; struct mount *mp = NULL; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); ndclear(&nd); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); @@ -2593,16 +2472,14 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto out; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; - nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | MPSAFE; + nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos, &dirp, v3, &dirfor, &dirfor_ret, FALSE); - vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd); if (dirp && !v3) { vrele(dirp); dirp = NULL; @@ -2680,7 +2557,6 @@ nfsmout: vrele(dirp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -2749,10 +2625,9 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t off, toff, verf; u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */ - int vfslocked, not_zfs; + int not_zfs; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (v3) { @@ -2775,7 +2650,7 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (siz > xfer) siz = xfer; fullsiz = siz; - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); @@ -3015,7 +2890,6 @@ again: nfsmout: if (vp) vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3049,13 +2923,12 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, u_quad_t off, toff, verf; u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */ int v3 = (nfsd->nd_flag & ND_NFSV3); - int usevget = 1, vfslocked; + int usevget = 1; struct componentname cn; struct mount *mntp = NULL; int not_zfs; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; vp_locked = 0; if (!v3) panic("nfsrv_readdirplus: v3 proc called on a v2 connection"); @@ -3076,7 +2949,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, if (siz > xfer) siz = xfer; fullsiz = siz; - error = nfsrv_fhtovp(fhp, NFSRV_FLAG_BUSY, &vp, &vfslocked, nfsd, slp, + error = nfsrv_fhtovp(fhp, NFSRV_FLAG_BUSY, &vp, nfsd, slp, nam, &rdonly); if (!error) { vp_locked = 1; @@ -3245,7 +3118,7 @@ again: usevget = 0; cn.cn_nameiop = LOOKUP; cn.cn_flags = ISLASTCN | NOFOLLOW | \ - LOCKSHARED | LOCKLEAF | MPSAFE; + LOCKSHARED | LOCKLEAF; cn.cn_lkflags = LK_SHARED | LK_RETRY; cn.cn_cred = cred; cn.cn_thread = curthread; @@ -3393,7 +3266,6 @@ nfsmout: vrele(vp); if (mntp) vfs_unbusy(mntp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3419,11 +3291,8 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, u_quad_t off; struct mount *mp = NULL; int v3 = (nfsd->nd_flag & ND_NFSV3); - int tvfslocked; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; if (!v3) panic("nfsrv_commit: v3 proc called on a v2 connection"); fhp = &nfh.fh_generic; @@ -3432,7 +3301,6 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, error = ESTALE; goto ereply; } - vfslocked = VFS_LOCK_GIANT(mp); (void) vn_start_write(NULL, &mp, V_WAIT); vfs_rel(mp); /* The write holds a ref. */ tl = nfsm_dissect_nonblock(u_int32_t *, 3 * NFSX_UNSIGNED); @@ -3444,8 +3312,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, off = fxdr_hyper(tl); tl += 2; cnt = fxdr_unsigned(int, *tl); - error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly); - vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); @@ -3561,7 +3428,6 @@ nfsmout: if (vp) vput(vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3588,13 +3454,11 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, fhandle_t *fhp; struct statfs statfs; u_quad_t tval; - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); if (v3) @@ -3654,7 +3518,6 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3680,15 +3543,13 @@ nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, u_quad_t maxfsize; struct statfs sb; int v3 = (nfsd->nd_flag & ND_NFSV3); - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); if (!v3) panic("nfsrv_fsinfo: v3 proc called on a v2 connection"); fhp = &nfh.fh_generic; - vfslocked = 0; nfsm_srvmtofh(fhp); - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); @@ -3729,7 +3590,6 @@ nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3754,15 +3614,13 @@ nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsfh_t nfh; fhandle_t *fhp; int v3 = (nfsd->nd_flag & ND_NFSV3); - int vfslocked; nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); if (!v3) panic("nfsrv_pathconf: v3 proc called on a v2 connection"); - vfslocked = 0; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); - error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); @@ -3802,7 +3660,6 @@ nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, nfsmout: if (vp) vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return(error); } @@ -3871,8 +3728,6 @@ nfsrv_access(struct vnode *vp, accmode_t accmode, struct ucred *cred, struct vattr vattr; int error; - VFS_ASSERT_GIANT(vp->v_mount); - nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); if (accmode & VWRITE) { diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 66a85c4..ba3a9fe 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -594,11 +594,7 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd, int error, rdonly, linklen; struct componentname *cnp = &ndp->ni_cnd; int lockleaf = (cnp->cn_flags & LOCKLEAF) != 0; - int dvfslocked; - int vfslocked; - vfslocked = 0; - dvfslocked = 0; *retdirp = NULL; cnp->cn_flags |= NOMACCHECK; cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); @@ -645,10 +641,9 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd, /* * Extract and set starting directory. */ - error = nfsrv_fhtovp(fhp, 0, &dp, &dvfslocked, nfsd, slp, nam, &rdonly); + error = nfsrv_fhtovp(fhp, 0, &dp, nfsd, slp, nam, &rdonly); if (error) goto out; - vfslocked = VFS_LOCK_GIANT(dp->v_mount); if (dp->v_type != VDIR) { vput(dp); error = ENOTDIR; @@ -726,14 +721,9 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd, if (pubflag) { ndp->ni_rootdir = rootvnode; ndp->ni_loopcnt = 0; - if (cnp->cn_pnbuf[0] == '/') { - int tvfslocked; - tvfslocked = VFS_LOCK_GIANT(rootvnode->v_mount); - VFS_UNLOCK_GIANT(vfslocked); + if (cnp->cn_pnbuf[0] == '/') dp = rootvnode; - vfslocked = tvfslocked; - } } else { cnp->cn_flags |= NOCROSSMOUNT; } @@ -758,11 +748,7 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd, * In either case ni_startdir will be dereferenced and NULLed * out. */ - if (vfslocked) - ndp->ni_cnd.cn_flags |= GIANTHELD; error = lookup(ndp); - vfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0; - ndp->ni_cnd.cn_flags &= ~GIANTHELD; if (error) break; @@ -860,10 +846,6 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd, } if (!lockleaf) cnp->cn_flags &= ~LOCKLEAF; - if (cnp->cn_flags & GIANTHELD) { - mtx_unlock(&Giant); - cnp->cn_flags &= ~GIANTHELD; - } /* * nfs_namei() guarentees that fields will not contain garbage @@ -877,21 +859,9 @@ out: ndp->ni_dvp = NULL; ndp->ni_startdir = NULL; cnp->cn_flags &= ~HASBUF; - VFS_UNLOCK_GIANT(vfslocked); - vfslocked = 0; } else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) { ndp->ni_dvp = NULL; } - /* - * This differs from normal namei() in that even on failure we may - * return with Giant held due to the dirp return. Make sure we only - * have not recursed however. The calling code only expects to drop - * one acquire. - */ - if (vfslocked || dvfslocked) - ndp->ni_cnd.cn_flags |= GIANTHELD; - if (vfslocked && dvfslocked) - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1055,7 +1025,7 @@ nfsm_srvfattr(struct nfsrv_descript *nfsd, struct vattr *vap, * - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon */ int -nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp, +nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct sockaddr *nam, int *rdonlyp) { @@ -1067,13 +1037,11 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp, struct sockaddr_int *saddr; #endif int credflavor; - int vfslocked; int numsecflavors, *secflavors; int authsys; int v3 = nfsd->nd_flag & ND_NFSV3; int mountreq; - *vfslockedp = 0; *vpp = NULL; if (nfs_ispublicfh(fhp)) { @@ -1085,7 +1053,6 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp, mp = vfs_busyfs(&fhp->fh_fsid); if (!mp) return (ESTALE); - vfslocked = VFS_LOCK_GIANT(mp); error = VFS_CHECKEXP(mp, nam, &exflags, &credanon, &numsecflavors, &secflavors); if (error) { @@ -1169,10 +1136,6 @@ out: if (credanon != NULL) crfree(credanon); - if (error) - VFS_UNLOCK_GIANT(vfslocked); - else - *vfslockedp = vfslocked; return (error); } |