Commit 149e6277 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Put stats directly in vfp_ctx

parent d1d73339
......@@ -455,6 +455,7 @@ struct vfp_ctx {
unsigned magic;
#define VFP_CTX_MAGIC 0x61d9d3e5
struct busyobj *bo;
struct dstat *stats;
int failed;
......@@ -894,7 +895,7 @@ void EXP_Init(void);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep);
void EXP_Touch(struct objcore *oc, double now);
int EXP_NukeOne(struct busyobj *, struct lru *lru);
int EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru);
/* cache_fetch.c */
enum vbf_fetch_mode_e {
......
......@@ -286,17 +286,20 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
*/
int
EXP_NukeOne(struct busyobj *bo, struct lru *lru)
EXP_NukeOne(struct vsl_log *vsl, struct dstat *ds, struct lru *lru)
{
struct objcore *oc, *oc2;
struct objhead *oh;
AN(vsl);
AN(ds);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
/* Find the first currently unused object on the LRU. */
Lck_Lock(&lru->mtx);
VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) {
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
VSLb(bo->vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
VSLb(vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
oc, oc->flags, oc->refcnt);
AZ(oc->exp_flags & OC_EF_OFFLRU);
......@@ -328,19 +331,17 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru)
Lck_Unlock(&lru->mtx);
if (oc == NULL) {
VSLb(bo->vsl, SLT_ExpKill, "LRU_Fail");
VSLb(vsl, SLT_ExpKill, "LRU_Fail");
return (-1);
}
/* XXX: We could grab and return one storage segment to our caller */
ObjSlim(oc, bo->stats);
ObjSlim(oc, ds);
exp_mail_it(oc);
VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, bo->stats));
AN(bo->stats);
AN(oc);
(void)HSH_DerefObjCore(bo->stats, &oc);
VSLb(vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(oc, ds));
(void)HSH_DerefObjCore(ds, &oc);
return (1);
}
......
......@@ -364,6 +364,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
VFP_Setup(bo->vfc);
bo->vfc->bo = bo;
bo->vfc->stats = bo->stats;
bo->vfc->http = bo->beresp;
bo->vfc->vsl = bo->vsl;
......@@ -684,6 +685,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
VFP_Setup(bo->vfc);
bo->vfc->bo = bo;
bo->vfc->stats = bo->stats;
bo->vfc->http = bo->beresp;
bo->vfc->vsl = bo->vsl;
......
......@@ -86,7 +86,7 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz)
if (st != NULL && st->len < st->space)
return (st);
AN(vc->bo->stats);
AN(vc->stats);
l = fetchfrag;
if (l == 0)
l = sz;
......
......@@ -299,7 +299,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->bo->fetch_objcore, OBJCORE_MAGIC);
o = obj_getobj(vc->bo->fetch_objcore, vc->bo->stats);
o = obj_getobj(vc->bo->fetch_objcore, vc->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
switch (attr) {
case OA_ESIDATA:
......@@ -347,7 +347,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->bo->stats, attr, &l);
vps = ObjGetattr(ocs, vc->stats, attr, &l);
// XXX: later we want to have zero-length OA's too
if (vps == NULL || l <= 0)
return (-1);
......
......@@ -195,7 +195,6 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size)
*/
CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
AN(vc->bo->stats);
stv = vc->body->stevedore;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
......@@ -213,7 +212,7 @@ stv_alloc_obj(const struct vfp_ctx *vc, size_t size)
/* no luck; try to free some space and keep trying */
if (fail < cache_param->nuke_limit &&
EXP_NukeOne(vc->bo, stv->lru) == -1)
EXP_NukeOne(vc->vsl, vc->stats, stv->lru) == -1)
break;
}
CHECK_OBJ_ORNULL(st, STORAGE_MAGIC);
......@@ -349,7 +348,7 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
if (o == NULL) {
/* no luck; try to free some space and keep trying */
for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) {
if (EXP_NukeOne(bo, stv->lru) == -1)
if (EXP_NukeOne(bo->vsl, bo->stats, stv->lru) == -1)
break;
o = stv->allocobj(stv, bo, ltot, &soc);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment