summaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_srvcache.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1996-03-31 13:16:48 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1996-03-31 13:16:48 +0000
commit21504931d6eeb371924b7751ab95d7209ef959db (patch)
treed80b42388119345065cd25ccf71050a3ed63ae26 /sys/nfs/nfs_srvcache.c
parent633344117da42400851635ede8dd4464fb125ae7 (diff)
From NetBSD: NFSv3 import (tomorrow's Net's kernel)
Open's patches kept in. i'll possibly take a look at Lite2 soon, is there smth usefull ?..
Diffstat (limited to 'sys/nfs/nfs_srvcache.c')
-rw-r--r--sys/nfs/nfs_srvcache.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/sys/nfs/nfs_srvcache.c b/sys/nfs/nfs_srvcache.c
index 169e2598f78..0da62453b67 100644
--- a/sys/nfs/nfs_srvcache.c
+++ b/sys/nfs/nfs_srvcache.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: nfs_srvcache.c,v 1.2 1996/02/29 09:24:55 niklas Exp $ */
-/* $NetBSD: nfs_srvcache.c,v 1.11 1996/02/09 21:48:32 christos Exp $ */
+/* $OpenBSD: nfs_srvcache.c,v 1.3 1996/03/31 13:15:50 mickey Exp $ */
+/* $NetBSD: nfs_srvcache.c,v 1.12 1996/02/18 11:53:49 fvdl Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)nfs_srvcache.c 8.2 (Berkeley) 8/18/94
+ * @(#)nfs_srvcache.c 8.3 (Berkeley) 3/30/95
*/
/*
@@ -61,12 +61,14 @@
#endif
#include <nfs/nfsm_subs.h>
#include <nfs/rpcv2.h>
-#include <nfs/nfsv2.h>
+#include <nfs/nfsproto.h>
#include <nfs/nfs.h>
#include <nfs/nfsrvcache.h>
#include <nfs/nqnfs.h>
#include <nfs/nfs_var.h>
+extern struct nfsstats nfsstats;
+extern int nfsv2_procid[NFS_NPROCS];
long numnfsrvcache, desirednfsrvcache = NFSRVCACHESIZ;
#define NFSRCHASH(xid) \
@@ -92,7 +94,6 @@ int nonidempotent[NFS_NPROCS] = {
FALSE,
FALSE,
FALSE,
- FALSE,
TRUE,
TRUE,
TRUE,
@@ -101,6 +102,10 @@ int nonidempotent[NFS_NPROCS] = {
TRUE,
TRUE,
TRUE,
+ TRUE,
+ FALSE,
+ FALSE,
+ FALSE,
FALSE,
FALSE,
FALSE,
@@ -111,7 +116,7 @@ int nonidempotent[NFS_NPROCS] = {
};
/* True iff the rpc reply is an nfs status ONLY! */
-static int repliesstatus[NFS_NPROCS] = {
+static int nfsv2_repstat[NFS_NPROCS] = {
FALSE,
FALSE,
FALSE,
@@ -130,11 +135,6 @@ static int repliesstatus[NFS_NPROCS] = {
TRUE,
FALSE,
FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- TRUE,
};
/*
@@ -163,9 +163,9 @@ nfsrv_initcache()
* Update/add new request at end of lru list
*/
int
-nfsrv_getcache(nam, nd, repp)
- struct mbuf *nam;
- register struct nfsd *nd;
+nfsrv_getcache(nd, slp, repp)
+ register struct nfsrv_descript *nd;
+ struct nfssvc_sock *slp;
struct mbuf **repp;
{
register struct nfsrvcache *rp;
@@ -174,13 +174,17 @@ nfsrv_getcache(nam, nd, repp)
caddr_t bpos;
int ret;
- if (nd->nd_nqlflag != NQL_NOVAL)
+ /*
+ * Don't cache recent requests for reliable transport protocols.
+ * (Maybe we should for the case of a reconnect, but..)
+ */
+ if (!nd->nd_nam2)
return (RC_DOIT);
loop:
for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
rp = rp->rc_hash.le_next) {
if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nam)) {
+ netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
(void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0);
@@ -199,7 +203,7 @@ loop:
ret = RC_DROPIT;
} else if (rp->rc_flag & RC_REPSTATUS) {
nfsstats.srvcache_nonidemdonehits++;
- nfs_rephead(0, nd, rp->rc_status,
+ nfs_rephead(0, nd, slp, rp->rc_status,
0, (u_quad_t *)0, repp, &mb, &bpos);
ret = RC_REPLY;
} else if (rp->rc_flag & RC_REPMBUF) {
@@ -246,7 +250,7 @@ loop:
TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
rp->rc_state = RC_INPROG;
rp->rc_xid = nd->nd_retxid;
- saddr = mtod(nam, struct sockaddr_in *);
+ saddr = mtod(nd->nd_nam, struct sockaddr_in *);
switch (saddr->sin_family) {
case AF_INET:
rp->rc_flag |= RC_INETADDR;
@@ -255,7 +259,7 @@ loop:
case AF_ISO:
default:
rp->rc_flag |= RC_NAM;
- rp->rc_nam = m_copym(nam, 0, M_COPYALL, M_WAIT);
+ rp->rc_nam = m_copym(nd->nd_nam, 0, M_COPYALL, M_WAIT);
break;
};
rp->rc_proc = nd->nd_procnum;
@@ -272,21 +276,20 @@ loop:
* Update a request cache entry after the rpc has been done
*/
void
-nfsrv_updatecache(nam, nd, repvalid, repmbuf)
- struct mbuf *nam;
- register struct nfsd *nd;
+nfsrv_updatecache(nd, repvalid, repmbuf)
+ register struct nfsrv_descript *nd;
int repvalid;
struct mbuf *repmbuf;
{
register struct nfsrvcache *rp;
- if (nd->nd_nqlflag != NQL_NOVAL)
+ if (!nd->nd_nam2)
return;
loop:
for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
rp = rp->rc_hash.le_next) {
if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nam)) {
+ netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
(void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0);
@@ -299,7 +302,8 @@ loop:
* the reply for non-idempotent rpc's.
*/
if (repvalid && nonidempotent[nd->nd_procnum]) {
- if (repliesstatus[nd->nd_procnum]) {
+ if ((nd->nd_flag & ND_NFSV3) == 0 &&
+ nfsv2_repstat[nfsv2_procid[nd->nd_procnum]]) {
rp->rc_status = nd->nd_repstat;
rp->rc_flag |= RC_REPSTATUS;
} else {