[master] 7816fee More refactoring to make struct worker the default context for Obj*()

Poul-Henning Kamp phk at FreeBSD.org
Tue Sep 16 13:30:43 CEST 2014


commit 7816feec3164b47081ae1df6a64ac8e14f15583d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 16 11:30:20 2014 +0000

    More refactoring to make struct worker the default context for Obj*()

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 57fb42f..74f2d9f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -898,9 +898,9 @@ void http_Unset(struct http *hp, const char *hdr);
 unsigned http_CountHdr(const struct http *hp, const char *hdr);
 void http_CollectHdr(struct http *hp, const char *hdr);
 void http_VSL_log(const struct http *hp);
-void HTTP_Merge(struct objcore *, struct dstat *, struct http *to);
-uint16_t HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds);
-const char *HTTP_GetHdrPack(struct objcore *, struct dstat *,
+void HTTP_Merge(struct worker *, struct objcore *, struct http *to);
+uint16_t HTTP_GetStatusPack(struct worker *, struct objcore *oc);
+const char *HTTP_GetHdrPack(struct worker *, struct objcore *,
     const char *hdr);
 enum sess_close http_DoConnection(struct http *hp);
 
@@ -982,15 +982,15 @@ void *ObjIterBegin(struct worker *, struct objcore *);
 enum objiter_status ObjIter(struct objcore *, void *, void **, ssize_t *);
 void ObjIterEnd(struct objcore *, void **);
 int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr);
-void ObjExtend(struct objcore *, struct dstat *, ssize_t l);
+void ObjExtend(struct worker *, struct objcore *, ssize_t l);
 void ObjTrimStore(struct worker *, struct objcore *);
 unsigned ObjGetXID(struct worker *, struct objcore *);
 uint64_t ObjGetLen(struct worker *, struct objcore *oc);
-void ObjUpdateMeta(struct objcore *, struct dstat *);
-void ObjFreeObj(struct objcore *, struct dstat *);
-void ObjSlim(struct objcore *oc, struct dstat *ds);
+void ObjUpdateMeta(struct worker *, struct objcore *);
+void ObjFreeObj(struct worker *, struct objcore *);
+void ObjSlim(struct worker *, struct objcore *oc);
 struct lru *ObjGetLRU(const struct objcore *);
-void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
+void *ObjGetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
     ssize_t *len);
 void *ObjSetattr(const struct vfp_ctx *, enum obj_attr attr, ssize_t len,
     const void *);
@@ -1000,11 +1000,11 @@ int ObjSetDouble(const struct vfp_ctx*, enum obj_attr, double);
 int ObjSetU32(const struct vfp_ctx *, enum obj_attr, uint32_t);
 int ObjSetU64(const struct vfp_ctx *, enum obj_attr, uint64_t);
 
-int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *);
-int ObjGetU32(struct objcore *, struct dstat *, enum obj_attr, uint32_t *);
-int ObjGetU64(struct objcore *, struct dstat *, enum obj_attr, uint64_t *);
+int ObjGetDouble(struct worker *, struct objcore *, enum obj_attr, double *);
+int ObjGetU32(struct worker *, struct objcore *, enum obj_attr, uint32_t *);
+int ObjGetU64(struct worker *, struct objcore *, enum obj_attr, uint64_t *);
 
-int ObjCheckFlag(struct objcore *oc, struct dstat *ds, enum obj_flags of);
+int ObjCheckFlag(struct worker *, struct objcore *oc, enum obj_flags of);
 void ObjSetFlag(const struct vfp_ctx *vc, enum obj_flags of, int val);
 
 /* cache_panic.c */
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 26c1f59..daa040f 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -827,7 +827,7 @@ BAN_Compile(void)
  */
 
 static int
