summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_nfsiod.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-05-31 17:27:58 +0000
committerpeter <peter@FreeBSD.org>1998-05-31 17:27:58 +0000
commite58631da3c81e111dd78b54402762f8f6875aa62 (patch)
tree5d5b5b3e488d62a97cd4059fbf25ec5ee46fca91 /sys/nfsclient/nfs_nfsiod.c
parent21e75a7ad9fa17b5c52ac550ad110499608debf5 (diff)
downloadFreeBSD-src-e58631da3c81e111dd78b54402762f8f6875aa62.zip
FreeBSD-src-e58631da3c81e111dd78b54402762f8f6875aa62.tar.gz
NFS Jumbo commit part 1. Cosmetic and structural changes only. The aim
of this part of commits is to minimize unnecessary differences between the other NFS's of similar origin. Yes, there are gratuitous changes here that the style folks won't like, but it makes the catch-up less difficult.
Diffstat (limited to 'sys/nfsclient/nfs_nfsiod.c')
-rw-r--r--sys/nfsclient/nfs_nfsiod.c326
1 files changed, 162 insertions, 164 deletions
diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c
index 317b1c0..94f33e2 100644
--- a/sys/nfsclient/nfs_nfsiod.c
+++ b/sys/nfsclient/nfs_nfsiod.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $Id: nfs_syscalls.c,v 1.37 1998/03/30 09:54:17 phk Exp $
+ * $Id: nfs_syscalls.c,v 1.38 1998/05/19 07:11:25 peter Exp $
*/
#include <sys/param.h>
@@ -252,8 +252,9 @@ nfssvc(p, uap)
error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
if (error)
return (error);
- if ((uap->flag & NFSSVC_AUTHIN) && ((nfsd = nsd->nsd_nfsd)) &&
- (nfsd->nfsd_slp->ns_flag & SLP_VALID)) {
+ if ((uap->flag & NFSSVC_AUTHIN) &&
+ ((nfsd = nsd->nsd_nfsd)) != NULL &&
+ (nfsd->nfsd_slp->ns_flag & SLP_VALID)) {
slp = nfsd->nfsd_slp;
/*
@@ -465,11 +466,10 @@ nfssvc_nfsd(nsd, argp, p)
writes_todo = 0;
#endif
if (nfsd == (struct nfsd *)0) {
- nfsd = (struct nfsd *)
+ nsd->nsd_nfsd = nfsd = (struct nfsd *)
malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK);
bzero((caddr_t)nfsd, sizeof (struct nfsd));
s = splnet();
- nsd->nsd_nfsd = nfsd;
nfsd->nfsd_procp = p;
TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain);
nfs_numnfsd++;
@@ -746,6 +746,161 @@ done:
nfsrv_init(TRUE); /* Reinitialize everything */
return (error);
}
+
+/*
+ * Shut down a socket associated with an nfssvc_sock structure.
+ * Should be called with the send lock set, if required.
+ * The trick here is to increment the sref at the start, so that the nfsds
+ * will stop using it and clear ns_flag at the end so that it will not be
+ * reassigned during cleanup.
+ */
+static void
+nfsrv_zapsock(slp)
+ register struct nfssvc_sock *slp;
+{
+ register struct nfsuid *nuidp, *nnuidp;
+ register struct nfsrv_descript *nwp, *nnwp;
+ struct socket *so;
+ struct file *fp;
+ struct nfsrv_rec *rec;
+ int s;
+
+ slp->ns_flag &= ~SLP_ALLFLAGS;
+ fp = slp->ns_fp;
+ if (fp) {
+ slp->ns_fp = (struct file *)0;
+ so = slp->ns_so;
+ so->so_upcall = NULL;
+ soshutdown(so, 2);
+ closef(fp, (struct proc *)0);
+ if (slp->ns_nam)
+ FREE(slp->ns_nam, M_SONAME);
+ m_freem(slp->ns_raw);
+ while (rec = STAILQ_FIRST(&slp->ns_rec)) {
+ STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
+ if (rec->nr_address)
+ FREE(rec->nr_address, M_SONAME);
+ m_freem(rec->nr_packet);
+ free(rec, M_NFSRVDESC);
+ }
+ for (nuidp = slp->ns_uidlruhead.tqh_first; nuidp != 0;
+ nuidp = nnuidp) {
+ nnuidp = nuidp->nu_lru.tqe_next;
+ LIST_REMOVE(nuidp, nu_hash);
+ TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru);
+ if (nuidp->nu_flag & NU_NAM)
+ FREE(nuidp->nu_nam, M_SONAME);
+ free((caddr_t)nuidp, M_NFSUID);
+ }
+ s = splsoftclock();
+ for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) {
+ nnwp = nwp->nd_tq.le_next;
+ LIST_REMOVE(nwp, nd_tq);
+ free((caddr_t)nwp, M_NFSRVDESC);
+ }
+ LIST_INIT(&slp->ns_tq);
+ splx(s);
+ }
+}
+
+/*
+ * Derefence a server socket structure. If it has no more references and
+ * is no longer valid, you can throw it away.
+ */
+void
+nfsrv_slpderef(slp)
+ register struct nfssvc_sock *slp;
+{
+ if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
+ TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
+ free((caddr_t)slp, M_NFSSVC);
+ }
+}
+
+/*
+ * Initialize the data structures for the server.
+ * Handshake with any new nfsds starting up to avoid any chance of
+ * corruption.
+ */
+void
+nfsrv_init(terminating)
+ int terminating;
+{
+ register struct nfssvc_sock *slp, *nslp;
+
+ if (nfssvc_sockhead_flag & SLP_INIT)
+ panic("nfsd init");
+ nfssvc_sockhead_flag |= SLP_INIT;
+ if (terminating) {
+ for (slp = nfssvc_sockhead.tqh_first; slp != 0; slp = nslp) {
+ nslp = slp->ns_chain.tqe_next;
+ if (slp->ns_flag & SLP_VALID)
+ nfsrv_zapsock(slp);
+ TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
+ free((caddr_t)slp, M_NFSSVC);
+ }
+ nfsrv_cleancache(); /* And clear out server cache */
+ } else
+ nfs_pub.np_valid = 0;
+
+ TAILQ_INIT(&nfssvc_sockhead);
+ nfssvc_sockhead_flag &= ~SLP_INIT;
+ if (nfssvc_sockhead_flag & SLP_WANTINIT) {
+ nfssvc_sockhead_flag &= ~SLP_WANTINIT;
+ wakeup((caddr_t)&nfssvc_sockhead);
+ }
+
+ TAILQ_INIT(&nfsd_head);
+ nfsd_head_flag &= ~NFSD_CHECKSLP;
+
+ nfs_udpsock = (struct nfssvc_sock *)
+ malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
+ bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock));
+ STAILQ_INIT(&nfs_udpsock->ns_rec);
+ TAILQ_INIT(&nfs_udpsock->ns_uidlruhead);
+ TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
+
+ nfs_cltpsock = (struct nfssvc_sock *)
+ malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
+ bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock));
+ STAILQ_INIT(&nfs_cltpsock->ns_rec);
+ TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead);
+ TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain);
+}
+
+/*
+ * Add entries to the server monitor log.
+ */
+static void
+nfsd_rt(sotype, nd, cacherep)
+ int sotype;
+ register struct nfsrv_descript *nd;
+ int cacherep;
+{
+ register struct drt *rt;
+
+ rt = &nfsdrt.drt[nfsdrt.pos];
+ if (cacherep == RC_DOIT)
+ rt->flag = 0;
+ else if (cacherep == RC_REPLY)
+ rt->flag = DRT_CACHEREPLY;
+ else
+ rt->flag = DRT_CACHEDROP;
+ if (sotype == SOCK_STREAM)
+ rt->flag |= DRT_TCP;
+ if (nd->nd_flag & ND_NQNFS)
+ rt->flag |= DRT_NQNFS;
+ else if (nd->nd_flag & ND_NFSV3)
+ rt->flag |= DRT_NFSV3;
+ rt->proc = nd->nd_procnum;
+ if (nd->nd_nam->sa_family == AF_INET)
+ rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr;
+ else
+ rt->ipadr = INADDR_ANY;
+ rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec);
+ getmicrotime(&rt->tstamp);
+ nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
+}
#endif /* NFS_NOSERVER */
static int nfs_defect = 0;
@@ -794,7 +949,8 @@ nfssvc_iod(p)
}
if (error) {
nfs_asyncdaemon[myiod] = 0;
- if (nmp) nmp->nm_bufqiods--;
+ if (nmp)
+ nmp->nm_bufqiods--;
nfs_iodwant[myiod] = NULL;
nfs_iodmount[myiod] = NULL;
nfs_numasync--;
@@ -812,7 +968,6 @@ nfssvc_iod(p)
(void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
else
(void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);
-
/*
* If there are more than one iod on this mount, then defect
* so that the iods can be shared out fairly between the mounts
@@ -829,61 +984,6 @@ nfssvc_iod(p)
}
}
-/*
- * Shut down a socket associated with an nfssvc_sock structure.
- * Should be called with the send lock set, if required.
- * The trick here is to increment the sref at the start, so that the nfsds
- * will stop using it and clear ns_flag at the end so that it will not be
- * reassigned during cleanup.
- */
-static void
-nfsrv_zapsock(slp)
- register struct nfssvc_sock *slp;
-{
- register struct nfsuid *nuidp, *nnuidp;
- register struct nfsrv_descript *nwp, *nnwp;
- struct socket *so;
- struct file *fp;
- struct nfsrv_rec *rec;
- int s;
-
- slp->ns_flag &= ~SLP_ALLFLAGS;
- fp = slp->ns_fp;
- if (fp) {
- slp->ns_fp = (struct file *)0;
- so = slp->ns_so;
- so->so_upcall = NULL;
- soshutdown(so, 2);
- closef(fp, (struct proc *)0);
- if (slp->ns_nam)
- FREE(slp->ns_nam, M_SONAME);
- m_freem(slp->ns_raw);
- while (rec = STAILQ_FIRST(&slp->ns_rec)) {
- STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
- if (rec->nr_address)
- FREE(rec->nr_address, M_SONAME);
- m_freem(rec->nr_packet);
- free(rec, M_NFSRVDESC);
- }
- for (nuidp = slp->ns_uidlruhead.tqh_first; nuidp != 0;
- nuidp = nnuidp) {
- nnuidp = nuidp->nu_lru.tqe_next;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru);
- if (nuidp->nu_flag & NU_NAM)
- FREE(nuidp->nu_nam, M_SONAME);
- free((caddr_t)nuidp, M_NFSUID);
- }
- s = splsoftclock();
- for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) {
- nnwp = nwp->nd_tq.le_next;
- LIST_REMOVE(nwp, nd_tq);
- free((caddr_t)nwp, M_NFSRVDESC);
- }
- LIST_INIT(&slp->ns_tq);
- splx(s);
- }
-}
/*
* Get an authorization string for the uid by having the mount_nfs sitting
@@ -1088,105 +1188,3 @@ nfsmout:
*dposp = dpos;
return (error);
}
-
-#ifndef NFS_NOSERVER
-
-/*
- * Derefence a server socket structure. If it has no more references and
- * is no longer valid, you can throw it away.
- */
-void
-nfsrv_slpderef(slp)
- register struct nfssvc_sock *slp;
-{
- if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
-}
-
-/*
- * Initialize the data structures for the server.
- * Handshake with any new nfsds starting up to avoid any chance of
- * corruption.
- */
-void
-nfsrv_init(terminating)
- int terminating;
-{
- register struct nfssvc_sock *slp, *nslp;
-
- if (nfssvc_sockhead_flag & SLP_INIT)
- panic("nfsd init");
- nfssvc_sockhead_flag |= SLP_INIT;
- if (terminating) {
- for (slp = nfssvc_sockhead.tqh_first; slp != 0; slp = nslp) {
- nslp = slp->ns_chain.tqe_next;
- if (slp->ns_flag & SLP_VALID)
- nfsrv_zapsock(slp);
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
- nfsrv_cleancache(); /* And clear out server cache */
- } else
- nfs_pub.np_valid = 0;
-
- TAILQ_INIT(&nfssvc_sockhead);
- nfssvc_sockhead_flag &= ~SLP_INIT;
- if (nfssvc_sockhead_flag & SLP_WANTINIT) {
- nfssvc_sockhead_flag &= ~SLP_WANTINIT;
- wakeup((caddr_t)&nfssvc_sockhead);
- }
-
- TAILQ_INIT(&nfsd_head);
- nfsd_head_flag &= ~NFSD_CHECKSLP;
-
- nfs_udpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_udpsock->ns_rec);
- TAILQ_INIT(&nfs_udpsock->ns_uidlruhead);
- TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
-
- nfs_cltpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_cltpsock->ns_rec);
- TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead);
- TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain);
-}
-
-/*
- * Add entries to the server monitor log.
- */
-static void
-nfsd_rt(sotype, nd, cacherep)
- int sotype;
- register struct nfsrv_descript *nd;
- int cacherep;
-{
- register struct drt *rt;
-
- rt = &nfsdrt.drt[nfsdrt.pos];
- if (cacherep == RC_DOIT)
- rt->flag = 0;
- else if (cacherep == RC_REPLY)
- rt->flag = DRT_CACHEREPLY;
- else
- rt->flag = DRT_CACHEDROP;
- if (sotype == SOCK_STREAM)
- rt->flag |= DRT_TCP;
- if (nd->nd_flag & ND_NQNFS)
- rt->flag |= DRT_NQNFS;
- else if (nd->nd_flag & ND_NFSV3)
- rt->flag |= DRT_NFSV3;
- rt->proc = nd->nd_procnum;
- if (nd->nd_nam->sa_family == AF_INET)
- rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr;
- else
- rt->ipadr = INADDR_ANY;
- rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec);
- getmicrotime(&rt->tstamp);
- nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
-}
-#endif /* NFS_NOSERVER */
OpenPOWER on IntegriCloud