Commit d0db0a59 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Get rid of the LRU list sentenniel.

parent ef2face7
......@@ -382,7 +382,7 @@ struct objcore {
#define OC_F_PRIV (1<<5) /* Stevedore private flag */
unsigned timer_idx;
VTAILQ_ENTRY(objcore) list;
VLIST_ENTRY(objcore) lru_list;
VTAILQ_ENTRY(objcore) lru_list;
VTAILQ_ENTRY(objcore) ban_list;
struct ban *ban;
};
......@@ -416,15 +416,6 @@ oc_getlru(const struct objcore *oc)
return (oc->methods->getlru(oc));
}
/*--------------------------------------------------------------------*/
struct lru {
unsigned magic;
#define LRU_MAGIC 0x3fec7bb0
VLIST_HEAD(,objcore) lru_head;
struct objcore senteniel;
};
/* Object structure --------------------------------------------------*/
VTAILQ_HEAD(storagehead, storage);
......@@ -634,7 +625,7 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
void EXP_Init(void);
void EXP_Rearm(const struct object *o);
void EXP_Touch(struct object *o, double tnow);
int EXP_NukeOne(const struct sess *sp, const struct lru *lru);
int EXP_NukeOne(const struct sess *sp, struct lru *lru);
/* cache_fetch.c */
struct storage *FetchStorage(const struct sess *sp, ssize_t sz);
......
......@@ -98,7 +98,7 @@ exp_insert(struct objcore *oc, struct lru *lru)
assert(oc->timer_idx == BINHEAP_NOIDX);
binheap_insert(exp_heap, oc);
assert(oc->timer_idx != BINHEAP_NOIDX);
VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
oc->flags |= OC_F_ONLRU;
}
......@@ -187,8 +187,8 @@ EXP_Touch(struct object *o, double tnow)
return;
if (oc->flags & OC_F_ONLRU) { /* XXX ?? */
VLIST_REMOVE(oc, lru_list);
VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
VSC_main->n_lru_moved++;
o->last_lru = tnow;
}
......@@ -239,6 +239,7 @@ static void * __match_proto__(void *start_routine(void *))
exp_timer(struct sess *sp, void *priv)
{
struct objcore *oc;
struct lru *lru;
double t;
(void)priv;
......@@ -272,7 +273,8 @@ exp_timer(struct sess *sp, void *priv)
/* And from LRU */
if (oc->flags & OC_F_ONLRU) {
VLIST_REMOVE(oc, lru_list);
lru = oc_getlru(oc);
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
oc->flags &= ~OC_F_ONLRU;
}
......@@ -293,19 +295,14 @@ exp_timer(struct sess *sp, void *priv)
*/
int
EXP_NukeOne(const struct sess *sp, const struct lru *lru)
EXP_NukeOne(const struct sess *sp, struct lru *lru)
{
struct objcore *oc;
struct object *o;
/* Find the first currently unused object on the LRU. */
Lck_Lock(&exp_mtx);
VLIST_FOREACH(oc, &lru->lru_head, lru_list) {
if (oc == &lru->senteniel) {
AZ(VLIST_NEXT(oc, lru_list));
oc = NULL;
break;
}
VTAILQ_FOREACH(oc, &lru->lru_head, lru_list) {
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->timer_idx == BINHEAP_NOIDX) /* exp_timer has it */
continue;
......@@ -313,7 +310,7 @@ EXP_NukeOne(const struct sess *sp, const struct lru *lru)
break;
}
if (oc != NULL) {
VLIST_REMOVE(oc, lru_list);
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
oc->flags &= ~OC_F_ONLRU;
binheap_delete(exp_heap, oc->timer_idx);
assert(oc->timer_idx == BINHEAP_NOIDX);
......
......@@ -70,8 +70,7 @@ LRU_Alloc(void)
ALLOC_OBJ(l, LRU_MAGIC);
AN(l);
VLIST_INIT(&l->lru_head);
VLIST_INSERT_HEAD(&l->lru_head, &l->senteniel, lru_list);
VTAILQ_INIT(&l->lru_head);
return (l);
}
......
......@@ -50,6 +50,16 @@ typedef void storage_close_f(const struct stevedore *);
#include "vrt_stv_var.h"
#undef VRTSTVTYPE
/*--------------------------------------------------------------------*/
struct lru {
unsigned magic;
#define LRU_MAGIC 0x3fec7bb0
VTAILQ_HEAD(,objcore) lru_head;
};
/*--------------------------------------------------------------------*/
struct stevedore {
unsigned magic;
#define STEVEDORE_MAGIC 0x4baf43db
......
......@@ -601,10 +601,8 @@ debug_report_silo(struct cli *cli, const struct smp_sc *sc, int objs)
cli_out(cli, " %u nobj, %u alloc, %u lobjlist, %u fixed\n",
sg->nobj, sg->nalloc, sg->p.lobjlist, sg->nfixed);
if (objs) {
VLIST_FOREACH(oc, &sg->lru->lru_head, lru_list)
cli_out(cli, " %s %p\n",
oc == &sg->lru->senteniel ?
"senteniel" : "OC: ", oc);
VTAILQ_FOREACH(oc, &sg->lru->lru_head, lru_list)
cli_out(cli, " OC %p\n", oc);
}
}
}
......
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