-ban_evaluate(const uint8_t *bs, struct objcore *oc, struct dstat *ds,
+ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc,
     const struct http *reqhttp, unsigned *tests)
 {
 	struct ban_test bt;
@@ -852,10 +852,10 @@ ban_evaluate(const uint8_t *bs, struct objcore *oc, struct dstat *ds,
 			arg1 = p;
 			break;
 		case BANS_ARG_OBJHTTP:
-			arg1 = HTTP_GetHdrPack(oc, ds, bt.arg1_spec);
+			arg1 = HTTP_GetHdrPack(wrk, oc, bt.arg1_spec);
 			break;
 		case BANS_ARG_OBJSTATUS:
-			arg1 = HTTP_GetHdrPack(oc, ds, ":status");
+			arg1 = HTTP_GetHdrPack(wrk, oc, ":status");
 			break;
 		default:
 			WRONG("Wrong BAN_ARG code");
@@ -939,7 +939,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req)
 		CHECK_OBJ_NOTNULL(b, BAN_MAGIC);
 		if (b->flags & BANS_FLAG_COMPLETED)
 			continue;
-		if (ban_evaluate(b->spec, oc, wrk->stats, req->http, &tests))
+		if (ban_evaluate(wrk, b->spec, oc, req->http, &tests))
 			break;
 	}
 
@@ -958,7 +958,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req)
 
 	if (b == oc->ban) {	/* not banned */
 		oc->ban = b0;
-		ObjUpdateMeta(oc, wrk->stats);
+		ObjUpdateMeta(wrk, oc);
 		return (0);
 	} else {
 		oc->ban = NULL;
@@ -1087,7 +1087,7 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
 				continue;
 			}
 			tests = 0;
-			i = ban_evaluate(bl->spec, oc, wrk->stats, NULL, &tests);
+			i = ban_evaluate(wrk, bl->spec, oc, NULL, &tests);
 			VSC_C_main->bans_lurker_tested++;
 			VSC_C_main->bans_lurker_tests_tested += tests;
 			if (i)
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index 9fa5cf9..97b6645 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -224,7 +224,7 @@ VBO_extend(struct busyobj *bo, ssize_t l)
 		return;
 	assert(l > 0);
 	Lck_Lock(&bo->mtx);
-	ObjExtend(bo->vfc->oc, bo->wrk->stats, l);
+	ObjExtend(bo->wrk, bo->vfc->oc, l);
 	AZ(pthread_cond_broadcast(&bo->cond));
 	Lck_Unlock(&bo->mtx);
 }
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 09e8a27..eca1eee 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -269,7 +269,7 @@ ESI_Deliver(struct req *req)
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
-	p = ObjGetattr(req->objcore, req->wrk->stats, OA_ESIDATA, &l);
+	p = ObjGetattr(req->wrk, req->objcore, OA_ESIDATA, &l);
 	AN(p);
 	assert(l > 0);
 	e = p + l;
