[master] bc2f3f0 Get object/objcore unref events sent through to the stevedore (via objcore method) and refer resultant empty persistant segments.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Feb 7 19:03:45 CET 2011
commit bc2f3f06764bec1aca49a0d21929838646bbcb3a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Feb 7 18:02:36 2011 +0000
Get object/objcore unref events sent through to the stevedore
(via objcore method) and refer resultant empty persistant segments.
diff --git a/bin/varnishd/cache_expire.c b/bin/varnishd/cache_expire.c
index f2f2ea4..bc791f1 100644
--- a/bin/varnishd/cache_expire.c
+++ b/bin/varnishd/cache_expire.c
@@ -239,7 +239,6 @@ static void * __match_proto__(void *start_routine(void *))
exp_timer(struct sess *sp, void *priv)
{
struct objcore *oc;
- struct object *o;
double t;
(void)priv;
@@ -282,20 +281,7 @@ exp_timer(struct sess *sp, void *priv)
VSC_main->n_expired++;
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
- if (oc->methods == &default_oc_methods) {
- o = oc_getobj(sp->wrk, oc);
- AN(o);
- WSL(sp->wrk, SLT_ExpKill, 0, "%u %d",
- o->xid, (int)(o->ttl - t));
- (void)HSH_Deref(sp->wrk, NULL, &o);
- } else {
- WSL(sp->wrk, SLT_ExpKill, 1, "-1 %d",
- (int)(oc->timer_when - t));
-
- oc->priv = NULL;
- AZ(HSH_Deref(sp->wrk, oc, NULL));
- sp->wrk->stats.n_vampireobject--;
- }
+ (void)HSH_Deref(sp->wrk, oc, NULL);
}
NEEDLESS_RETURN(NULL);
}
diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c
index 02f9016..a33bf5e 100644
--- a/bin/varnishd/cache_hash.c
+++ b/bin/varnishd/cache_hash.c
@@ -648,65 +648,61 @@ HSH_Ref(struct objcore *oc)
int
HSH_Deref(struct worker *w, struct objcore *oc, struct object **oo)
{
- struct object *o;
- struct objhead *oh = NULL;
+ struct object *o = NULL;
+ struct objhead *oh;
unsigned r;
- if (oc != NULL) {
- AZ(oo);
- o = NULL;
- AZ(oc->priv); // XXX: for now
- } else {
- AZ(oc);
- AN(oo);
+ /* Only one arg at a time */
+ assert(oc == NULL || oo == NULL);
+
+ if (oo != NULL) {
o = *oo;
*oo = NULL;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
}
- if (oc != NULL) {
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- oh = oc->objhead;
- CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
-
- Lck_Lock(&oh->mtx);
- assert(oh->refcnt > 0);
- assert(oc->refcnt > 0);
- r = --oc->refcnt;
- if (!r)
- VTAILQ_REMOVE(&oh->objcs, oc, list);
- if (oc->flags & OC_F_BUSY)
- hsh_rush(oh);
- Lck_Unlock(&oh->mtx);
- if (r != 0)
- return (r);
+ if (o != NULL && oc == NULL) {
+ /*
+ * A pass object with neither objcore nor objhdr reference.
+ * -> simply free the (Transient) storage
+ */
+ STV_Freestore(o);
+ STV_free(o->objstore);
+ w->stats.n_object--;
+ return (0);
}
- if (oc != NULL) {
- BAN_DestroyObj(oc);
- AZ(oc->ban);
- }
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- if (o != NULL) {
- DSL(0x40, SLT_Debug, 0, "Object %u workspace min free %u",
- o->xid, WS_Free(o->ws_o));
+ oh = oc->objhead;
+ CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
- if (oc != NULL)
- oc_freeobj(oc);
- else {
- STV_Freestore(o);
- STV_free(o->objstore);
- o = NULL;
- }
- w->stats.n_object--;
+ Lck_Lock(&oh->mtx);
+ assert(oh->refcnt > 0);
+ assert(oc->refcnt > 0);
+ r = --oc->refcnt;
+ if (!r)
+ VTAILQ_REMOVE(&oh->objcs, oc, list);
+ else {
+ /* Must have an object */
+ AN(oc->methods);
}
+ if (oc->flags & OC_F_BUSY)
+ hsh_rush(oh);
+ Lck_Unlock(&oh->mtx);
+ if (r != 0)
+ return (r);
- if (oc == NULL)
- return (0);
+ BAN_DestroyObj(oc);
+ AZ(oc->ban);
- AN(oh);
+ if (oc->methods != NULL) {
+ oc_freeobj(oc);
+ w->stats.n_object--;
+ }
FREE_OBJ(oc);
+
w->stats.n_objectcore--;
/* Drop our ref on the objhead */
assert(oh->refcnt > 0);
diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c
index ceae27d..9a45cf3 100644
--- a/bin/varnishd/storage_persistent.c
+++ b/bin/varnishd/storage_persistent.c
@@ -774,16 +774,13 @@ smp_oc_updatemeta(struct objcore *oc)
}
}
-static void
+static void __match_proto__()
smp_oc_freeobj(struct objcore *oc)
{
struct smp_seg *sg;
- struct object *o;
struct smp_object *so;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- o = smp_oc_getobj(NULL, oc);
- AN(o);
CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
so = smp_find_so(sg, oc);
More information about the varnish-commit
mailing list