[master] 35a9e75 Push busyobj further backwards

Poul-Henning Kamp phk at FreeBSD.org
Mon Sep 15 14:20:47 CEST 2014


commit 35a9e755c64b717b5c61d4cda5b24a24dd2a6bc9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 15 12:20:33 2014 +0000

    Push busyobj further backwards

diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index fa84d56..9f42422 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -189,13 +189,12 @@ STV_alloc(struct stevedore *stv, size_t size)
  */
 
 struct object *
-STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
+STV_MkObject(struct stevedore *stv, struct objcore *oc, void *ptr)
 {
 	struct object *o;
 
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	assert(PAOK(ptr));
 
@@ -205,13 +204,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
 
 	VTAILQ_INIT(&o->body->list);
 
-	bo->fetch_objcore->stobj->magic = STOREOBJ_MAGIC;
-	bo->fetch_objcore->stobj->stevedore = stv;
+	oc->stobj->magic = STOREOBJ_MAGIC;
+	oc->stobj->stevedore = stv;
 	o->body->stevedore = stv;
 	AN(stv->methods);
-	bo->fetch_objcore->stobj->priv = o;
-	bo->fetch_objcore->stobj->priv2 = (uintptr_t)stv;
-	VSLb(bo->vsl, SLT_Storage, "%s %s", stv->name, stv->ident);
+	oc->stobj->priv = o;
+	oc->stobj->priv2 = (uintptr_t)stv;
 	return (o);
 }
 
@@ -221,12 +219,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
  */
 
 struct object *
-stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
+stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
 {
 	struct object *o;
 	struct storage *st;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	st = stv->alloc(stv, ltot);
 	if (st == NULL)
 		return (NULL);
@@ -234,11 +232,10 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
 		stv->free(st);
 		return (NULL);
 	}
-	o = STV_MkObject(stv, bo, st->ptr);
+	o = STV_MkObject(stv, oc, st->ptr);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	st->len = sizeof(*o);
 	o->objstore = st;
-	bo->stats->n_object++;
 	return (o);
 }
 
@@ -252,12 +249,14 @@ int
 STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
 {
 	struct object *o;
+	struct objcore *oc;
 	struct stevedore *stv, *stv0;
 	unsigned ltot;
 	int i;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-	CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
+	oc = bo->fetch_objcore;
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	assert(wsl > 0);
 	wsl = PRNDUP(wsl);
 
@@ -265,12 +264,12 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
 
 	stv = stv0 = stv_pick_stevedore(bo->vsl, &hint);
 	AN(stv->allocobj);
-	o = stv->allocobj(stv, bo, ltot);
+	o = stv->allocobj(stv, oc, ltot);
 	if (o == NULL && hint == NULL) {
 		do {
 			stv = stv_pick_stevedore(bo->vsl, &hint);
 			AN(stv->allocobj);
-			o = stv->allocobj(stv, bo, ltot);
+			o = stv->allocobj(stv, oc, ltot);
 		} while (o == NULL && stv != stv0);
 	}
 	if (o == NULL) {
@@ -278,13 +277,16 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
 		for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) {
 			if (EXP_NukeOne(bo->vsl, bo->stats, stv->lru) == -1)
 				break;
-			o = stv->allocobj(stv, bo, ltot);
+			o = stv->allocobj(stv, oc, ltot);
 		}
 	}
 
 	if (o == NULL)
 		return (0);
 
+	bo->stats->n_object++;
+	VSLb(bo->vsl, SLT_Storage, "%s %s",
+	    oc->stobj->stevedore->name, oc->stobj->stevedore->ident);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	CHECK_OBJ_NOTNULL(o->objstore, STORAGE_MAGIC);
 	AN(stv->methods);
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 95d8eae..5108e47 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -61,7 +61,7 @@ typedef void storage_open_f(const struct stevedore *);
 typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
 typedef void storage_trim_f(struct storage *, size_t size, int move_ok);
 typedef void storage_free_f(struct storage *);
-typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *,
+typedef struct object *storage_allocobj_f(struct stevedore *, struct objcore *,
     unsigned ltot);
 typedef void storage_close_f(const struct stevedore *);
 typedef void storage_signal_close_f(const struct stevedore *);
@@ -122,8 +122,7 @@ extern struct stevedore *stv_transient;
 int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx);
 uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity,
     const char *ctx);
-struct object *STV_MkObject(struct stevedore *stv, struct busyobj *bo,
-    void *ptr);
+struct object *STV_MkObject(struct stevedore *, struct objcore *, void *ptr);
 
 struct lru *LRU_Alloc(void);
 void LRU_Free(struct lru *lru);
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index f85dc12..037d23b 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -505,23 +505,20 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
  */
 
 static struct object *
-smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
+smp_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
 {
 	struct object *o;
 	struct storage *st;
 	struct smp_sc	*sc;
 	struct smp_seg *sg;
 	struct smp_object *so;
-	struct objcore *oc;
 	unsigned objidx;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
 
 	/* Don't entertain already dead objects */
-	if ((bo->fetch_objcore->exp.ttl +
-	     bo->fetch_objcore->exp.grace +
-	     bo->fetch_objcore->exp.keep) <= 0.)
+	if ((oc->exp.ttl + oc->exp.grace + oc->exp.keep) <= 0.)
 		return (NULL);
 
 	ltot = IRNUP(sc, ltot);
@@ -532,16 +529,12 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
 
 	assert(st->space >= ltot);
 
-	o = STV_MkObject(stv, bo, st->ptr);
-	AN(bo->fetch_objcore->stobj->stevedore);
-	assert(bo->fetch_objcore->stobj->stevedore == stv);
+	o = STV_MkObject(stv, oc, st->ptr);
+	AN(oc->stobj->stevedore);
+	assert(oc->stobj->stevedore == stv);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	o->objstore = st;
 	st->len = sizeof(*o);
-	bo->stats->n_object++;
-
-	oc = bo->fetch_objcore;
-	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	Lck_Lock(&sc->mtx);
 	sg->nfixed++;
@@ -550,7 +543,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
 	/* We have to do this somewhere, might as well be here... */
 	assert(sizeof so->hash == DIGEST_LEN);
 	memcpy(so->hash, oc->objhead->digest, DIGEST_LEN);
-	so->exp = bo->fetch_objcore->exp;
+	so->exp = oc->exp;
 	so->ptr = (uint8_t*)o - sc->base;
 	so->ban = BAN_Time(oc->ban);
 



More information about the varnish-commit mailing list