@@ -484,7 +484,7 @@ ESI_DeliverChild(struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
 
-	if (!ObjCheckFlag(req->objcore, req->wrk->stats, OF_GZIPED)) {
+	if (!ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED)) {
 		oi = ObjIterBegin(req->wrk, req->objcore);
 		do {
 			ois = ObjIter(req->objcore, oi, &sp, &sl);
@@ -500,7 +500,7 @@ ESI_DeliverChild(struct req *req)
 	 * padding it, as necessary, to a byte boundary.
 	 */
 
-	p = ObjGetattr(req->objcore, req->wrk->stats, OA_GZIPBITS, &l);
+	p = ObjGetattr(req->wrk, req->objcore, OA_GZIPBITS, &l);
 	AN(p);
 	assert(l == 24);
 	start = vbe64dec(p);
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 116a73e..79a8d2f 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -335,7 +335,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru)
 	}
 
 	/* XXX: We could grab and return one storage segment to our caller */
-	ObjSlim(oc, wrk->stats);
+	ObjSlim(wrk, oc);
 
 	exp_mail_it(oc);
 
@@ -391,7 +391,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
 
 	if (flags & OC_EF_MOVE) {
 		oc->timer_when = EXP_When(&oc->exp);
-		ObjUpdateMeta(oc, ep->wrk->stats);
+		ObjUpdateMeta(ep->wrk, oc);
 	}
 
 	VSLb(&ep->vsl, SLT_ExpKill, "EXP_When p=%p e=%.9f f=0x%x", oc,
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 3c0ba92..caa74c3 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -190,12 +190,11 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
 	}
 
 	if (bo->ims_oc != NULL) {
-		q = HTTP_GetHdrPack(bo->ims_oc, bo->wrk->stats,
-		    H_Last_Modified);
+		q = HTTP_GetHdrPack(bo->wrk, bo->ims_oc, H_Last_Modified);
 		if (q != NULL)
 			http_PrintfHeader(bo->bereq0,
 			    "If-Modified-Since: %s", q);
-		q = HTTP_GetHdrPack(bo->ims_oc, bo->wrk->stats, H_ETag);
+		q = HTTP_GetHdrPack(bo->wrk, bo->ims_oc, H_ETag);
 		if (q != NULL)
 			http_PrintfHeader(bo->bereq0,
 			    "If-None-Match: %s", q);
@@ -381,7 +380,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	AZ(bo->do_esi);
 
 	if (bo->ims_oc != NULL && http_IsStatus(bo->beresp, 304)) {
-		if (ObjCheckFlag(bo->ims_oc, bo->wrk->stats, OF_CHGGZIP)) {
+		if (ObjCheckFlag(bo->wrk, bo->ims_oc, OF_CHGGZIP)) {
 			/*
 			 * If we changed the gzip status of the object
 			 * the stored Content_Encoding controls we
@@ -390,7 +389,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 			http_Unset(bo->beresp, H_Content_Encoding);
 			RFC2616_Weaken_Etag(bo->beresp);
 		}
-		HTTP_Merge(bo->ims_oc, bo->wrk->stats, bo->beresp);
+		HTTP_Merge(bo->wrk, bo->ims_oc, bo->beresp);
 		assert(http_IsStatus(bo->beresp, 200));
 		do_ims = 1;
 	} else
@@ -626,7 +625,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->vfc->failed && !bo->do_stream) {
 		assert(bo->state < BOS_STREAM);
 		if (bo->fetch_objcore != NULL)
-			ObjFreeObj(bo->fetch_objcore, bo->wrk->stats);
+			ObjFreeObj(bo->wrk, bo->fetch_objcore);
 		return (F_STP_ERROR);
 	}
 
@@ -672,7 +671,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 
 	AZ(vbf_beresp2obj(bo));
 
-	if (ObjGetattr(bo->ims_oc, bo->wrk->stats, OA_ESIDATA, NULL) != NULL)
+	if (ObjGetattr(bo->wrk, bo->ims_oc, OA_ESIDATA, NULL) != NULL)
 		AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_ESIDATA));
 
 	AZ(ObjCopyAttr(bo->vfc, bo->ims_oc, OA_FLAGS));
@@ -949,8 +948,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
 	bo->fetch_objcore = oc;
 
 	AZ(bo->ims_oc);
-	if (oldoc != NULL &&
-	    ObjCheckFlag(oldoc, req->wrk->stats, OF_IMSCAND)) {
+	if (oldoc != NULL && ObjCheckFlag(req->wrk, oldoc, OF_IMSCAND)) {
 		assert(oldoc->refcnt > 0);
 		HSH_Ref(oldoc);
 		bo->ims_oc = oldoc;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index f8c4149..7fe3d86 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -424,7 +424,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 		if (BAN_CheckObject(wrk, oc, req))
 			continue;
 
-		vary = ObjGetattr(oc, wrk->stats, OA_VARY, NULL);
+		vary = ObjGetattr(wrk, oc, OA_VARY, NULL);
 
 		if (vary != NULL && !VRY_Match(req, vary))
 			continue;
@@ -771,7 +771,7 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp)
 	AZ(oc->ban);
 
 	if (oc->stobj->stevedore != NULL)
-		ObjFreeObj(oc, wrk->stats);
+		ObjFreeObj(wrk, oc);
 	FREE_OBJ(oc);
 
 	wrk->stats->n_objectcore--;
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 27ab49f..031b7dd 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -820,10 +820,10 @@ HTTP_Decode(struct http *to, uint8_t *fm)
 /*--------------------------------------------------------------------*/
 
 uint16_t
-HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds)
+HTTP_GetStatusPack(struct worker *wrk, struct objcore *oc)
 {
 	const char *ptr;
-	ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL);
+	ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL);
 	AN(ptr);
 
 	return(vbe16dec(ptr + 2));
@@ -832,16 +832,16 @@ HTTP_GetStatusPack(struct objcore *oc, struct dstat *ds)
 /*--------------------------------------------------------------------*/
 
 const char *
-HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr)
+HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr)
 {
 	const char *ptr;
 	unsigned l;
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(ds);
 	AN(hdr);
 
-	ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL);
+	ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL);
 	AN(ptr);
 
 	/* Skip nhd and status */
