[master] ef2face The LRU is a property of the objcore which is on it, not of whatever storage we have put the object into.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Feb 9 10:58:29 CET 2011
commit ef2face7d1d546d64c1d64da8ebba7d03899ed94
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 9 09:58:02 2011 +0000
The LRU is a property of the objcore which is on it, not of
whatever storage we have put the object into.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index 32c6e45..da5c80e 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -354,11 +354,13 @@ struct storage {
typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc);
typedef void updatemeta_f(struct objcore *oc);
typedef void freeobj_f(struct objcore *oc);
+typedef struct lru *getlru_f(const struct objcore *oc);
struct objcore_methods {
getobj_f *getobj;
updatemeta_f *updatemeta;
freeobj_f *freeobj;
+ getlru_f *getlru;
};
extern struct objcore_methods default_oc_methods;
@@ -407,6 +409,13 @@ oc_freeobj(struct objcore *oc)
oc->methods->freeobj(oc);
}
+static inline struct lru *
+oc_getlru(const struct objcore *oc)
+{
+
+ return (oc->methods->getlru(oc));
+}
+
/*--------------------------------------------------------------------*/
struct lru {
diff --git a/bin/varnishd/cache_expire.c b/bin/varnishd/cache_expire.c
index bc791f1..23c9cc2 100644
--- a/bin/varnishd/cache_expire.c
+++ b/bin/varnishd/cache_expire.c
@@ -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);
+ lru = oc_getlru(oc);
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);
+ lru = oc_getlru(oc);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
if (Lck_Trylock(&exp_mtx))
diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c
index 8e0ee36..ae0e634 100644
--- a/bin/varnishd/stevedore.c
+++ b/bin/varnishd/stevedore.c
@@ -283,19 +283,6 @@ 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)
{
@@ -341,9 +328,19 @@ default_oc_freeobj(struct objcore *oc)
STV_free(o->objstore);
}
+static struct lru *
+default_oc_getlru(const struct objcore *oc)
+{
+ struct object *o;
+
+ CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
+ return (o->objstore->stevedore->lru);
+}
+
struct objcore_methods default_oc_methods = {
.getobj = default_oc_getobj,
.freeobj = default_oc_freeobj,
+ .getlru = default_oc_getlru,
};
/*-------------------------------------------------------------------*/
@@ -402,17 +399,6 @@ STV_close(void)
stv->close(stv);
}
-struct lru *
-STV_lru(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);
- AN(o->objstore->stevedore->getlru);
-
- return (o->objstore->stevedore->getlru(o));
-}
-
/*--------------------------------------------------------------------
* Parse a stevedore argument on the form:
* [ name '=' ] strategy [ ',' arg ] *
@@ -475,8 +461,6 @@ 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++);
diff --git a/bin/varnishd/stevedore.h b/bin/varnishd/stevedore.h
index 3951050..86da7ee 100644
--- a/bin/varnishd/stevedore.h
+++ b/bin/varnishd/stevedore.h
@@ -43,7 +43,6 @@ 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 */
@@ -59,7 +58,6 @@ 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; /* --//-- */
@@ -88,7 +86,6 @@ 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 object *o);
void STV_Config(const char *spec);
void STV_Config_Transient(void);
void STV_Freestore(struct object *o);
diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c
index 1ae9e80..1c25e85 100644
--- a/bin/varnishd/storage_persistent.c
+++ b/bin/varnishd/storage_persistent.c
@@ -66,7 +66,7 @@ SVNID("$Id$")
static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos);
/*--------------------------------------------------------------------
- * Add a new ban to all silos
+ * Add bans to silos
*/
static void
@@ -96,6 +96,8 @@ smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, double t0,
smp_append_sign(ctx, ptr2, ptr - ptr2);
}
+/* Trust that cache_ban.c takes care of locking */
+
void
SMP_NewBan(double t0, const char *ban)
{
@@ -165,8 +167,6 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx)
return (retval);
}
-
-
/*--------------------------------------------------------------------
* Attempt to open and read in a segment list
*/
@@ -468,20 +468,6 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
}
/*--------------------------------------------------------------------
- * 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
*/
@@ -575,24 +561,6 @@ smp_free(struct storage *st)
(void)st;
}
-/*--------------------------------------------------------------------
- * Pause until all silos have loaded.
- */
-
-void
-SMP_Ready(void)
-{
- struct smp_sc *sc;
-
- ASSERT_CLI();
- do {
- VTAILQ_FOREACH(sc, &silos, list)
- if (!(sc->flags & SMP_SC_LOADED))
- break;
- if (sc != NULL)
- (void)sleep(1);
- } while (sc != NULL);
-}
/*--------------------------------------------------------------------*/
@@ -604,7 +572,6 @@ const struct stevedore smp_stevedore = {
.close = smp_close,
.alloc = smp_alloc,
.allocobj = smp_allocobj,
- .getlru = smp_getlru,
.free = smp_free,
.trim = smp_trim,
};
@@ -692,8 +659,29 @@ static struct cli_proto debug_cmds[] = {
{ NULL }
};
+/*--------------------------------------------------------------------*/
+
void
SMP_Init(void)
{
CLI_AddFuncs(debug_cmds);
}
+
+/*--------------------------------------------------------------------
+ * Pause until all silos have loaded.
+ */
+
+void
+SMP_Ready(void)
+{
+ struct smp_sc *sc;
+
+ ASSERT_CLI();
+ do {
+ VTAILQ_FOREACH(sc, &silos, list)
+ if (!(sc->flags & SMP_SC_LOADED))
+ break;
+ if (sc != NULL)
+ (void)sleep(1);
+ } while (sc != NULL);
+}
diff --git a/bin/varnishd/storage_persistent_silo.c b/bin/varnishd/storage_persistent_silo.c
index 480474e..defb3d0 100644
--- a/bin/varnishd/storage_persistent_silo.c
+++ b/bin/varnishd/storage_persistent_silo.c
@@ -503,10 +503,24 @@ smp_oc_freeobj(struct objcore *oc)
Lck_Unlock(&sg->sc->mtx);
}
+/*--------------------------------------------------------------------
+ * Find the per-segment lru list for this object
+ */
+
+static struct lru *
+smp_oc_getlru(const struct objcore *oc)
+{
+ struct smp_seg *sg;
+
+ CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
+ return (sg->lru);
+}
+
static struct objcore_methods smp_oc_methods = {
.getobj = smp_oc_getobj,
.updatemeta = smp_oc_updatemeta,
.freeobj = smp_oc_freeobj,
+ .getlru = smp_oc_getlru,
};
/*--------------------------------------------------------------------*/
More information about the varnish-commit
mailing list