Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsserver/nfs_nfsdcache.c
Context not available. | |||||
#ifndef APPLEKEXT | #ifndef APPLEKEXT | ||||
#include <fs/nfs/nfsport.h> | #include <fs/nfs/nfsport.h> | ||||
extern struct nfsstats newnfsstats; | extern struct nfsstatsv1 nfsstatsv1; | ||||
extern struct mtx nfsrc_udpmtx; | extern struct mtx nfsrc_udpmtx; | ||||
extern struct nfsrchash_bucket nfsrchash_table[NFSRVCACHE_HASHSIZE]; | extern struct nfsrchash_bucket nfsrchash_table[NFSRVCACHE_HASHSIZE]; | ||||
extern struct nfsrchash_bucket nfsrcahash_table[NFSRVCACHE_HASHSIZE]; | extern struct nfsrchash_bucket nfsrcahash_table[NFSRVCACHE_HASHSIZE]; | ||||
Context not available. | |||||
TAILQ_INIT(&nfsrvudplru); | TAILQ_INIT(&nfsrvudplru); | ||||
nfsrc_tcpsavedreplies = 0; | nfsrc_tcpsavedreplies = 0; | ||||
nfsrc_udpcachesize = 0; | nfsrc_udpcachesize = 0; | ||||
newnfsstats.srvcache_tcppeak = 0; | nfsstatsv1.srvcache_tcppeak = 0; | ||||
newnfsstats.srvcache_size = 0; | nfsstatsv1.srvcache_size = 0; | ||||
} | } | ||||
/* | /* | ||||
Context not available. | |||||
TAILQ_REMOVE(&nfsrvudplru, rp, rc_lru); | TAILQ_REMOVE(&nfsrvudplru, rp, rc_lru); | ||||
TAILQ_INSERT_TAIL(&nfsrvudplru, rp, rc_lru); | TAILQ_INSERT_TAIL(&nfsrvudplru, rp, rc_lru); | ||||
if (rp->rc_flag & RC_INPROG) { | if (rp->rc_flag & RC_INPROG) { | ||||
newnfsstats.srvcache_inproghits++; | nfsstatsv1.srvcache_inproghits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
ret = RC_DROPIT; | ret = RC_DROPIT; | ||||
} else if (rp->rc_flag & RC_REPSTATUS) { | } else if (rp->rc_flag & RC_REPSTATUS) { | ||||
/* | /* | ||||
* V2 only. | * V2 only. | ||||
*/ | */ | ||||
newnfsstats.srvcache_nonidemdonehits++; | nfsstatsv1.srvcache_nonidemdonehits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
nfsrvd_rephead(nd); | nfsrvd_rephead(nd); | ||||
*(nd->nd_errp) = rp->rc_status; | *(nd->nd_errp) = rp->rc_status; | ||||
Context not available. | |||||
rp->rc_timestamp = NFSD_MONOSEC + | rp->rc_timestamp = NFSD_MONOSEC + | ||||
NFSRVCACHE_UDPTIMEOUT; | NFSRVCACHE_UDPTIMEOUT; | ||||
} else if (rp->rc_flag & RC_REPMBUF) { | } else if (rp->rc_flag & RC_REPMBUF) { | ||||
newnfsstats.srvcache_nonidemdonehits++; | nfsstatsv1.srvcache_nonidemdonehits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
nd->nd_mreq = m_copym(rp->rc_reply, 0, | nd->nd_mreq = m_copym(rp->rc_reply, 0, | ||||
M_COPYALL, M_WAITOK); | M_COPYALL, M_WAITOK); | ||||
Context not available. | |||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
newnfsstats.srvcache_misses++; | nfsstatsv1.srvcache_misses++; | ||||
atomic_add_int(&newnfsstats.srvcache_size, 1); | atomic_add_int(&nfsstatsv1.srvcache_size, 1); | ||||
nfsrc_udpcachesize++; | nfsrc_udpcachesize++; | ||||
newrp->rc_flag |= RC_INPROG; | newrp->rc_flag |= RC_INPROG; | ||||
Context not available. | |||||
* Reply from cache is a special case returned by nfsrv_checkseqid(). | * Reply from cache is a special case returned by nfsrv_checkseqid(). | ||||
*/ | */ | ||||
if (nd->nd_repstat == NFSERR_REPLYFROMCACHE) { | if (nd->nd_repstat == NFSERR_REPLYFROMCACHE) { | ||||
newnfsstats.srvcache_nonidemdonehits++; | nfsstatsv1.srvcache_nonidemdonehits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
nd->nd_repstat = 0; | nd->nd_repstat = 0; | ||||
if (nd->nd_mreq) | if (nd->nd_mreq) | ||||
Context not available. | |||||
if (!(rp->rc_flag & RC_UDP)) { | if (!(rp->rc_flag & RC_UDP)) { | ||||
atomic_add_int(&nfsrc_tcpsavedreplies, 1); | atomic_add_int(&nfsrc_tcpsavedreplies, 1); | ||||
if (nfsrc_tcpsavedreplies > | if (nfsrc_tcpsavedreplies > | ||||
newnfsstats.srvcache_tcppeak) | nfsstatsv1.srvcache_tcppeak) | ||||
newnfsstats.srvcache_tcppeak = | nfsstatsv1.srvcache_tcppeak = | ||||
nfsrc_tcpsavedreplies; | nfsrc_tcpsavedreplies; | ||||
} | } | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
Context not available. | |||||
panic("nfs tcp cache0"); | panic("nfs tcp cache0"); | ||||
rp->rc_flag |= RC_LOCKED; | rp->rc_flag |= RC_LOCKED; | ||||
if (rp->rc_flag & RC_INPROG) { | if (rp->rc_flag & RC_INPROG) { | ||||
newnfsstats.srvcache_inproghits++; | nfsstatsv1.srvcache_inproghits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
if (newrp->rc_sockref == rp->rc_sockref) | if (newrp->rc_sockref == rp->rc_sockref) | ||||
nfsrc_marksametcpconn(rp->rc_sockref); | nfsrc_marksametcpconn(rp->rc_sockref); | ||||
Context not available. | |||||
/* | /* | ||||
* V2 only. | * V2 only. | ||||
*/ | */ | ||||
newnfsstats.srvcache_nonidemdonehits++; | nfsstatsv1.srvcache_nonidemdonehits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
if (newrp->rc_sockref == rp->rc_sockref) | if (newrp->rc_sockref == rp->rc_sockref) | ||||
nfsrc_marksametcpconn(rp->rc_sockref); | nfsrc_marksametcpconn(rp->rc_sockref); | ||||
Context not available. | |||||
*(nd->nd_errp) = rp->rc_status; | *(nd->nd_errp) = rp->rc_status; | ||||
rp->rc_timestamp = NFSD_MONOSEC + nfsrc_tcptimeout; | rp->rc_timestamp = NFSD_MONOSEC + nfsrc_tcptimeout; | ||||
} else if (rp->rc_flag & RC_REPMBUF) { | } else if (rp->rc_flag & RC_REPMBUF) { | ||||
newnfsstats.srvcache_nonidemdonehits++; | nfsstatsv1.srvcache_nonidemdonehits++; | ||||
mtx_unlock(mutex); | mtx_unlock(mutex); | ||||
if (newrp->rc_sockref == rp->rc_sockref) | if (newrp->rc_sockref == rp->rc_sockref) | ||||
nfsrc_marksametcpconn(rp->rc_sockref); | nfsrc_marksametcpconn(rp->rc_sockref); | ||||
Context not available. | |||||
free((caddr_t)newrp, M_NFSRVCACHE); | free((caddr_t)newrp, M_NFSRVCACHE); | ||||
goto out; | goto out; | ||||
} | } | ||||
newnfsstats.srvcache_misses++; | nfsstatsv1.srvcache_misses++; | ||||
atomic_add_int(&newnfsstats.srvcache_size, 1); | atomic_add_int(&nfsstatsv1.srvcache_size, 1); | ||||
/* | /* | ||||
* For TCP, multiple entries for a key are allowed, so don't | * For TCP, multiple entries for a key are allowed, so don't | ||||
Context not available. | |||||
atomic_add_int(&nfsrc_tcpsavedreplies, -1); | atomic_add_int(&nfsrc_tcpsavedreplies, -1); | ||||
} | } | ||||
FREE((caddr_t)rp, M_NFSRVCACHE); | FREE((caddr_t)rp, M_NFSRVCACHE); | ||||
atomic_add_int(&newnfsstats.srvcache_size, -1); | atomic_add_int(&nfsstatsv1.srvcache_size, -1); | ||||
} | } | ||||
/* | /* | ||||
Context not available. | |||||
nfsrc_freecache(rp); | nfsrc_freecache(rp); | ||||
} | } | ||||
} | } | ||||
newnfsstats.srvcache_size = 0; | nfsstatsv1.srvcache_size = 0; | ||||
mtx_unlock(&nfsrc_udpmtx); | mtx_unlock(&nfsrc_udpmtx); | ||||
nfsrc_tcpsavedreplies = 0; | nfsrc_tcpsavedreplies = 0; | ||||
} | } | ||||
Context not available. |