@@ -883,17 +883,17 @@ HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr)
  */
 
 void
-HTTP_Merge(struct objcore *oc, struct dstat *ds, struct http *to)
+HTTP_Merge(struct worker *wrk, struct objcore *oc, struct http *to)
 {
 	const char *ptr;
 	unsigned u;
 	const char *p;
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
-	AN(ds);
 
-	ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL);
+	ptr = ObjGetattr(wrk, oc, OA_HEADERS, NULL);
 	AN(ptr);
 
 	to->status = vbe16dec(ptr + 2);
diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c
index 99e9a24..3eb10d6 100644
--- a/bin/varnishd/cache/cache_http1_deliver.c
+++ b/bin/varnishd/cache/cache_http1_deliver.c
@@ -239,7 +239,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 
 	req->res_mode = 0;
 
-	if (!req->disable_esi && ObjGetattr(req->objcore, req->wrk->stats,
+	if (!req->disable_esi && ObjGetattr(req->wrk, req->objcore,
 	    OA_ESIDATA, NULL) != NULL) {
 		/* In ESI mode, we can't know the aggregate length */
 		req->res_mode &= ~RES_LEN;
@@ -267,7 +267,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	}
 
 	if (cache_param->http_gzip_support &&
-	    ObjCheckFlag(req->objcore, req->wrk->stats, OF_GZIPED) &&
+	    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
 	    !RFC2616_Req_Gzip(req->http)) {
 		/*
 		 * We don't know what it uncompresses to
@@ -346,7 +346,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	} else if (req->res_mode & RES_GUNZIP ||
 	    (req->res_mode & RES_ESI_CHILD &&
 	    !req->gzip_resp &&
-	    ObjCheckFlag(req->objcore, req->wrk->stats, OF_GZIPED))) {
+	    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED))) {
 		VDP_push(req, VDP_gunzip);
 		req->vgz = VGZ_NewUngzip(req->vsl, "U D -");
 		AZ(VGZ_WrwInit(req->vgz));
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 1d8f578..4db9524 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -58,13 +58,14 @@ obj_getmethods(const struct objcore *oc)
 }
 
 static struct object *
-obj_getobj(struct objcore *oc, struct dstat *ds)
+obj_getobj(struct worker *wrk, struct objcore *oc)
 {
 	const struct storeobj_methods *m = obj_getmethods(oc);
 
-	AN(ds);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	AN(m->getobj);
-	return (m->getobj(oc, ds));
+	return (m->getobj(wrk, oc));
 }
 
 /*====================================================================
@@ -104,7 +105,7 @@ ObjIterBegin(struct worker *wrk, struct objcore *oc)
 		return (om->objiterbegin(wrk, oc));
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	obj = obj_getobj(oc, wrk->stats);
+	obj = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
 	ALLOC_OBJ(oi, OBJITER_MAGIC);
 	if (oi == NULL)
@@ -265,7 +266,7 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr)
 	AN(sz);
 	AN(ptr);
 	assert(*sz > 0);
-	o = obj_getobj(oc, wrk->stats);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 
 	st = VTAILQ_LAST(&o->list, storagehead);
@@ -302,19 +303,20 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr)
  */
 
 void
-ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l)
+ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l)
 {
 	struct object *o;
 	struct storage *st;
 	const struct storeobj_methods *om = obj_getmethods(oc);
 
 	if (om->objextend != NULL) {
-		om->objextend(oc, ds, l);
+		om->objextend(wrk, oc, l);
 		return;
 	}
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	o = obj_getobj(oc, ds);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	st = VTAILQ_LAST(&o->list, storagehead);
 	CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
@@ -338,7 +340,7 @@ ObjGetLen(struct worker *wrk, struct objcore *oc)
 	if (om->objgetlen != NULL)
 		return (om->objgetlen(wrk, oc));
 
-	o = obj_getobj(oc, wrk->stats);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	return (o->len);
 }
@@ -368,7 +370,7 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	stv = oc->stobj->stevedore;
 	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
-	o = obj_getobj(oc, wrk->stats);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	st = VTAILQ_LAST(&o->list, storagehead);
 	if (st == NULL)
@@ -389,20 +391,20 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
  */
 
 void
-ObjSlim(struct objcore *oc, struct dstat *ds)
+ObjSlim(struct worker *wrk, struct objcore *oc)
 {
 	struct object *o;
 	struct storage *st, *stn;
 	const struct storeobj_methods *om = obj_getmethods(oc);
 
 	if (om->objslim != NULL) {
-		om->objslim(oc, ds);
+		om->objslim(wrk, oc);
 		return;
 	}
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(ds);
-	o = obj_getobj(oc, ds);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 
 	if (o->esidata != NULL) {
@@ -419,25 +421,25 @@ ObjSlim(struct objcore *oc, struct dstat *ds)
 /*====================================================================
  */
 void
-ObjUpdateMeta(struct objcore *oc, struct dstat *ds)
+ObjUpdateMeta(struct worker *wrk, struct objcore *oc)
 {
 	const struct storeobj_methods *m = obj_getmethods(oc);
 
 	if (m->updatemeta != NULL)
-		m->updatemeta(oc, ds);
+		m->updatemeta(wrk, oc);
 }
 
 /*====================================================================
  */
 void
-ObjFreeObj(struct objcore *oc, struct dstat *ds)
+ObjFreeObj(struct worker *wrk, struct objcore *oc)
 {
 	const struct storeobj_methods *m = obj_getmethods(oc);
 
-	AN(ds);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	AN(m->freeobj);
-	m->freeobj(oc, ds);
+	m->freeobj(wrk, oc);
 }
 
 /*====================================================================
@@ -459,7 +461,7 @@ ObjGetLRU(const struct objcore *oc)
  */
 
 void *
-ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
+ObjGetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
    ssize_t *len)
 {
 	struct object *o;
@@ -467,13 +469,13 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
 	const struct storeobj_methods *om = obj_getmethods(oc);
 
 	if (om->objgetattr != NULL)
-		return (om->objgetattr(oc, ds, attr, len));
+		return (om->objgetattr(wrk, oc, attr, len));
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(ds);
 	if (len == NULL)
 		len = &dummy;
-	o = obj_getobj(oc, ds);
+	o = obj_getobj(wrk, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	switch (attr) {
 	case OA_ESIDATA:
@@ -527,7 +529,7 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len,
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->oc, OBJCORE_MAGIC);
-	o = obj_getobj(vc->oc, vc->wrk->stats);
+	o = obj_getobj(vc->wrk, vc->oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	st = o->objstore;
 	switch (attr) {
@@ -590,7 +592,7 @@ ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr)
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 
-	vps = ObjGetattr(ocs, vc->wrk->stats, attr, &l);
+	vps = ObjGetattr(vc->wrk, ocs, attr, &l);
 	// XXX: later we want to have zero-length OA's too
 	if (vps == NULL || l <= 0)
 		return (-1);
@@ -605,7 +607,7 @@ ObjGetXID(struct worker *wrk, struct objcore *oc)
 {
 	uint32_t u;
 
-	AZ(ObjGetU32(oc, wrk->stats, OA_VXID, &u));
+	AZ(ObjGetU32(wrk, oc, OA_VXID, &u));
 	return (u);
 }
 
@@ -633,14 +635,14 @@ ObjSetDouble(const struct vfp_ctx *vc, enum obj_attr a, double t)
 }
 
 int
-ObjGetDouble(struct objcore *oc, struct dstat *ds, enum obj_attr a, double *d)
+ObjGetDouble(struct worker *wrk, struct objcore *oc, enum obj_attr a, double *d)
 {
 	void *vp;
 	uint64_t u;
 	ssize_t l;
 
 	assert(sizeof *d == sizeof u);
-	vp = ObjGetattr(oc, ds, a, &l);
+	vp = ObjGetattr(wrk, oc, a, &l);
 	if (vp == NULL)
 		return (-1);
 	if (d != NULL) {
@@ -667,12 +669,12 @@ ObjSetU64(const struct vfp_ctx *vc, enum obj_attr a, uint64_t t)
 }
 
 int
-ObjGetU64(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint64_t *d)
+ObjGetU64(struct worker *wrk, struct objcore *oc, enum obj_attr a, uint64_t *d)
 {
 	void *vp;
 	ssize_t l;
 
-	vp = ObjGetattr(oc, ds, a, &l);
+	vp = ObjGetattr(wrk, oc, a, &l);
 	if (vp == NULL || l != sizeof *d)
 		return (-1);
 	if (d != NULL)
@@ -693,12 +695,12 @@ ObjSetU32(const struct vfp_ctx *vc, enum obj_attr a, uint32_t t)
 }
 
 int
-ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d)
+ObjGetU32(struct worker *wrk, struct objcore *oc, enum obj_attr a, uint32_t *d)
 {
 	void *vp;
 	ssize_t l;
 
-	vp = ObjGetattr(oc, ds, a, &l);
+	vp = ObjGetattr(wrk, oc, a, &l);
 	if (vp == NULL || l != sizeof *d)
 		return (-1);
 	if (d != NULL)
@@ -710,11 +712,11 @@ ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d)
  */
 
 int
-ObjCheckFlag(struct objcore *oc, struct dstat *ds, enum obj_flags of)
+ObjCheckFlag(struct worker *wrk, struct objcore *oc, enum obj_flags of)
 {
 	uint8_t *fp;
 
-	fp = ObjGetattr(oc, ds, OA_FLAGS, NULL);
+	fp = ObjGetattr(wrk, oc, OA_FLAGS, NULL);
 	AN(fp);
 	return ((*fp) & of);
 }
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 16bd00e..223b728 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -174,7 +174,7 @@ VRB_Free(struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	if (req->body_oc != NULL) {
-		ObjFreeObj(req->body_oc, req->wrk->stats);
+		ObjFreeObj(req->wrk,req->body_oc);
 		FREE_OBJ(req->body_oc);
 		req->body_oc = NULL;
 	}
@@ -254,7 +254,7 @@ VRB_Cache(struct req *req, ssize_t maxsize)
 			req->acct.req_bodybytes += l;
 			if (yet >= l)
 				yet -= l;
-			ObjExtend(req->body_oc, req->wrk->stats, l);
+			ObjExtend(req->wrk, req->body_oc, l);
 		}
 
 	} while (vfps == VFP_OK);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 4a34a17..3d20e43 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -103,7 +103,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 
 	HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod);
 	AZ(HTTP_Decode(req->resp,
-	    ObjGetattr(req->objcore, req->wrk->stats, OA_HEADERS, NULL)));
+	    ObjGetattr(req->wrk, req->objcore, OA_HEADERS, NULL)));
 	http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1");
 
 	if (req->wrk->stats->cache_hit)
