2003-08-07 20:26:28 +04:00
|
|
|
/* $NetBSD: nfs_srvcache.c,v 1.28 2003/08/07 16:33:52 agc Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-06-08 15:33:09 +04:00
|
|
|
* Copyright (c) 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-02-18 14:53:36 +03:00
|
|
|
* @(#)nfs_srvcache.c 8.3 (Berkeley) 3/30/95
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reference: Chet Juszczak, "Improving the Performance and Correctness
|
1994-06-08 15:33:09 +04:00
|
|
|
* of an NFS Server", in Proc. Winter 1989 USENIX Conference,
|
|
|
|
* pages 53-63. San Diego, February 1989.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2001-11-10 13:59:08 +03:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2003-08-07 20:26:28 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: nfs_srvcache.c,v 1.28 2003/08/07 16:33:52 agc Exp $");
|
2001-11-10 13:59:08 +03:00
|
|
|
|
1998-07-05 08:37:35 +04:00
|
|
|
#include "opt_iso.h"
|
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
2003-05-21 18:13:34 +04:00
|
|
|
#include <sys/lock.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <sys/proc.h>
|
2003-05-21 17:55:28 +04:00
|
|
|
#include <sys/pool.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/mbuf.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <sys/malloc.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <netinet/in.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#ifdef ISO
|
|
|
|
#include <netiso/iso.h>
|
|
|
|
#endif
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <nfs/nfsm_subs.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <nfs/rpcv2.h>
|
1996-02-18 14:53:36 +03:00
|
|
|
#include <nfs/nfsproto.h>
|
1993-12-18 03:40:47 +03:00
|
|
|
#include <nfs/nfs.h>
|
1994-06-08 15:33:09 +04:00
|
|
|
#include <nfs/nfsrvcache.h>
|
|
|
|
#include <nfs/nqnfs.h>
|
1996-02-10 00:48:19 +03:00
|
|
|
#include <nfs/nfs_var.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1996-02-18 14:53:36 +03:00
|
|
|
extern struct nfsstats nfsstats;
|
2002-12-02 02:02:10 +03:00
|
|
|
extern const int nfsv2_procid[NFS_NPROCS];
|
1994-06-08 15:33:09 +04:00
|
|
|
long numnfsrvcache, desirednfsrvcache = NFSRVCACHESIZ;
|
2003-05-21 17:55:28 +04:00
|
|
|
struct pool nfs_reqcache_pool;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-08-17 16:34:12 +04:00
|
|
|
#define NFSRCHASH(xid) \
|
|
|
|
(&nfsrvhashtbl[((xid) + ((xid) >> 24)) & nfsrvhash])
|
|
|
|
LIST_HEAD(nfsrvhash, nfsrvcache) *nfsrvhashtbl;
|
|
|
|
TAILQ_HEAD(nfsrvlru, nfsrvcache) nfsrvlruhead;
|
2003-05-21 18:13:34 +04:00
|
|
|
struct simplelock nfsrv_reqcache_lock = SIMPLELOCK_INITIALIZER;
|
1994-08-17 16:34:12 +04:00
|
|
|
u_long nfsrvhash;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
#define NETFAMILY(rp) \
|
|
|
|
(((rp)->rc_flag & RC_INETADDR) ? AF_INET : AF_ISO)
|
|
|
|
|
2003-05-21 18:13:34 +04:00
|
|
|
static struct nfsrvcache *nfsrv_lookupcache(struct nfsrv_descript *nd);
|
|
|
|
static void nfsrv_unlockcache(struct nfsrvcache *rp);
|
|
|
|
|
1994-06-08 15:33:09 +04:00
|
|
|
/*
|
|
|
|
* Static array that defines which nfs rpc's are nonidempotent
|
|
|
|
*/
|
2001-02-22 00:39:52 +03:00
|
|
|
const int nonidempotent[NFS_NPROCS] = {
|
1994-06-08 15:33:09 +04:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
1996-02-18 14:53:36 +03:00
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
1994-06-08 15:33:09 +04:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* True iff the rpc reply is an nfs status ONLY! */
|
2001-02-22 00:39:52 +03:00
|
|
|
static const int nfsv2_repstat[NFS_NPROCS] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the server request cache list
|
|
|
|
*/
|
1996-02-10 00:48:19 +03:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
nfsrv_initcache()
|
|
|
|
{
|
|
|
|
|
2000-11-08 17:28:12 +03:00
|
|
|
nfsrvhashtbl = hashinit(desirednfsrvcache, HASH_LIST, M_NFSD,
|
|
|
|
M_WAITOK, &nfsrvhash);
|
1994-08-17 16:34:12 +04:00
|
|
|
TAILQ_INIT(&nfsrvlruhead);
|
2003-05-21 17:55:28 +04:00
|
|
|
pool_init(&nfs_reqcache_pool, sizeof(struct nfsrvcache), 0, 0, 0,
|
|
|
|
"nfsreqcachepl", &pool_allocator_nointr);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2003-05-21 18:13:34 +04:00
|
|
|
/*
|
|
|
|
* Lookup a cache and lock it
|
|
|
|
*/
|
|
|
|
static struct nfsrvcache *
|
|
|
|
nfsrv_lookupcache(nd)
|
|
|
|
struct nfsrv_descript *nd;
|
|
|
|
{
|
|
|
|
struct nfsrvcache *rp;
|
|
|
|
|
|
|
|
LOCK_ASSERT(simple_lock_held(&nfsrv_reqcache_lock));
|
|
|
|
|
|
|
|
loop:
|
|
|
|
LIST_FOREACH(rp, NFSRCHASH(nd->nd_retxid), rc_hash) {
|
|
|
|
if (nd->nd_retxid == rp->rc_xid &&
|
|
|
|
nd->nd_procnum == rp->rc_proc &&
|
|
|
|
netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
|
|
|
|
if ((rp->rc_flag & RC_LOCKED) != 0) {
|
|
|
|
rp->rc_flag |= RC_WANTED;
|
|
|
|
(void) ltsleep(rp, PZERO - 1, "nfsrc", 0,
|
|
|
|
&nfsrv_reqcache_lock);
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
rp->rc_flag |= RC_LOCKED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unlock a cache
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
nfsrv_unlockcache(rp)
|
|
|
|
struct nfsrvcache *rp;
|
|
|
|
{
|
|
|
|
|
|
|
|
LOCK_ASSERT(simple_lock_held(&nfsrv_reqcache_lock));
|
|
|
|
|
|
|
|
rp->rc_flag &= ~RC_LOCKED;
|
|
|
|
if (rp->rc_flag & RC_WANTED) {
|
|
|
|
rp->rc_flag &= ~RC_WANTED;
|
|
|
|
wakeup(rp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Look for the request in the cache
|
|
|
|
* If found then
|
|
|
|
* return action and optionally reply
|
|
|
|
* else
|
|
|
|
* insert it in the cache
|
|
|
|
*
|
|
|
|
* The rules are as follows:
|
|
|
|
* - if in progress, return DROP request
|
|
|
|
* - if completed within DELAY of the current time, return DROP it
|
|
|
|
* - if completed a longer time ago return REPLY if the reply was cached or
|
|
|
|
* return DOIT
|
|
|
|
* Update/add new request at end of lru list
|
|
|
|
*/
|
1996-02-10 00:48:19 +03:00
|
|
|
int
|
1996-02-18 14:53:36 +03:00
|
|
|
nfsrv_getcache(nd, slp, repp)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct nfsrv_descript *nd;
|
1996-02-18 14:53:36 +03:00
|
|
|
struct nfssvc_sock *slp;
|
1993-03-21 12:45:37 +03:00
|
|
|
struct mbuf **repp;
|
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct nfsrvcache *rp;
|
1993-03-21 12:45:37 +03:00
|
|
|
struct mbuf *mb;
|
1994-06-08 15:33:09 +04:00
|
|
|
struct sockaddr_in *saddr;
|
1993-03-21 12:45:37 +03:00
|
|
|
caddr_t bpos;
|
|
|
|
int ret;
|
|
|
|
|
1996-02-18 14:53:36 +03:00
|
|
|
/*
|
|
|
|
* Don't cache recent requests for reliable transport protocols.
|
|
|
|
* (Maybe we should for the case of a reconnect, but..)
|
|
|
|
*/
|
|
|
|
if (!nd->nd_nam2)
|
2003-05-21 17:56:21 +04:00
|
|
|
return RC_DOIT;
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
rp = nfsrv_lookupcache(nd);
|
|
|
|
if (rp) {
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
|
|
|
found:
|
|
|
|
/* If not at end of LRU chain, move it there */
|
|
|
|
if (TAILQ_NEXT(rp, rc_lru)) { /* racy but ok */
|
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
|
|
|
|
TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2003-05-21 18:13:34 +04:00
|
|
|
if (rp->rc_state == RC_UNUSED)
|
|
|
|
panic("nfsrv cache");
|
|
|
|
if (rp->rc_state == RC_INPROG) {
|
|
|
|
nfsstats.srvcache_inproghits++;
|
|
|
|
ret = RC_DROPIT;
|
|
|
|
} else if (rp->rc_flag & RC_REPSTATUS) {
|
|
|
|
nfsstats.srvcache_nonidemdonehits++;
|
|
|
|
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) {
|
|
|
|
nfsstats.srvcache_nonidemdonehits++;
|
|
|
|
*repp = m_copym(rp->rc_reply, 0, M_COPYALL,
|
|
|
|
M_WAIT);
|
|
|
|
ret = RC_REPLY;
|
|
|
|
} else {
|
|
|
|
nfsstats.srvcache_idemdonehits++;
|
|
|
|
rp->rc_state = RC_INPROG;
|
|
|
|
ret = RC_DOIT;
|
|
|
|
}
|
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
nfsrv_unlockcache(rp);
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
|
|
|
return ret;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
nfsstats.srvcache_misses++;
|
1994-06-08 15:33:09 +04:00
|
|
|
if (numnfsrvcache < desirednfsrvcache) {
|
|
|
|
numnfsrvcache++;
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
|
|
|
rp = pool_get(&nfs_reqcache_pool, PR_WAITOK);
|
|
|
|
memset(rp, 0, sizeof *rp);
|
1994-06-08 15:33:09 +04:00
|
|
|
rp->rc_flag = RC_LOCKED;
|
|
|
|
} else {
|
2003-04-02 19:14:19 +04:00
|
|
|
rp = TAILQ_FIRST(&nfsrvlruhead);
|
1994-06-08 15:33:09 +04:00
|
|
|
while ((rp->rc_flag & RC_LOCKED) != 0) {
|
|
|
|
rp->rc_flag |= RC_WANTED;
|
2003-05-21 18:13:34 +04:00
|
|
|
(void) ltsleep(rp, PZERO-1, "nfsrc", 0,
|
|
|
|
&nfsrv_reqcache_lock);
|
2003-04-02 19:14:19 +04:00
|
|
|
rp = TAILQ_FIRST(&nfsrvlruhead);
|
1994-06-08 15:33:09 +04:00
|
|
|
}
|
|
|
|
rp->rc_flag |= RC_LOCKED;
|
1994-08-17 16:34:12 +04:00
|
|
|
LIST_REMOVE(rp, rc_hash);
|
|
|
|
TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
1994-06-08 15:33:09 +04:00
|
|
|
if (rp->rc_flag & RC_REPMBUF)
|
|
|
|
m_freem(rp->rc_reply);
|
|
|
|
if (rp->rc_flag & RC_NAM)
|
2003-02-26 09:31:08 +03:00
|
|
|
(void) m_free(rp->rc_nam);
|
1994-06-08 15:33:09 +04:00
|
|
|
rp->rc_flag &= (RC_LOCKED | RC_WANTED);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
rp->rc_state = RC_INPROG;
|
1994-06-08 15:33:09 +04:00
|
|
|
rp->rc_xid = nd->nd_retxid;
|
1996-02-18 14:53:36 +03:00
|
|
|
saddr = mtod(nd->nd_nam, struct sockaddr_in *);
|
1994-06-08 15:33:09 +04:00
|
|
|
switch (saddr->sin_family) {
|
|
|
|
case AF_INET:
|
|
|
|
rp->rc_flag |= RC_INETADDR;
|
|
|
|
rp->rc_inetaddr = saddr->sin_addr.s_addr;
|
|
|
|
break;
|
|
|
|
case AF_ISO:
|
|
|
|
default:
|
|
|
|
rp->rc_flag |= RC_NAM;
|
1996-02-18 14:53:36 +03:00
|
|
|
rp->rc_nam = m_copym(nd->nd_nam, 0, M_COPYALL, M_WAIT);
|
1994-06-08 15:33:09 +04:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
rp->rc_proc = nd->nd_procnum;
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
if (nfsrv_lookupcache(nd)) {
|
|
|
|
/*
|
|
|
|
* other thread made duplicate cache entry.
|
|
|
|
*/
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
|
|
|
pool_put(&nfs_reqcache_pool, rp);
|
|
|
|
goto found;
|
1994-06-08 15:33:09 +04:00
|
|
|
}
|
2003-05-21 18:13:34 +04:00
|
|
|
TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
|
|
|
|
LIST_INSERT_HEAD(NFSRCHASH(nd->nd_retxid), rp, rc_hash);
|
|
|
|
nfsrv_unlockcache(rp);
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
2003-05-21 17:56:21 +04:00
|
|
|
return RC_DOIT;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update a request cache entry after the rpc has been done
|
|
|
|
*/
|
1994-06-08 15:33:09 +04:00
|
|
|
void
|
1996-02-18 14:53:36 +03:00
|
|
|
nfsrv_updatecache(nd, repvalid, repmbuf)
|
2000-03-30 16:51:13 +04:00
|
|
|
struct nfsrv_descript *nd;
|
1993-03-21 12:45:37 +03:00
|
|
|
int repvalid;
|
|
|
|
struct mbuf *repmbuf;
|
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct nfsrvcache *rp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1996-02-18 14:53:36 +03:00
|
|
|
if (!nd->nd_nam2)
|
1994-06-08 15:33:09 +04:00
|
|
|
return;
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
rp = nfsrv_lookupcache(nd);
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
|
|
|
if (rp) {
|
|
|
|
rp->rc_state = RC_DONE;
|
|
|
|
/*
|
|
|
|
* If we have a valid reply update status and save
|
|
|
|
* the reply for non-idempotent rpc's.
|
|
|
|
*/
|
|
|
|
if (repvalid && nonidempotent[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 {
|
|
|
|
rp->rc_reply = m_copym(repmbuf,
|
|
|
|
0, M_COPYALL, M_WAIT);
|
|
|
|
rp->rc_flag |= RC_REPMBUF;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
|
|
|
nfsrv_unlockcache(rp);
|
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1994-06-08 15:33:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean out the cache. Called when the last nfsd terminates.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nfsrv_cleancache()
|
|
|
|
{
|
2000-03-30 16:51:13 +04:00
|
|
|
struct nfsrvcache *rp, *nextrp;
|
1994-06-08 15:33:09 +04:00
|
|
|
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_lock(&nfsrv_reqcache_lock);
|
2003-04-02 19:14:19 +04:00
|
|
|
for (rp = TAILQ_FIRST(&nfsrvlruhead); rp != 0; rp = nextrp) {
|
|
|
|
nextrp = TAILQ_NEXT(rp, rc_lru);
|
1994-08-17 16:34:12 +04:00
|
|
|
LIST_REMOVE(rp, rc_hash);
|
|
|
|
TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
|
2003-05-21 17:55:28 +04:00
|
|
|
pool_put(&nfs_reqcache_pool, rp);
|
1994-06-08 15:33:09 +04:00
|
|
|
}
|
|
|
|
numnfsrvcache = 0;
|
2003-05-21 18:13:34 +04:00
|
|
|
simple_unlock(&nfsrv_reqcache_lock);
|
1994-06-08 15:33:09 +04:00
|
|
|
}
|