[master] cc5380f Reduce the amount of magic for persistent stevedores.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Feb 5 22:21:09 CET 2016
commit cc5380f2add34e2577d5339470a43e087bb6ed6e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Feb 5 21:20:37 2016 +0000
Reduce the amount of magic for persistent stevedores.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 5e9d30d..33c40ed 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -682,7 +682,6 @@ void EXP_Clr(struct exp *e);
double EXP_Ttl(const struct req *, const struct exp*);
double EXP_When(const struct exp *exp);
void EXP_Insert(struct worker *wrk, struct objcore *oc);
-void EXP_Inject(struct worker *wrk, struct objcore *oc);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep);
void EXP_Poke(struct objcore *);
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index d60900c..06db2d7 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -167,30 +167,6 @@ EXP_Poke(struct objcore *oc)
}
/*--------------------------------------------------------------------
- * Inject an object with a reference into the binheap.
- *
- * This can either come from a stevedore (persistent) during startup
- * or from EXP_Insert() below.
- */
-
-void
-EXP_Inject(struct worker *wrk, struct objcore *oc)
-{
-
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-
- AZ(oc->exp_flags & (OC_EF_INSERT | OC_EF_MOVE));
- AZ(oc->flags & OC_F_DYING);
- AZ(oc->flags & OC_F_BUSY);
-
- oc->timer_when = EXP_When(&oc->exp);
-
- exp_event(wrk, oc, EXP_INJECT);
- exp_mail_it(oc, OC_EF_INSERT | OC_EF_EXP);
-}
-
-/*--------------------------------------------------------------------
* Insert new object.
*
* We grab a reference to the object, which will keep it around until
@@ -203,11 +179,11 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- HSH_Ref(oc);
AZ(oc->exp_flags & (OC_EF_INSERT | OC_EF_MOVE));
AZ(oc->flags & OC_F_DYING);
- AN(oc->flags & OC_F_BUSY);
+
+ HSH_Ref(oc);
exp_event(wrk, oc, EXP_INSERT);
exp_mail_it(oc, OC_EF_INSERT | OC_EF_EXP | OC_EF_MOVE);
@@ -352,7 +328,7 @@ exp_expire(struct exp_priv *ep, double now)
if (oc == NULL)
return (now + 355./113.);
VSLb(&ep->vsl, SLT_ExpKill, "EXP_expire p=%p e=%.9f f=0x%x", oc,
- oc->timer_when, oc->flags);
+ oc->timer_when - now, oc->flags);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index b9bff87..11714f9 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -273,7 +273,6 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc)
assert(oh->refcnt > 0);
/* Insert (precreated) objcore in objecthead */
- oc->refcnt = 1;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AZ(oc->flags & OC_F_BUSY);
@@ -745,6 +744,7 @@ HSH_DerefBoc(struct worker *wrk, struct objcore *oc)
boc = oc->boc;
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
Lck_Lock(&oc->objhead->mtx);
+ assert(oc->refcnt > 0);
assert(boc->refcount > 0);
r = --boc->refcount;
if (r == 0)
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 0c7c8ec..deb1340 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -165,13 +165,15 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
smp_init_oc(oc, sg, no);
oc->stobj->priv2 |= NEED_FIXUP;
oc->ban = BAN_RefBan(oc, so->ban);
- HSH_Insert(wrk, so->hash, oc);
oc->exp = so->exp;
sg->nobj++;
- EXP_Inject(wrk, oc);
+ oc->refcnt++;
+ HSH_Insert(wrk, so->hash, oc);
+ EXP_Insert(wrk, oc);
AN(isnan(oc->last_lru));
HSH_DerefBoc(wrk, oc); // XXX Keep it an stream resurrection?
AZ(isnan(oc->last_lru));
+ (void)HSH_DerefObjCore(wrk, &oc);
}
Pool_Sumstat(wrk);
sg->flags |= SMP_SEG_LOADED;
@@ -457,17 +459,14 @@ smp_oc_sml_getobj(struct worker *wrk, struct objcore *oc)
return (o);
}
-static void
+static void __match_proto__(objupdatemeta_f)
smp_oc_objupdatemeta(struct worker *wrk, struct objcore *oc)
{
- struct object *o;
struct smp_seg *sg;
struct smp_object *so;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- o = smp_oc_sml_getobj(wrk, oc);
- AN(o);
CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC);
CHECK_OBJ_NOTNULL(sg->sc, SMP_SC_MAGIC);
diff --git a/bin/varnishtest/tests/p00005.vtc b/bin/varnishtest/tests/p00005.vtc
index 55bc6c9..de6f3c3 100644
--- a/bin/varnishtest/tests/p00005.vtc
+++ b/bin/varnishtest/tests/p00005.vtc
@@ -52,6 +52,8 @@ varnish v1 -vcl+backend {
delay 5
+varnish v1 -expect n_object == 0
+
logexpect l1 -v v1 -g vxid -q "Begin ~ bereq" {
expect * 1002 Storage "persistent s0"
} -start
More information about the varnish-commit
mailing list