@@ -127,7 +127,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 	http_SetHeader(req->resp, "Via: 1.1 varnish-v4");
 
 	if (cache_param->http_gzip_support &&
-	    ObjCheckFlag(req->objcore, req->wrk->stats, OF_GZIPED) &&
+	    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
 	    !RFC2616_Req_Gzip(req->http))
 		RFC2616_Weaken_Etag(req->resp);
 
@@ -188,7 +188,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 		 */
 		while (req->objcore->busyobj != NULL)
 			(void)usleep(100000);
-		ObjSlim(req->objcore, wrk->stats);
+		ObjSlim(wrk, req->objcore);
 	}
 
 	assert(WRW_IsReleased(wrk));
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 6f27269..99de23f 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -225,8 +225,7 @@ RFC2616_Do_Cond(const struct req *req)
 		ims = VTIM_parse(p);
 		if (ims > req->t_req)	/* [RFC2616 14.25] */
 			return (0);
-		AZ(ObjGetDouble(req->objcore,  req->wrk->stats,
-		    OA_LASTMODIFIED, &lm));
+		AZ(ObjGetDouble(req->wrk, req->objcore, OA_LASTMODIFIED, &lm));
 		if (lm > ims)
 			return (0);
 		do_cond = 1;
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 13c04dc..8422f79 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -127,8 +127,8 @@ VRT_GetHdr(const struct vrt_ctx *ctx, const struct gethdr_s *hs)
 	if (hs->where == HDR_OBJ) {
 		CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 		CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
-		return(HTTP_GetHdrPack(ctx->req->objcore,
-		    ctx->req->wrk->stats, hs->what));
+		return(HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
+		    hs->what));
 	}
 	hp = vrt_selecthttp(ctx, hs->where);
 	CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 59b3c6f..439ef46 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -148,7 +148,7 @@ VRT_r_obj_status(const struct vrt_ctx *ctx)
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
 
