Lines Matching refs:rp
84 #define NETFAMILY(rp) \
85 (((rp)->rc_flags & RC_INETADDR) ? AF_INET : -1)
88 static void nfsrv_unlockcache(struct nfsrvcache *rp);
142 cleanentry(struct nfsrvcache *rp)
145 if ((rp->rc_flags & RC_REPMBUF) != 0) {
146 m_freem(rp->rc_reply);
148 if ((rp->rc_flags & RC_NAM) != 0) {
149 m_free(rp->rc_nam);
151 rp->rc_flags &= ~(RC_REPSTATUS|RC_REPMBUF);
188 struct nfsrvcache *rp;
193 LIST_FOREACH(rp, NFSRCHASH(nd->nd_retxid), rc_hash) {
194 if (nd->nd_retxid == rp->rc_xid &&
195 nd->nd_procnum == rp->rc_proc &&
196 netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
197 if ((rp->rc_gflags & RC_G_LOCKED) != 0) {
198 cv_wait(&rp->rc_cv, &nfsrv_reqcache_lock);
201 rp->rc_gflags |= RC_G_LOCKED;
206 return rp;
213 nfsrv_unlockcache(struct nfsrvcache *rp)
218 KASSERT((rp->rc_gflags & RC_G_LOCKED) != 0);
219 rp->rc_gflags &= ~RC_G_LOCKED;
220 cv_broadcast(&rp->rc_cv);
240 struct nfsrvcache *rp, *rpdup;
247 rp = nfsrv_lookupcache(nd);
248 if (rp) {
252 if (TAILQ_NEXT(rp, rc_lru)) { /* racy but ok */
254 TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
255 TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
258 if (rp->rc_state == RC_UNUSED)
260 if (rp->rc_state == RC_INPROG) {
263 } else if (rp->rc_flags & RC_REPSTATUS) {
265 nfs_rephead(0, nd, slp, rp->rc_status,
268 } else if (rp->rc_flags & RC_REPMBUF) {
270 *repp = m_copym(rp->rc_reply, 0, M_COPYALL,
275 rp->rc_state = RC_INPROG;
279 nfsrv_unlockcache(rp);
287 rp = pool_get(&nfs_reqcache_pool, PR_WAITOK);
288 memset(rp, 0, sizeof *rp);
289 cv_init(&rp->rc_cv, "nfsdrc");
290 rp->rc_gflags = RC_G_LOCKED;
292 rp = TAILQ_FIRST(&nfsrvlruhead);
293 while ((rp->rc_gflags & RC_G_LOCKED) != 0) {
294 cv_wait(&rp->rc_cv, &nfsrv_reqcache_lock);
295 rp = TAILQ_FIRST(&nfsrvlruhead);
297 rp->rc_gflags |= RC_G_LOCKED;
298 LIST_REMOVE(rp, rc_hash);
299 TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
301 cleanentry(rp);
302 rp->rc_flags = 0;
304 rp->rc_state = RC_INPROG;
305 rp->rc_xid = nd->nd_retxid;
309 rp->rc_flags |= RC_INETADDR;
310 rp->rc_inetaddr = saddr->sin_addr.s_addr;
313 rp->rc_flags |= RC_NAM;
314 rp->rc_nam = m_copym(nd->nd_nam, 0, M_COPYALL, M_WAIT);
315 m_claimm(rp->rc_nam, &nfsd_cache_mowner);
318 rp->rc_proc = nd->nd_procnum;
328 cleanentry(rp);
329 cv_destroy(&rp->rc_cv);
330 pool_put(&nfs_reqcache_pool, rp);
331 rp = rpdup;
334 TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
335 LIST_INSERT_HEAD(NFSRCHASH(nd->nd_retxid), rp, rc_hash);
336 nfsrv_unlockcache(rp);
347 struct nfsrvcache *rp;
350 rp = nfsrv_lookupcache(nd);
352 if (rp) {
353 cleanentry(rp);
354 rp->rc_state = RC_DONE;
362 rp->rc_status = nd->nd_repstat;
363 rp->rc_flags |= RC_REPSTATUS;
365 rp->rc_reply = m_copym(repmbuf,
367 m_claimm(rp->rc_reply, &nfsd_cache_mowner);
368 rp->rc_flags |= RC_REPMBUF;
372 nfsrv_unlockcache(rp);
383 struct nfsrvcache *rp;
386 while ((rp = TAILQ_FIRST(&nfsrvlruhead)) != NULL) {
387 KASSERT((rp->rc_gflags & RC_G_LOCKED) == 0);
388 LIST_REMOVE(rp, rc_hash);
389 TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
393 cleanentry(rp);
394 cv_destroy(&rp->rc_cv);
395 pool_put(&nfs_reqcache_pool, rp);