[PATCH] Only add size of struct object when using default storeobj_methods

Martin Blix Grydeland martin at varnish-software.com
Tue Sep 22 16:09:22 CEST 2015


---
 bin/varnishd/storage/stevedore.c          | 14 ++++++--------
 bin/varnishd/storage/storage_persistent.c |  4 +++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 77a601c..0929ba8 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -219,12 +219,14 @@ STV_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr)
 
 int
 stv_default_allocobj(const struct stevedore *stv, struct objcore *oc,
-    unsigned ltot)
+    unsigned wsl)
 {
 	struct object *o;
 	struct storage *st;
+	unsigned ltot;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	ltot = sizeof(struct object) + PRNDUP(wsl);
 	st = stv->alloc(stv, ltot);
 	if (st == NULL)
 		return (0);
@@ -250,24 +252,20 @@ STV_NewObject(struct objcore *oc, struct worker *wrk,
     const char *hint, unsigned wsl)
 {
 	struct stevedore *stv, *stv0;
-	unsigned ltot;
 	int i, j;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	assert(wsl > 0);
-	wsl = PRNDUP(wsl);
-
-	ltot = sizeof(struct object) + wsl;
 
 	stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint);
 	AN(stv->allocobj);
-	j = stv->allocobj(stv, oc, ltot);
+	j = stv->allocobj(stv, oc, wsl);
 	if (j == 0 && hint == NULL) {
 		do {
 			stv = stv_pick_stevedore(wrk->vsl, &hint);
 			AN(stv->allocobj);
-			j = stv->allocobj(stv, oc, ltot);
+			j = stv->allocobj(stv, oc, wsl);
 		} while (j == 0 && stv != stv0);
 	}
 	if (j == 0) {
@@ -275,7 +273,7 @@ STV_NewObject(struct objcore *oc, struct worker *wrk,
 		for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) {
 			if (EXP_NukeOne(wrk, stv->lru) == -1)
 				break;
-			j = stv->allocobj(stv, oc, ltot);
+			j = stv->allocobj(stv, oc, wsl);
 		}
 	}
 
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 160cc35..2679675 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -502,7 +502,7 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size,
  */
 
 static int
-smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
+smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned wsl)
 {
 	struct object *o;
 	struct storage *st;
@@ -510,6 +510,7 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
 	struct smp_seg *sg;
 	struct smp_object *so;
 	unsigned objidx;
+	unsigned ltot;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
@@ -518,6 +519,7 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned ltot)
 	if ((oc->exp.ttl + oc->exp.grace + oc->exp.keep) <= 0.)
 		return (0);
 
+	ltot = sizeof(struct object) + PRNDUP(wsl);
 	ltot = IRNUP(sc, ltot);
 
 	st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg);
-- 
2.1.4




More information about the varnish-dev mailing list