-	return (HTTP_GetStatusPack(ctx->req->objcore, ctx->req->wrk->stats));
+	return (HTTP_GetStatusPack(ctx->req->wrk, ctx->req->objcore));
 }
 
 const char *
@@ -158,8 +158,7 @@ VRT_r_obj_proto(const struct vrt_ctx *ctx)
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
 
-	return (HTTP_GetHdrPack(ctx->req->objcore,
-	    ctx->req->wrk->stats, ":proto"));
+	return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, ":proto"));
 }
 
 const char *
@@ -169,8 +168,7 @@ VRT_r_obj_reason(const struct vrt_ctx *ctx)
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
 
-	return (HTTP_GetHdrPack(ctx->req->objcore,
-	    ctx->req->wrk->stats, ":reason"));
+	return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, ":reason"));
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 2e02e0a..ec03354 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -49,11 +49,12 @@ static const struct stevedore * volatile stv_next;
  */
 
 static struct object * __match_proto__(getobj_f)
-default_oc_getobj(struct objcore *oc, struct dstat *ds)
+default_oc_getobj(struct worker *wrk, struct objcore *oc)
 {
 	struct object *o;
 
-	(void)ds;
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	if (oc->stobj->priv == NULL)
 		return (NULL);
 	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
@@ -61,13 +62,13 @@ default_oc_getobj(struct objcore *oc, struct dstat *ds)
 }
 
 static void __match_proto__(freeobj_f)
-default_oc_freeobj(struct objcore *oc, struct dstat *ds)
+default_oc_freeobj(struct worker *wrk, struct objcore *oc)
 {
 	struct object *o;
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AN(ds);
-	ObjSlim(oc, ds);
+	ObjSlim(wrk, oc);
 	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
 	oc->stobj->priv = NULL;
 	oc->stobj->stevedore = NULL;
@@ -75,7 +76,7 @@ default_oc_freeobj(struct objcore *oc, struct dstat *ds)
 
 	STV_free(o->objstore);
 
-	ds->n_object--;
+	wrk->stats->n_object--;
 }
 
 static struct lru * __match_proto__(getlru_f)
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 06d6d22..c3d6158 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -81,15 +81,15 @@ struct object {
 
 /* Methods on objcore ------------------------------------------------*/
 
-typedef void updatemeta_f(struct objcore *oc, struct dstat *);
-typedef void freeobj_f(struct objcore *oc, struct dstat *);
+typedef void updatemeta_f(struct worker *, struct objcore *oc);
+typedef void freeobj_f(struct worker *, struct objcore *oc);
 typedef struct lru *getlru_f(const struct objcore *oc);
 
 /*
  * Stevedores can either be simple, and provide just this method:
  */
 
-typedef struct object *getobj_f(struct objcore *oc, struct dstat *);
+typedef struct object *getobj_f(struct worker *, struct objcore *oc);
 
 /*
  * Or the can be "complex" and provide all of these methods:
@@ -101,10 +101,10 @@ typedef enum objiter_status objiter_f(struct objcore *oc, void *oix,
 typedef void objiterend_f(struct objcore *, void **oix);
 typedef int objgetspace_f(struct worker *, struct objcore *,
      ssize_t *sz, uint8_t **ptr);
-typedef void objextend_f(struct objcore *, struct dstat *ds, ssize_t l);
+typedef void objextend_f(struct worker *, struct objcore *, ssize_t l);
 typedef void objtrimstore_f(struct worker *, struct objcore *);
-typedef void objslim_f(struct objcore *, struct dstat *ds);
-typedef void *objgetattr_f(struct objcore *, struct dstat *ds,
+typedef void objslim_f(struct worker *, struct objcore *);
+typedef void *objgetattr_f(struct worker *, struct objcore *,
     enum obj_attr attr, ssize_t *len);
 typedef void *objsetattr_f(const struct vfp_ctx *, enum obj_attr attr,
     ssize_t len, const void *ptr);
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index b0dbff9..2dbfb0a 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -388,7 +388,7 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg,
  */
 
 static struct object *
-smp_oc_getobj(struct objcore *oc, struct dstat *ds)
+smp_oc_getobj(struct worker *wrk, struct objcore *oc)
 {
 	struct object *o;
 	struct smp_seg *sg;
@@ -400,9 +400,8 @@ smp_oc_getobj(struct objcore *oc, struct dstat *ds)
 	/* Some calls are direct, but they should match anyway */
 	assert(oc->stobj->stevedore->methods->getobj == smp_oc_getobj);
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	if (ds == NULL)
-		AZ(oc->stobj->priv2 & NEED_FIXUP);
 
 	CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC);
 	so = smp_find_so(sg, oc->stobj->priv2);
@@ -424,7 +423,6 @@ smp_oc_getobj(struct objcore *oc, struct dstat *ds)
 	if (!(oc->stobj->priv2 & NEED_FIXUP))
 		return (o);
 
-	AN(ds);
 	Lck_Lock(&sg->sc->mtx);
 	/* Check again, we might have raced. */
 	if (oc->stobj->priv2 & NEED_FIXUP) {
@@ -447,8 +445,8 @@ smp_oc_getobj(struct objcore *oc, struct dstat *ds)
 		}
 
 		sg->nfixed++;
-		ds->n_object++;
-		ds->n_vampireobject--;
+		wrk->stats->n_object++;
+		wrk->stats->n_vampireobject--;
 		oc->stobj->priv2 &= ~NEED_FIXUP;
 	}
 	Lck_Unlock(&sg->sc->mtx);
@@ -457,14 +455,15 @@ smp_oc_getobj(struct objcore *oc, struct dstat *ds)
 }
 
 static void
-smp_oc_updatemeta(struct objcore *oc, struct dstat *ds)
+smp_oc_updatemeta(struct worker *wrk, struct objcore *oc)
 {
 	struct object *o;
 	struct smp_seg *sg;
 	struct smp_object *so;
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	o = smp_oc_getobj(oc, ds);
+	o = smp_oc_getobj(wrk, oc);
 	AN(o);
 
 	CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC);
@@ -484,12 +483,12 @@ smp_oc_updatemeta(struct objcore *oc, struct dstat *ds)
 }
 
 static void __match_proto__(freeobj_f)
-smp_oc_freeobj(struct objcore *oc, struct dstat *ds)
+smp_oc_freeobj(struct worker *wrk, struct objcore *oc)
 {
 	struct smp_seg *sg;
 	struct smp_object *so;
 
-	AN(ds);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC);
@@ -502,11 +501,11 @@ smp_oc_freeobj(struct objcore *oc, struct dstat *ds)
 	assert(sg->nobj > 0);
 	sg->nobj--;
 	if (oc->stobj->priv2 & NEED_FIXUP) {
-		ds->n_vampireobject--;
+		wrk->stats->n_vampireobject--;
 	} else {
 		assert(sg->nfixed > 0);
 		sg->nfixed--;
-		ds->n_object--;
+		wrk->stats->n_object--;
 	}
 
 	Lck_Unlock(&sg->sc->mtx);



More information about the varnish-commit mailing list