Lines Matching refs:rc

56 		replay_alloc(struct replay_cache *rc, struct rpc_msg *msg,
58 static void replay_free(struct replay_cache *rc,
60 static void replay_prune(struct replay_cache *rc);
77 struct replay_cache *rc;
80 rc = malloc(sizeof(*rc), M_RPC, M_WAITOK|M_ZERO);
82 TAILQ_INIT(&rc->rc_cache[i]);
83 TAILQ_INIT(&rc->rc_all);
84 mtx_init(&rc->rc_lock, "rc_lock", NULL, MTX_DEF);
85 rc->rc_maxsize = maxsize;
87 return (rc);
91 replay_setsize(struct replay_cache *rc, size_t newmaxsize)
94 mtx_lock(&rc->rc_lock);
95 rc->rc_maxsize = newmaxsize;
96 replay_prune(rc);
97 mtx_unlock(&rc->rc_lock);
101 replay_freecache(struct replay_cache *rc)
104 mtx_lock(&rc->rc_lock);
105 while (TAILQ_FIRST(&rc->rc_all))
106 replay_free(rc, TAILQ_FIRST(&rc->rc_all));
107 mtx_destroy(&rc->rc_lock);
108 free(rc, M_RPC);
112 replay_alloc(struct replay_cache *rc,
117 mtx_assert(&rc->rc_lock, MA_OWNED);
119 rc->rc_count++;
127 TAILQ_INSERT_HEAD(&rc->rc_cache[h], rce, rce_link);
128 TAILQ_INSERT_HEAD(&rc->rc_all, rce, rce_alllink);
134 replay_free(struct replay_cache *rc, struct replay_cache_entry *rce)
137 mtx_assert(&rc->rc_lock, MA_OWNED);
139 rc->rc_count--;
140 TAILQ_REMOVE(&rc->rc_cache[rce->rce_hash], rce, rce_link);
141 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink);
143 rc->rc_size -= m_length(rce->rce_repbody, NULL);
150 replay_prune(struct replay_cache *rc)
154 mtx_assert(&rc->rc_lock, MA_OWNED);
156 if (rc->rc_count < REPLAY_MAX && rc->rc_size <= rc->rc_maxsize)
163 TAILQ_FOREACH_REVERSE(rce, &rc->rc_all, replay_cache_list,
169 replay_free(rc, rce);
170 } while (rce && (rc->rc_count >= REPLAY_MAX
171 || rc->rc_size > rc->rc_maxsize));
175 replay_find(struct replay_cache *rc, struct rpc_msg *msg,
181 mtx_lock(&rc->rc_lock);
182 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) {
195 TAILQ_REMOVE(&rc->rc_all, rce, rce_alllink);
196 TAILQ_INSERT_HEAD(&rc->rc_all, rce,
202 mtx_unlock(&rc->rc_lock);
206 mtx_unlock(&rc->rc_lock);
210 mtx_unlock(&rc->rc_lock);
216 replay_prune(rc);
218 rce = replay_alloc(rc, msg, addr, h);
220 mtx_unlock(&rc->rc_lock);
229 replay_setreply(struct replay_cache *rc,
241 mtx_lock(&rc->rc_lock);
242 TAILQ_FOREACH(rce, &rc->rc_cache[h], rce_link) {
253 rc->rc_size += m_length(m, NULL);
255 mtx_unlock(&rc->rc_lock);