Lines Matching refs:rc

58 		replay_alloc(struct replay_cache *rc, struct rpc_msg *msg,
60 static void replay_free(struct replay_cache *rc,
62 static void replay_prune(struct replay_cache *rc);
79 struct replay_cache *rc;
82 rc = malloc(sizeof(*rc), M_RPC, M_WAITOK|M_ZERO);
84 TAILQ_INIT(&rc->rc_cache[i]);
85 TAILQ_INIT(&rc->rc_all);
86 mtx_init(&rc->rc_lock, "rc_lock", NULL, MTX_DEF);
87 rc->rc_maxsize = maxsize;
89 return (rc);
93 replay_setsize(struct replay_cache *rc, size_t newmaxsize)
96 mtx_lock(&rc->rc_lock);
97 rc->rc_maxsize = newmaxsize;
98 replay_prune(rc);
99 mtx_unlock(&rc->rc_lock);
103 replay_freecache(struct replay_cache *rc)
106 mtx_lock(&rc->rc_lock);
107 while (TAILQ_FIRST(&rc->rc_all))
108 replay_free(rc, TAILQ_FIRST(&rc->rc_all));
109 mtx_destroy(&rc->rc_lock);
110 free(rc, M_RPC);
114 replay_alloc(struct replay_cache *rc,
119 mtx_assert(&rc->rc_lock, MA_OWNED);
121 rc->rc_count++;
129 TAILQ_INSERT_HEAD(&rc->rc_cache[h], rce, rce_link);
130 TAILQ_INSERT_HEAD(&rc->rc_all, rce, rce_alllink);
136 replay_free(struct replay_cache *rc, struct replay_cache_entry *rce)
139 mtx_assert(&rc->rc_lock, MA_OWNED);
141 rc->rc_count--;
142 TAILQ_REMOVE(&rc->rc_cache[rce->rce_hash], rce, rce_link);
143 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink);
145 rc->rc_size -= m_length(rce->rce_repbody, NULL);
152 replay_prune(struct replay_cache *rc)
156 mtx_assert(&rc->rc_lock, MA_OWNED);
158 if (rc->rc_count < REPLAY_MAX && rc->rc_size <= rc->rc_maxsize)
165 TAILQ_FOREACH_REVERSE(rce, &rc->rc_all, replay_cache_list,
171 replay_free(rc, rce);
172 } while (rce && (rc->rc_count >= REPLAY_MAX
173 || rc->rc_size > rc->rc_maxsize));
177 replay_find(struct replay_cache *rc, struct rpc_msg *msg,
183 mtx_lock(&rc->rc_lock);
184 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) {
197 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink);
198 TAILQ_INSERT_HEAD(&rc->rc_all, rce,
204 mtx_unlock(&rc->rc_lock);
208 mtx_unlock(&rc->rc_lock);
212 mtx_unlock(&rc->rc_lock);
218 replay_prune(rc);
220 rce = replay_alloc(rc, msg, addr, h);
222 mtx_unlock(&rc->rc_lock);
231 replay_setreply(struct replay_cache *rc,
243 mtx_lock(&rc->rc_lock);
244 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) {
255 rc->rc_size += m_length(m, NULL);
257 mtx_unlock(&rc->rc_lock);