[master] 7f698ad Wrap the list of storage segments in a "struct body"

Poul-Henning Kamp phk at FreeBSD.org
Tue Jul 15 12:51:14 CEST 2014


commit 7f698adeb7e7c9d88f5d3f60f54877ec46090d88
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 15 10:50:52 2014 +0000

    Wrap the list of storage segments in a "struct body"

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index b8ca57f..cc91eae 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -537,6 +537,11 @@ struct busyobj {
 
 VTAILQ_HEAD(storagehead, storage);
 
+struct body {
+	struct stevedore	*stevedore;
+	struct storagehead	list;
+};
+
 struct object {
 	unsigned		magic;
 #define OBJECT_MAGIC		0x32851d42
@@ -561,7 +566,7 @@ struct object {
 
 	struct http		*http;
 
-	struct storagehead	store;
+	struct body		body[1];
 
 	struct storage		*esidata;
 
@@ -585,7 +590,7 @@ struct req {
 	VTAILQ_ENTRY(req)	w_list;
 
 	volatile enum req_body_state_e	req_body_status;
-	struct storagehead	body;
+	struct body		body[1];
 
 	struct {
 		ssize_t			bytes_done;
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index f4b4296..d0ec1d2 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -228,7 +228,7 @@ VBO_extend(struct busyobj *bo, ssize_t l)
 		return;
 	assert(l > 0);
 	Lck_Lock(&bo->mtx);
-	st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
+	st = VTAILQ_LAST(&bo->fetch_obj->body->list, storagehead);
 	CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
 	st->len += l;
 	bo->fetch_obj->len += l;
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 924a22a..19326e9 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -309,7 +309,7 @@ ESI_Deliver(struct req *req)
 		AZ(dl);
 	}
 
-	st = VTAILQ_FIRST(&req->obj->store);
+	st = VTAILQ_FIRST(&req->obj->body->list);
 	off = 0;
 
 	while (p < e) {
@@ -467,7 +467,7 @@ ved_deliver_byterange(struct req *req, ssize_t low, ssize_t high)
 	u_char *p;
 
 	lx = 0;
-	VTAILQ_FOREACH(st, &req->obj->store, list) {
+	VTAILQ_FOREACH(st, &req->obj->body->list, list) {
 		p = st->ptr;
 		l = st->len;
 		if (lx + l < low) {
@@ -509,7 +509,7 @@ ESI_DeliverChild(struct req *req)
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	if (!req->obj->gziped) {
-		VTAILQ_FOREACH(st, &req->obj->store, list)
+		VTAILQ_FOREACH(st, &req->obj->body->list, list)
 			ved_pretend_gzip(req, st->ptr, st->len);
 		return;
 	}
@@ -588,7 +588,7 @@ ESI_DeliverChild(struct req *req)
 		req->resp_bodybytes += WRW_Write(req->wrk, dbits + 1, lpad);
 
 	/* We need the entire tail, but it may not be in one storage segment */
-	st = VTAILQ_LAST(&req->obj->store, storagehead);
+	st = VTAILQ_LAST(&req->obj->body->list, storagehead);
 	for (i = sizeof tailbuf; i > 0; i -= j) {
 		j = st->len;
 		if (j > i)
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 32cd3da..8f967e2 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -826,7 +826,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
 			struct storage *st;
 
 			uu = 0;
-			VTAILQ_FOREACH(st, &bo->fetch_obj->store, list)
+			VTAILQ_FOREACH(st, &bo->fetch_obj->body->list, list)
 				uu += st->len;
 			if (bo->do_stream)
 				/* Streaming might have started freeing stuff */
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index a49a58a..80952c7 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -84,7 +84,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	obj = bo->fetch_obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
-	st = VTAILQ_LAST(&obj->store, storagehead);
+	st = VTAILQ_LAST(&obj->body->list, storagehead);
 	if (st != NULL && st->len < st->space)
 		return (st);
 
@@ -100,7 +100,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz)
 	} else {
 		AZ(st->len);
 		Lck_Lock(&bo->mtx);
-		VTAILQ_INSERT_TAIL(&obj->store, st, list);
+		VTAILQ_INSERT_TAIL(&obj->body->list, st, list);
 		Lck_Unlock(&bo->mtx);
 	}
 	return (st);
@@ -233,12 +233,13 @@ VFP_Fetch_Body(struct busyobj *bo)
 		}
 
 		CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
-		assert(st == VTAILQ_LAST(&bo->fetch_obj->store, storagehead));
+		assert(st == VTAILQ_LAST(&bo->fetch_obj->body->list,
+		    storagehead));
 		l = st->space - st->len;
 		AZ(bo->failed);
 		vfps = VFP_Suck(&bo->vfc, st->ptr + st->len, &l);
 		if (l > 0 && vfps != VFP_ERROR) {
-			AZ(VTAILQ_EMPTY(&bo->fetch_obj->store));
+			AZ(VTAILQ_EMPTY(&bo->fetch_obj->body->list));
 			VBO_extend(bo, l);
 		}
 		if (st->len == st->space)
diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index b6f08be..049ca68 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -548,7 +548,7 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv)
 
 	switch(req->req_body_status) {
 	case REQ_BODY_CACHED:
-		VTAILQ_FOREACH(st, &req->body, list) {
+		VTAILQ_FOREACH(st, &req->body->list, list) {
 			i = func(req, priv, st->ptr, st->len);
 			if (i)
 				return (i);
@@ -677,7 +677,7 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize)
 				l = -1;
 				break;
 			} else {
-				VTAILQ_INSERT_TAIL(&req->body, st, list);
+				VTAILQ_INSERT_TAIL(&req->body->list, st, list);
 			}
 		}
 
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index adb35f6..00d5bc9 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -74,7 +74,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
 
 	if (oi->bo == NULL) {
 		if (oi->st == NULL)
-			oi->st = VTAILQ_FIRST(&oi->obj->store);
+			oi->st = VTAILQ_FIRST(&oi->obj->body->list);
 		else
 			oi->st = VTAILQ_NEXT(oi->st, list);
 		if (oi->st != NULL) {
@@ -95,8 +95,8 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
 				return (OIS_ERROR);
 		}
 		Lck_Lock(&oi->bo->mtx);
-		AZ(VTAILQ_EMPTY(&oi->obj->store));
-		VTAILQ_FOREACH(oi->st, &oi->obj->store, list) {
+		AZ(VTAILQ_EMPTY(&oi->obj->body->list));
+		VTAILQ_FOREACH(oi->st, &oi->obj->body->list, list) {
 			if (oi->st->len > ol) {
 				*p = oi->st->ptr + ol;
 				*l = oi->st->len - ol;
@@ -158,11 +158,11 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds)
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
 	o = ObjGetObj(oc, ds);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	st = VTAILQ_LAST(&o->store, storagehead);
+	st = VTAILQ_LAST(&o->body->list, storagehead);
 	if (st == NULL)
 		return;
 	if (st->len == 0) {
-		VTAILQ_REMOVE(&o->store, st, list);
+		VTAILQ_REMOVE(&o->body->list, st, list);
 		STV_free(st);
 	} else if (st->len < st->space) {
 		STV_trim(st, st->len, 1);
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 88dc9f5..d59333b 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -219,7 +219,7 @@ pan_object(const char *typ, const struct object *o)
 	pan_http("obj", o->http, 4);
 	VSB_printf(pan_vsp, "    len = %jd,\n", (intmax_t)o->len);
 	VSB_printf(pan_vsp, "    store = {\n");
-	VTAILQ_FOREACH(st, &o->store, list)
+	VTAILQ_FOREACH(st, &o->body->list, list)
 		pan_storage(st);
 	VSB_printf(pan_vsp, "    },\n");
 	VSB_printf(pan_vsp, "  },\n");
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 927abc4..ebace03 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -922,9 +922,9 @@ CNT_Request(struct worker *wrk, struct req *req)
 			VSLb(req->vsl, SLT_ESI_BodyBytes, "%ju",
 			    (uintmax_t)req->resp_bodybytes);
 
-		while (!VTAILQ_EMPTY(&req->body)) {
-			st = VTAILQ_FIRST(&req->body);
-			VTAILQ_REMOVE(&req->body, st, list);
+		while (!VTAILQ_EMPTY(&req->body->list)) {
+			st = VTAILQ_FIRST(&req->body->list);
+			VTAILQ_REMOVE(&req->body->list, st, list);
 			STV_free(st);
 		}
 		req->wrk = NULL;
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index c938b98..5b8a843 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -378,7 +378,7 @@ SES_GetReq(struct worker *wrk, struct sess *sp)
 	req->t_prev = NAN;
 	req->t_req = NAN;
 
-	VTAILQ_INIT(&req->body);
+	VTAILQ_INIT(&req->body->list);
 
 	return (req);
 }
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index c9520f8..44ed2b6 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -207,7 +207,7 @@ stv_alloc_obj(struct busyobj *bo, size_t size)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	obj = bo->fetch_obj;
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
-	stv = obj->objstore->stevedore;
+	stv = obj->body->stevedore;
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
 
 	if (size > cache_param->fetch_maxchunksize)
@@ -285,11 +285,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
 
 	HTTP_Setup(o->http, bo->ws_o, bo->vsl, SLT_ObjMethod);
 	o->http->magic = HTTP_MAGIC;
-	VTAILQ_INIT(&o->store);
+	VTAILQ_INIT(&o->body->list);
 
 	o->objcore = bo->fetch_objcore;
 
 	o->objcore->stevedore = stv;
+	o->body->stevedore = stv;
 	AN(stv->methods);
 	o->objcore->priv = o;
 	o->objcore->priv2 = (uintptr_t)stv;
@@ -399,9 +400,9 @@ STV_Freestore(struct object *o)
 		STV_free(o->esidata);
 		o->esidata = NULL;
 	}
-	VTAILQ_FOREACH_SAFE(st, &o->store, list, stn) {
+	VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) {
 		CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
-		VTAILQ_REMOVE(&o->store, st, list);
+		VTAILQ_REMOVE(&o->body->list, st, list);
 		STV_free(st);
 	}
 }
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 5119467..9e747ce 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -454,7 +454,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 
 		bad = 0;
 		l = 0;
-		VTAILQ_FOREACH(st, &o->store, list) {
+		VTAILQ_FOREACH(st, &o->body->list, list) {
 			bad |= smp_loaded_st(sg->sc, sg, st);
 			if (bad)
 				break;



More information about the varnish-commit mailing list