[master] f7e2c15 Reintegrate struct body into struct object.

Poul-Henning Kamp phk at FreeBSD.org
Mon Sep 15 21:07:46 CEST 2014


commit f7e2c15615bd35e20f35c4050f6a2295210b0502
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Sep 15 19:07:31 2014 +0000

    Reintegrate struct body into struct object.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 75c4bdc..86f3c34 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -104,7 +104,6 @@ enum {
 struct SHA256Context;
 struct VSC_C_lck;
 struct ban;
-struct body;
 struct busyobj;
 struct cli;
 struct cli_proto;
@@ -391,7 +390,7 @@ struct lru {
 struct storeobj {
 	unsigned		magic;
 #define STOREOBJ_MAGIC		0x6faed850
-	const struct stevedore	*stevedore;
+	struct stevedore	*stevedore;
 	void			*priv;
 	uintptr_t		priv2;
 };
@@ -534,12 +533,6 @@ struct busyobj {
 
 VTAILQ_HEAD(storagehead, storage);
 
-struct body {
-	struct stevedore	*stevedore;
-	struct storagehead	list;
-	ssize_t			len;
-};
-
 enum obj_attr {
 #define OBJ_ATTR(U, l)	OA_##U,
 #include "tbl/obj_attr.h"
@@ -564,7 +557,9 @@ struct object {
 	char			oa_gzipbits[24];
 	char			oa_lastmodified[8];
 
-	struct body		body[1];
+	// struct stevedore	*stevedore;
+	struct storagehead	list;
+	ssize_t			len;
 
 	struct storage		*esidata;
 };
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index f57bd0b..81e65cf 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -116,7 +116,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
 
 	if (oi->bo == NULL) {
 		if (oi->st == NULL)
-			oi->st = VTAILQ_FIRST(&oi->obj->body->list);
+			oi->st = VTAILQ_FIRST(&oi->obj->list);
 		else
 			oi->st = VTAILQ_NEXT(oi->st, list);
 		while(oi->st != NULL && oi->st->len == 0)
@@ -140,8 +140,8 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
 				return (OIS_ERROR);
 		}
 		Lck_Lock(&oi->bo->mtx);
-		AZ(VTAILQ_EMPTY(&oi->obj->body->list));
-		VTAILQ_FOREACH(oi->st, &oi->obj->body->list, list) {
+		AZ(VTAILQ_EMPTY(&oi->obj->list));
+		VTAILQ_FOREACH(oi->st, &oi->obj->list, list) {
 			if (oi->st->len > ol) {
 				*p = oi->st->ptr + ol;
 				*l = oi->st->len - ol;
@@ -231,7 +231,7 @@ ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds,
 	o = obj_getobj(oc, ds);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 
-	st = VTAILQ_LAST(&o->body->list, storagehead);
+	st = VTAILQ_LAST(&o->list, storagehead);
 	if (st != NULL && st->len < st->space) {
 		*sz = st->space - st->len;
 		*ptr = st->ptr + st->len;
@@ -239,17 +239,17 @@ ObjGetSpace(struct objcore *oc, struct vsl_log *vsl, struct dstat *ds,
 		return (1);
 	}
 
-	st = objallocwithnuke(o->body->stevedore, vsl, ds, *sz);
+	st = objallocwithnuke(oc->stobj->stevedore, vsl, ds, *sz);
 	if (st == NULL)
 		return (0);
 
 	if (oc->busyobj != NULL) {
 		CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC);
 		Lck_Lock(&oc->busyobj->mtx);
-		VTAILQ_INSERT_TAIL(&o->body->list, st, list);
+		VTAILQ_INSERT_TAIL(&o->list, st, list);
 		Lck_Unlock(&oc->busyobj->mtx);
 	} else {
-		VTAILQ_INSERT_TAIL(&o->body->list, st, list);
+		VTAILQ_INSERT_TAIL(&o->list, st, list);
 	}
 	*sz = st->space - st->len;
 	assert (*sz > 0);
@@ -269,11 +269,11 @@ ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l)
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	o = obj_getobj(oc, ds);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	st = VTAILQ_LAST(&o->body->list, storagehead);
+	st = VTAILQ_LAST(&o->list, storagehead);
 	CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
 	assert(st->len + l <= st->space);
 	st->len += l;
-	o->body->len += l;
+	o->len += l;
 }
 
 /*--------------------------------------------------------------------
@@ -292,11 +292,11 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds)
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
 	o = obj_getobj(oc, ds);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	st = VTAILQ_LAST(&o->body->list, storagehead);
+	st = VTAILQ_LAST(&o->list, storagehead);
 	if (st == NULL)
 		return;
 	if (st->len == 0) {
-		VTAILQ_REMOVE(&o->body->list, st, list);
+		VTAILQ_REMOVE(&o->list, st, list);
 		STV_free(st);
 	} else if (st->len < st->space) {
 		STV_trim(st, st->len, 1);
@@ -322,9 +322,9 @@ ObjSlim(struct objcore *oc, struct dstat *ds)
 		STV_free(o->esidata);
 		o->esidata = NULL;
 	}
-	VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) {
+	VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) {
 		CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
-		VTAILQ_REMOVE(&o->body->list, st, list);
+		VTAILQ_REMOVE(&o->list, st, list);
 		STV_free(st);
 	}
 }
@@ -418,7 +418,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len,
 	st = o->objstore;
 	switch (attr) {
 	case OA_ESIDATA:
-		o->esidata = objallocwithnuke(o->body->stevedore, vc->vsl,
+		o->esidata = objallocwithnuke(vc->oc->stobj->stevedore, vc->vsl,
 		    vc->stats, len);
 		if (o->esidata == NULL)
 			return (NULL);
@@ -498,7 +498,7 @@ ObjGetLen(struct objcore *oc, struct dstat *ds)
 
 	o = obj_getobj(oc, ds);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	return (o->body->len);
+	return (o->len);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 2a5e692..11c8828 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -202,11 +202,10 @@ STV_MkObject(struct stevedore *stv, struct objcore *oc, void *ptr)
 	memset(o, 0, sizeof *o);
 	o->magic = OBJECT_MAGIC;
 
-	VTAILQ_INIT(&o->body->list);
+	VTAILQ_INIT(&o->list);
 
 	oc->stobj->magic = STOREOBJ_MAGIC;
 	oc->stobj->stevedore = stv;
-	o->body->stevedore = stv;
 	AN(stv->methods);
 	oc->stobj->priv = o;
 	oc->stobj->priv2 = (uintptr_t)stv;
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 440446a..190843f 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -432,13 +432,13 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 
 		bad = 0;
 		l = 0;
-		VTAILQ_FOREACH(st, &o->body->list, list) {
+		VTAILQ_FOREACH(st, &o->list, list) {
 			bad |= smp_loaded_st(sg->sc, sg, st);
 			if (bad)
 				break;
 			l += st->len;
 		}
-		if (l != o->body->len)
+		if (l != o->len)
 			bad |= 0x100;
 
 		if(bad) {



More information about the varnish-commit mailing list