Lines Matching refs:rc
55 replay_alloc(struct replay_cache *rc, struct rpc_msg *msg,
57 static void replay_free(struct replay_cache *rc,
59 static void replay_prune(struct replay_cache *rc);
76 struct replay_cache *rc; in replay_newcache() local
79 rc = malloc(sizeof(*rc), M_RPC, M_WAITOK|M_ZERO); in replay_newcache()
81 TAILQ_INIT(&rc->rc_cache[i]); in replay_newcache()
82 TAILQ_INIT(&rc->rc_all); in replay_newcache()
83 mtx_init(&rc->rc_lock, "rc_lock", NULL, MTX_DEF); in replay_newcache()
84 rc->rc_maxsize = maxsize; in replay_newcache()
86 return (rc); in replay_newcache()
90 replay_setsize(struct replay_cache *rc, size_t newmaxsize) in replay_setsize() argument
93 mtx_lock(&rc->rc_lock); in replay_setsize()
94 rc->rc_maxsize = newmaxsize; in replay_setsize()
95 replay_prune(rc); in replay_setsize()
96 mtx_unlock(&rc->rc_lock); in replay_setsize()
100 replay_freecache(struct replay_cache *rc) in replay_freecache() argument
103 mtx_lock(&rc->rc_lock); in replay_freecache()
104 while (TAILQ_FIRST(&rc->rc_all)) in replay_freecache()
105 replay_free(rc, TAILQ_FIRST(&rc->rc_all)); in replay_freecache()
106 mtx_destroy(&rc->rc_lock); in replay_freecache()
107 free(rc, M_RPC); in replay_freecache()
111 replay_alloc(struct replay_cache *rc, in replay_alloc() argument
116 mtx_assert(&rc->rc_lock, MA_OWNED); in replay_alloc()
118 rc->rc_count++; in replay_alloc()
126 TAILQ_INSERT_HEAD(&rc->rc_cache[h], rce, rce_link); in replay_alloc()
127 TAILQ_INSERT_HEAD(&rc->rc_all, rce, rce_alllink); in replay_alloc()
133 replay_free(struct replay_cache *rc, struct replay_cache_entry *rce) in replay_free() argument
136 mtx_assert(&rc->rc_lock, MA_OWNED); in replay_free()
138 rc->rc_count--; in replay_free()
139 TAILQ_REMOVE(&rc->rc_cache[rce->rce_hash], rce, rce_link); in replay_free()
140 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink); in replay_free()
142 rc->rc_size -= m_length(rce->rce_repbody, NULL); in replay_free()
149 replay_prune(struct replay_cache *rc) in replay_prune() argument
153 mtx_assert(&rc->rc_lock, MA_OWNED); in replay_prune()
155 if (rc->rc_count < REPLAY_MAX && rc->rc_size <= rc->rc_maxsize) in replay_prune()
162 TAILQ_FOREACH_REVERSE(rce, &rc->rc_all, replay_cache_list, in replay_prune()
168 replay_free(rc, rce); in replay_prune()
169 } while (rce && (rc->rc_count >= REPLAY_MAX in replay_prune()
170 || rc->rc_size > rc->rc_maxsize)); in replay_prune()
174 replay_find(struct replay_cache *rc, struct rpc_msg *msg, in replay_find() argument
180 mtx_lock(&rc->rc_lock); in replay_find()
181 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) { in replay_find()
194 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink); in replay_find()
195 TAILQ_INSERT_HEAD(&rc->rc_all, rce, in replay_find()
201 mtx_unlock(&rc->rc_lock); in replay_find()
205 mtx_unlock(&rc->rc_lock); in replay_find()
209 mtx_unlock(&rc->rc_lock); in replay_find()
215 replay_prune(rc); in replay_find()
217 rce = replay_alloc(rc, msg, addr, h); in replay_find()
219 mtx_unlock(&rc->rc_lock); in replay_find()
228 replay_setreply(struct replay_cache *rc, in replay_setreply() argument
240 mtx_lock(&rc->rc_lock); in replay_setreply()
241 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) { in replay_setreply()
252 rc->rc_size += m_length(m, NULL); in replay_setreply()
254 mtx_unlock(&rc->rc_lock); in replay_setreply()