Commit 856edab5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give the stevedore the chance to tell which LRU list a given object

should be on.
parent e0d21c96
......@@ -143,7 +143,7 @@ EXP_Insert(struct object *o)
assert(o->entered != 0 && !isnan(o->entered));
o->last_lru = o->entered;
lru = STV_lru(o->objstore);
lru = STV_lru(o);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
Lck_Lock(&exp_mtx);
(void)update_object_when(o);
......@@ -180,7 +180,7 @@ EXP_Touch(struct object *o, double tnow)
if (oc->flags & OC_F_LRUDONTMOVE)
return;
lru = STV_lru(o->objstore);
lru = STV_lru(o);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
if (Lck_Trylock(&exp_mtx))
......
......@@ -283,6 +283,19 @@ STV_NewObject(struct sess *sp, const char *hint, unsigned wsl, double ttl,
/*-------------------------------------------------------------------*/
static struct lru *
stv_default_getlru(const struct object *o)
{
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC);
CHECK_OBJ_NOTNULL(o->objstore->stevedore, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(o->objstore->stevedore->lru, LRU_MAGIC);
return (o->objstore->stevedore->lru);
}
/*-------------------------------------------------------------------*/
void
STV_Freestore(struct object *o)
{
......@@ -386,11 +399,14 @@ STV_close(void)
}
struct lru *
STV_lru(const struct storage *st)
STV_lru(const struct object *o)
{
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC);
CHECK_OBJ_NOTNULL(o->objstore->stevedore, STEVEDORE_MAGIC);
AN(o->objstore->stevedore->getlru);
return (st->stevedore->lru);
return (o->objstore->stevedore->getlru(o));
}
/*--------------------------------------------------------------------
......@@ -455,6 +471,8 @@ STV_Config(const char *spec)
AN(stv->alloc);
if (stv->allocobj == NULL)
stv->allocobj = stv_default_allocobj;
if (stv->getlru == NULL)
stv->getlru = stv_default_getlru;
if (p == NULL)
bprintf(stv->ident, "s%u", seq++);
......
......@@ -43,6 +43,7 @@ typedef void storage_trim_f(struct storage *, size_t size);
typedef void storage_free_f(struct storage *);
typedef struct object *storage_allocobj_f(struct stevedore *, struct sess *sp,
unsigned ltot, const struct stv_objsecrets *);
typedef struct lru *storage_getlru_f(const struct object *);
typedef void storage_close_f(const struct stevedore *);
/* Prototypes for VCL variable responders */
......@@ -58,6 +59,7 @@ struct stevedore {
storage_init_f *init; /* called by mgt process */
storage_open_f *open; /* called by cache process */
storage_alloc_f *alloc; /* --//-- */
storage_getlru_f *getlru; /* --//-- */
storage_trim_f *trim; /* --//-- */
storage_free_f *free; /* --//-- */
storage_close_f *close; /* --//-- */
......@@ -86,7 +88,7 @@ void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st);
void STV_open(void);
void STV_close(void);
struct lru *STV_lru(const struct storage *st);
struct lru *STV_lru(const struct object *o);
void STV_Config(const char *spec);
void STV_Config_Transient(void);
void STV_Freestore(struct object *o);
......
......@@ -1427,6 +1427,19 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
return (ss);
}
/*--------------------------------------------------------------------
* Find the per-segment lru list for this object
*/
static struct lru *
smp_getlru(const struct object *o)
{
struct smp_seg *sg;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
CAST_OBJ_NOTNULL(sg, o->objcore->priv, SMP_SEG_MAGIC);
return (sg->lru);
}
/*--------------------------------------------------------------------
* Allocate an object
......@@ -1552,6 +1565,7 @@ const struct stevedore smp_stevedore = {
.close = smp_close,
.alloc = smp_alloc,
.allocobj = smp_allocobj,
.getlru = smp_getlru,
.free = smp_free,
.trim = smp_trim,
};
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