[master] 9da7a7b Move Obj* API towards taking a struct worker as first argument.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Sep 16 12:52:37 CEST 2014
commit 9da7a7bcc9e8a37611215886faea1a26af769f68
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Sep 16 10:52:13 2014 +0000
Move Obj* API towards taking a struct worker as first argument.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index df62953..57fb42f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -729,7 +729,7 @@ struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
void VBO_Free(struct busyobj **vbo);
void VBO_extend(struct busyobj *, ssize_t);
-ssize_t VBO_waitlen(struct busyobj *, struct dstat *, ssize_t l);
+ssize_t VBO_waitlen(struct worker *, struct busyobj *, ssize_t l);
void VBO_setstate(struct busyobj *bo, enum busyobj_state_e next);
void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want);
@@ -978,14 +978,14 @@ enum objiter_status {
OIS_STREAM,
OIS_ERROR,
};
-void *ObjIterBegin(struct objcore *, struct worker *);
+void *ObjIterBegin(struct worker *, struct objcore *);
enum objiter_status ObjIter(struct objcore *, void *, void **, ssize_t *);
void ObjIterEnd(struct objcore *, void **);
-int ObjGetSpace(struct objcore *, struct worker *, ssize_t *sz, uint8_t **ptr);
+int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr);
void ObjExtend(struct objcore *, struct dstat *, ssize_t l);
-void ObjTrimStore(struct objcore *, struct dstat *);
-unsigned ObjGetXID(struct objcore *, struct dstat *);
-uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds);
+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);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 9311b75..26c1f59 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -962,8 +962,7 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req)
return (0);
} else {
oc->ban = NULL;
- VSLb(vsl, SLT_ExpBan, "%u banned lookup",
- ObjGetXID(oc, wrk->stats));
+ VSLb(vsl, SLT_ExpBan, "%u banned lookup", ObjGetXID(wrk, oc));
VSC_C_main->bans_obj_killed++;
EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now
return (1);
@@ -1096,7 +1095,7 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
}
if (i) {
VSLb(vsl, SLT_ExpBan, "%u banned by lurker",
- ObjGetXID(oc, wrk->stats));
+ ObjGetXID(wrk, oc));
EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now
VSC_C_main->bans_lurker_obj_killed++;
}
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index f381e08..9fa5cf9 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -230,20 +230,20 @@ VBO_extend(struct busyobj *bo, ssize_t l)
}
ssize_t
-VBO_waitlen(struct busyobj *bo, struct dstat *ds, ssize_t l)
+VBO_waitlen(struct worker *wrk, struct busyobj *bo, ssize_t l)
{
ssize_t rv;
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
- AN(ds);
Lck_Lock(&bo->mtx);
- rv = ObjGetLen(bo->fetch_objcore, ds);
+ rv = ObjGetLen(wrk, bo->fetch_objcore);
while (1) {
assert(l <= rv || bo->state == BOS_FAILED);
if (rv > l || bo->state >= BOS_FINISHED)
break;
(void)Lck_CondWait(&bo->cond, &bo->mtx, 0);
- rv = ObjGetLen(bo->fetch_objcore, ds);
+ rv = ObjGetLen(wrk, bo->fetch_objcore);
}
Lck_Unlock(&bo->mtx);
return (rv);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 9f2059e..09e8a27 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);
}
- oi = ObjIterBegin(req->objcore, req->wrk);
+ oi = ObjIterBegin(req->wrk, req->objcore);
ois = ObjIter(req->objcore, oi, &sp, &sl);
assert(ois != OIS_ERROR);
pp = sp;
@@ -485,7 +485,7 @@ ESI_DeliverChild(struct req *req)
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
if (!ObjCheckFlag(req->objcore, req->wrk->stats, OF_GZIPED)) {
- oi = ObjIterBegin(req->objcore, req->wrk);
+ oi = ObjIterBegin(req->wrk, req->objcore);
do {
ois = ObjIter(req->objcore, oi, &sp, &sl);
if (sl > 0)
@@ -506,7 +506,7 @@ ESI_DeliverChild(struct req *req)
start = vbe64dec(p);
last = vbe64dec(p + 8);
stop = vbe64dec(p + 16);
- olen = ObjGetLen(req->objcore, req->wrk->stats);
+ olen = ObjGetLen(req->wrk, req->objcore);
assert(start > 0 && start < olen * 8);
assert(last > 0 && last < olen * 8);
assert(stop > 0 && stop < olen * 8);
@@ -525,7 +525,7 @@ ESI_DeliverChild(struct req *req)
dbits = (void*)WS_Alloc(req->ws, 8);
AN(dbits);
ll = 0;
- oi = ObjIterBegin(req->objcore, req->wrk);
+ oi = ObjIterBegin(req->wrk, req->objcore);
do {
ois = ObjIter(req->objcore, oi, &sp, &sl);
pp = sp;
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 3d8caa5..116a73e 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -339,7 +339,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru)
exp_mail_it(oc);
- VSLb(wrk->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, wrk->stats));
+ VSLb(wrk->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(wrk, oc));
(void)HSH_DerefObjCore(wrk, &oc);
return (1);
}
@@ -463,8 +463,7 @@ exp_expire(struct exp_priv *ep, double now)
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f",
- ObjGetXID(oc, ep->wrk->stats),
- EXP_Ttl(NULL, &oc->exp) - now);
+ ObjGetXID(ep->wrk, oc), EXP_Ttl(NULL, &oc->exp) - now);
(void)HSH_DerefObjCore(ep->wrk, &oc);
return (0);
}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 4080a8e..3c0ba92 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -497,7 +497,7 @@ vbf_fetch_body_helper(struct busyobj *bo)
VFP_Close(vfc);
if (!bo->do_stream)
- ObjTrimStore(vfc->oc, bo->wrk->stats);
+ ObjTrimStore(bo->wrk, vfc->oc);
}
/*--------------------------------------------------------------------
@@ -684,8 +684,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
}
al = 0;
- ol = ObjGetLen(bo->ims_oc, bo->wrk->stats);
- oi = ObjIterBegin(bo->ims_oc, wrk);
+ ol = ObjGetLen(bo->wrk, bo->ims_oc);
+ oi = ObjIterBegin(wrk, bo->ims_oc);
do {
ois = ObjIter(bo->ims_oc, oi, &sp, &sl);
while (sl > 0) {
@@ -709,7 +709,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
HSH_Unbusy(wrk, bo->fetch_objcore);
assert(al == ol);
- assert(ObjGetLen(bo->fetch_objcore, bo->wrk->stats) == al);
+ assert(ObjGetLen(bo->wrk, bo->fetch_objcore) == al);
EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0);
/* Recycle the backend connection before setting BOS_FINISHED to
@@ -889,7 +889,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
AZ(bo->fetch_objcore->flags & OC_F_FAILED);
HSH_Complete(bo->fetch_objcore);
VSLb(bo->vsl, SLT_Length, "%ju",
- (uintmax_t)ObjGetLen(bo->fetch_objcore, bo->wrk->stats));
+ (uintmax_t)ObjGetLen(bo->wrk, bo->fetch_objcore));
}
AZ(bo->fetch_objcore->busyobj);
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 3e3aad6..331efce 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -89,7 +89,7 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t *sz, uint8_t **ptr)
if (l == 0)
l = cache_param->fetch_chunksize;
*sz = l;
- if (!ObjGetSpace(vc->oc, vc->wrk, sz, ptr)) {
+ if (!ObjGetSpace(vc->wrk, vc->oc, sz, ptr)) {
*sz = 0;
*ptr = NULL;
return (VFP_Error(vc, "Could not get storage"));
diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c
index f58ea70..99e9a24 100644
--- a/bin/varnishd/cache/cache_http1_deliver.c
+++ b/bin/varnishd/cache/cache_http1_deliver.c
@@ -97,9 +97,9 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r)
/* We must snapshot the length if we're streaming from the backend */
if (bo != NULL)
- len = VBO_waitlen(bo, req->wrk->stats, -1);
+ len = VBO_waitlen(req->wrk, bo, -1);
else
- len = ObjGetLen(req->objcore, req->wrk->stats);
+ len = ObjGetLen(req->wrk, req->objcore);
if (strncmp(r, "bytes=", 6))
return;
@@ -174,7 +174,7 @@ v1d_WriteDirObj(struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- oi = ObjIterBegin(req->objcore, req->wrk);
+ oi = ObjIterBegin(req->wrk, req->objcore);
XXXAN(oi);
do {
@@ -252,11 +252,11 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
/* XXX: Not happy with this convoluted test */
req->res_mode |= RES_LEN;
if (!(req->objcore->flags & OC_F_PASS) ||
- ObjGetLen(req->objcore, req->wrk->stats) != 0) {
+ ObjGetLen(req->wrk, req->objcore) != 0) {
http_Unset(req->resp, H_Content_Length);
http_PrintfHeader(req->resp,
"Content-Length: %ju", (uintmax_t)ObjGetLen(
- req->objcore, req->wrk->stats));
+ req->wrk, req->objcore));
}
}
@@ -340,7 +340,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
l = -1;
while (req->objcore->busyobj) {
assert(bo != NULL);
- l = VBO_waitlen(bo, req->wrk->stats, l);
+ l = VBO_waitlen(req->wrk, bo, l);
}
ESI_DeliverChild(req);
} else if (req->res_mode & RES_GUNZIP ||
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 2c5335c..1d8f578 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -94,14 +94,14 @@ struct objiter {
};
void *
-ObjIterBegin(struct objcore *oc, struct worker *wrk)
+ObjIterBegin(struct worker *wrk, struct objcore *oc)
{
struct objiter *oi;
struct object *obj;
const struct storeobj_methods *om = obj_getmethods(oc);
if (om->objiterbegin != NULL)
- return (om->objiterbegin(oc, wrk));
+ return (om->objiterbegin(wrk, oc));
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
obj = obj_getobj(oc, wrk->stats);
@@ -152,7 +152,7 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l)
} else {
ol = oi->len;
while (1) {
- nl = VBO_waitlen(oi->bo, oi->wrk->stats, ol);
+ nl = VBO_waitlen(oi->wrk, oi->bo, ol);
if (nl != ol)
break;
if (oi->bo->state == BOS_FINISHED)
@@ -251,14 +251,14 @@ objallocwithnuke(struct stevedore *stv, struct worker *wrk, size_t size)
*/
int
-ObjGetSpace(struct objcore *oc, struct worker *wrk, ssize_t *sz, uint8_t **ptr)
+ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr)
{
struct object *o;
struct storage *st;
const struct storeobj_methods *om = obj_getmethods(oc);
if (om->objgetspace != NULL)
- return (om->objgetspace(oc, wrk, sz, ptr));
+ return (om->objgetspace(wrk, oc, sz, ptr));
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -330,15 +330,15 @@ ObjExtend(struct objcore *oc, struct dstat *ds, ssize_t l)
*/
uint64_t
-ObjGetLen(struct objcore *oc, struct dstat *ds)
+ObjGetLen(struct worker *wrk, struct objcore *oc)
{
struct object *o;
const struct storeobj_methods *om = obj_getmethods(oc);
if (om->objgetlen != NULL)
- return (om->objgetlen(oc, ds));
+ return (om->objgetlen(wrk, oc));
- o = obj_getobj(oc, ds);
+ o = obj_getobj(oc, wrk->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
return (o->len);
}
@@ -352,7 +352,7 @@ ObjGetLen(struct objcore *oc, struct dstat *ds)
*/
void
-ObjTrimStore(struct objcore *oc, struct dstat *ds)
+ObjTrimStore(struct worker *wrk, struct objcore *oc)
{
const struct stevedore *stv;
struct storage *st;
@@ -360,15 +360,15 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds)
const struct storeobj_methods *om = obj_getmethods(oc);
if (om->objtrimstore != NULL) {
- om->objtrimstore(oc, ds);
+ om->objtrimstore(wrk, oc);
return;
}
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- AN(ds);
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
stv = oc->stobj->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
- o = obj_getobj(oc, ds);
+ o = obj_getobj(oc, wrk->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
st = VTAILQ_LAST(&o->list, storagehead);
if (st == NULL)
@@ -601,11 +601,11 @@ ObjCopyAttr(const struct vfp_ctx *vc, struct objcore *ocs, enum obj_attr attr)
}
unsigned
-ObjGetXID(struct objcore *oc, struct dstat *ds)
+ObjGetXID(struct worker *wrk, struct objcore *oc)
{
uint32_t u;
- AZ(ObjGetU32(oc, ds, OA_VXID, &u));
+ AZ(ObjGetU32(oc, wrk->stats, OA_VXID, &u));
return (u);
}
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 049e850..16bd00e 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -62,7 +62,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv)
switch(req->req_body_status) {
case REQ_BODY_CACHED:
- oi = ObjIterBegin(req->body_oc, req->wrk);
+ oi = ObjIterBegin(req->wrk, req->body_oc);
AN(oi);
do {
ois = ObjIter(req->body_oc, oi, &p, &l);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 3ea3452..4a34a17 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -109,7 +109,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
if (req->wrk->stats->cache_hit)
http_PrintfHeader(req->resp,
"X-Varnish: %u %u", VXID(req->vsl->wid),
- ObjGetXID(req->objcore, wrk->stats));
+ ObjGetXID(wrk, req->objcore));
else
http_PrintfHeader(req->resp,
"X-Varnish: %u", VXID(req->vsl->wid));
@@ -399,7 +399,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
/* Found a hit-for-pass */
VSLb(req->vsl, SLT_Debug, "XXXX HIT-FOR-PASS");
VSLb(req->vsl, SLT_HitPass, "%u",
- ObjGetXID(req->objcore, wrk->stats));
+ ObjGetXID(wrk, req->objcore));
AZ(boc);
(void)HSH_DerefObjCore(wrk, &req->objcore);
wrk->stats->cache_hitpass++;
@@ -407,8 +407,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
return (REQ_FSM_MORE);
}
- VSLb(req->vsl, SLT_Hit, "%u",
- ObjGetXID(req->objcore, wrk->stats));
+ VSLb(req->vsl, SLT_Hit, "%u", ObjGetXID(wrk, req->objcore));
VCL_hit_method(req->vcl, wrk, req, NULL, req->http->ws);
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index cc3420a..06d6d22 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -95,20 +95,20 @@ typedef struct object *getobj_f(struct objcore *oc, struct dstat *);
* Or the can be "complex" and provide all of these methods:
* (Described in comments in cache_obj.c)
*/
-typedef void *objiterbegin_f(struct objcore *oc, struct worker *wrk);
+typedef void *objiterbegin_f(struct worker *, struct objcore *oc);
typedef enum objiter_status objiter_f(struct objcore *oc, void *oix,
void **p, ssize_t *l);
-typedef void objiterend_f(struct objcore *oc, void **oix);
-typedef int objgetspace_f(struct objcore *oc, struct worker *,
+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 *oc, struct dstat *ds, ssize_t l);
-typedef void objtrimstore_f(struct objcore *oc, struct dstat *ds);
-typedef void objslim_f(struct objcore *oc, struct dstat *ds);
-typedef void *objgetattr_f(struct objcore *oc, struct dstat *ds,
+typedef void objextend_f(struct objcore *, struct dstat *ds, 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,
enum obj_attr attr, ssize_t *len);
-typedef void *objsetattr_f(const struct vfp_ctx *vc, enum obj_attr attr,
+typedef void *objsetattr_f(const struct vfp_ctx *, enum obj_attr attr,
ssize_t len, const void *ptr);
-typedef uint64_t objgetlen_f(struct objcore *oc, struct dstat *ds);
+typedef uint64_t objgetlen_f(struct worker *, struct objcore *);
struct storeobj_methods {
freeobj_f *freeobj;
More information about the varnish-commit
mailing list