Fix fco on LRU twice

2d468a6f gave the clue:

When fellow_cache_obj_lru_touch() raced fellow_cache_lru_work(),
we would put the fco's fcs on the lru list twice: once from
_touch and then from _lru_work().

Fixes #25
parent dcca7f0b
......@@ -3427,6 +3427,10 @@ fellow_cache_obj_lru_touch(struct fellow_cache_obj *fco)
if (! fcs->fcs_onlru)
return (0);
// mutate should be failing, so it will do the lru move
if (fcs->fco_lru_mutate)
return (1);
assert(fellow_cache_shouldlru(fcs->state, fco->oc, fcs->refcnt));
r = pthread_mutex_trylock(&lru->lru_mtx);
......@@ -3434,9 +3438,10 @@ fellow_cache_obj_lru_touch(struct fellow_cache_obj *fco)
assert(r == EBUSY);
return (0);
}
AZ(fcs->fco_lru_mutate);
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, fcs, lru_list);
if (! fcs->fco_lru_mutate) {
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, fcs, lru_list);
}
//lint -e{455} flexelint does not grok trylock
AZ(pthread_mutex_unlock(&lru->lru_mtx));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment