[master] aa45a21 Make the persistent stevedore responsible for finding space for the "NEED_FIXUP" flag in the space dedicated for private bits.

Poul-Henning Kamp phk at FreeBSD.org
Thu Aug 21 21:58:20 CEST 2014


commit aa45a2144ccb54754ffde9128bba49e79eba5dfe
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Aug 21 19:57:47 2014 +0000

    Make the persistent stevedore responsible for finding space for
    the "NEED_FIXUP" flag in the space dedicated for private bits.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 27a0e1b..4939941 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -400,7 +400,6 @@ struct objcore {
 	uint16_t		flags;
 #define OC_F_BUSY		(1<<1)
 #define OC_F_PASS		(1<<2)
-#define OC_F_PRIV		(1<<5)		/* Stevedore private flag */
 #define OC_F_PRIVATE		(1<<8)
 #define OC_F_FAILED		(1<<9)
 
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index 68f969d..b35bd92 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -153,8 +153,6 @@ struct smp_object {
 #define ASSERT_SILO_THREAD(sc) \
     do {assert(pthread_equal(pthread_self(), (sc)->thread));} while (0)
 
-#define OC_F_NEEDFIXUP OC_F_PRIV
-
 /*
  * Context for a signature.
  *
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 472453f..40b3dc3 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -47,6 +47,13 @@
 
 #include "storage/storage_persistent.h"
 
+/*
+ * We use the low bit to mark objects still needing fixup
+ * In theory this may need to be platform dependent
+ */
+
+#define NEED_FIXUP	(1U << 31)
+
 /*--------------------------------------------------------------------
  * Write the segmentlist back to the silo.
  *
@@ -152,10 +159,10 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
 			continue;
 		ALLOC_OBJ(oc, OBJCORE_MAGIC);
 		AN(oc);
-		oc->flags |= OC_F_NEEDFIXUP;
 		oc->flags &= ~OC_F_BUSY;
 		oc->stevedore = sc->parent;
 		smp_init_oc(oc, sg, no);
+		oc->priv2 |= NEED_FIXUP;
 		oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
 		HSH_Insert(wrk, so->hash, oc);
 		oc->exp = so->exp;
@@ -321,6 +328,7 @@ smp_find_so(const struct smp_seg *sg, unsigned priv2)
 {
 	struct smp_object *so;
 
+	priv2 &= ~NEED_FIXUP;
 	assert(priv2 > 0);
 	assert(priv2 <= sg->p.lobjlist);
 	so = &sg->objs[sg->p.lobjlist - priv2];
@@ -394,7 +402,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	if (ds == NULL)
-		AZ(oc->flags & OC_F_NEEDFIXUP);
+		AZ(oc->priv2 & NEED_FIXUP);
 
 	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
 	so = smp_find_so(sg, oc->priv2);
@@ -413,13 +421,13 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 	 * If this flag is not set, it will not be, and the lock is not
 	 * needed to test it.
 	 */
-	if (!(oc->flags & OC_F_NEEDFIXUP))
+	if (!(oc->priv2 & NEED_FIXUP))
 		return (o);
 
 	AN(ds);
 	Lck_Lock(&sg->sc->mtx);
 	/* Check again, we might have raced. */
-	if (oc->flags & OC_F_NEEDFIXUP) {
+	if (oc->priv2 & NEED_FIXUP) {
 		/* We trust caller to have a refcnt for us */
 		o->objcore = oc;
 
@@ -442,7 +450,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 		sg->nfixed++;
 		ds->n_object++;
 		ds->n_vampireobject--;
-		oc->flags &= ~OC_F_NEEDFIXUP;
+		oc->priv2 &= ~NEED_FIXUP;
 	}
 	Lck_Unlock(&sg->sc->mtx);
 	EXP_Rearm(oc, NAN, NAN, NAN, NAN);	// XXX: Shouldn't be needed
@@ -494,7 +502,7 @@ smp_oc_freeobj(struct dstat *ds, struct objcore *oc)
 
 	assert(sg->nobj > 0);
 	sg->nobj--;
-	if (oc->flags & OC_F_NEEDFIXUP) {
+	if (oc->priv2 & NEED_FIXUP) {
 		ds->n_vampireobject--;
 	} else {
 		assert(sg->nfixed > 0);
@@ -531,6 +539,7 @@ void
 smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx)
 {
 
+	AZ(objidx & NEED_FIXUP);
 	oc->priv = sg;
 	oc->priv2 = objidx;
 }



More information about the varnish-commit mailing list