Unverified Commit bf1e9e71 authored by Nils Goroll's avatar Nils Goroll

Hunt bug #25

parent 155110e4
......@@ -43,6 +43,8 @@
#include "foreign/vend.h"
#define BUG25_CHECK(fcs) assert(VTAILQ_NEXT(fcs, lru_list) != fcs)
#ifdef TEST_DRIVER
#define FCERR_INJECT
#endif
......@@ -1139,9 +1141,20 @@ fellow_cache_lru_chgbatch_apply(struct fellow_lru_chgbatch *lcb)
TAKE_OBJ_NOTNULL(fcs, &lcb->fcs[lcb->n_rem],
FELLOW_CACHE_SEG_MAGIC);
assert(fcs->fco == fco);
BUG25_CHECK(fcs);
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
}
fcs = VTAILQ_FIRST(&lcb->add);
if (fcs)
BUG25_CHECK(fcs);
fcs = VTAILQ_FIRST(&lru->lru_head);
if (fcs)
BUG25_CHECK(fcs);
VTAILQ_CONCAT(&lru->lru_head, &lcb->add, lru_list);
fcs = VTAILQ_FIRST(&lru->lru_head);
if (fcs)
BUG25_CHECK(fcs);
AZ(pthread_mutex_unlock(&lru->lru_mtx));
lcb->n_add = 0;
AZ(lcb->n_rem);
......@@ -1203,13 +1216,17 @@ fellow_cache_lru_chg(struct fellow_lru_chgbatch *lcb,
AZ(fcs->lcb_add);
AZ(fcs->lcb_remove);
fcs->lcb_add = 1;
BUG25_CHECK(fcs);
VTAILQ_INSERT_TAIL(&lcb->add, fcs, lru_list);
BUG25_CHECK(fcs);
lcb->n_add++;
}
else if (fcs->lcb_add) {
//DBG("%p -add", fcs);
AZ(fcs->lcb_remove);
BUG25_CHECK(fcs);
VTAILQ_REMOVE(&lcb->add, fcs, lru_list);
BUG25_CHECK(fcs);
fcs->lcb_add = 0;
AN(lcb->n_add);
lcb->n_add--;
......@@ -3056,7 +3073,9 @@ fellow_cache_lru_seg_evict_locked(
fcs->fcs_onlru = 0;
AN(lru->n);
lru->n--;
BUG25_CHECK(fcs);
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
BUG25_CHECK(fcs);
fellow_cache_seg_evict_locked(fcs, alloc);
}
......@@ -3167,6 +3186,9 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
AZ(pthread_mutex_lock(&lru->lru_mtx));
//lint -e{850} loop variable modified in body
VTAILQ_FOREACH_SAFE(fcs, &lru->lru_head, lru_list, fcss) {
BUG25_CHECK(fcs);
if (fcss)
BUG25_CHECK(fcss);
// no use trying the same object again and again
if (fcs->fco == fco)
continue;
......@@ -3180,6 +3202,9 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
}
if (fcs->state == FCS_INCORE) {
do {
BUG25_CHECK(fcs);
if (fcss)
BUG25_CHECK(fcss);
fellow_cache_lru_seg_evict_locked(fcs,
&alloc, lru);
AN(buddy_return_ptr_extent(rets, &alloc));
......@@ -3210,6 +3235,8 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
AN(lru->n);
lru->n--;
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
BUG25_CHECK(fcs);
AZ(pthread_mutex_unlock(&lru->lru_mtx));
r = stvfe_mutate(wrk, lru, oc);
......@@ -3232,7 +3259,9 @@ fellow_cache_lru_work(struct worker *wrk, struct fellow_cache_lru *lru)
AN(fcs->fco_lru_mutate);
fcs->fco_lru_mutate = 0;
BUG25_CHECK(fcs);
VTAILQ_INSERT_TAIL(&lru->lru_head, fcs, lru_list);
BUG25_CHECK(fcs);
lru->n++;
AZ(pthread_mutex_unlock(&fco->mtx));
......@@ -3454,8 +3483,11 @@ fellow_cache_obj_lru_touch(struct fellow_cache_obj *fco)
assert(r == EBUSY);
return (0);
}
BUG25_CHECK(fcs);
VTAILQ_REMOVE(&lru->lru_head, fcs, lru_list);
BUG25_CHECK(fcs);
VTAILQ_INSERT_TAIL(&lru->lru_head, fcs, lru_list);
BUG25_CHECK(fcs);
//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