Commit d299d768 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Cherry-picking from Martins obj/objcore/exp patch:

move n_object accounting responsibility to stevedores.

Fix n_object accounting detail in persistent.
parent 74889dda
......@@ -403,7 +403,7 @@ struct storage {
typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc);
typedef unsigned getxid_f(struct dstat *ds, struct objcore *oc);
typedef void updatemeta_f(struct objcore *oc);
typedef void freeobj_f(struct objcore *oc);
typedef void freeobj_f(struct dstat *ds, struct objcore *oc);
typedef struct lru *getlru_f(const struct objcore *oc);
struct objcore_methods {
......@@ -479,13 +479,14 @@ oc_updatemeta(struct objcore *oc)
}
static inline void
oc_freeobj(struct objcore *oc)
oc_freeobj(struct dstat *ds, struct objcore *oc)
{
AN(ds);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(oc->methods);
AN(oc->methods->freeobj);
oc->methods->freeobj(oc);
oc->methods->freeobj(ds, oc);
}
static inline struct lru *
......
......@@ -534,9 +534,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if (bo->failed && !bo->do_stream) {
assert(bo->state < BOS_STREAM);
if (bo->fetch_obj != NULL) {
oc_freeobj(bo->fetch_objcore);
oc_freeobj(bo->stats, bo->fetch_objcore);
bo->fetch_obj = NULL;
bo->stats->n_object--;
}
return (F_STP_ERROR);
}
......
......@@ -804,10 +804,8 @@ HSH_DerefObjCore(struct dstat *ds, struct objcore **ocp)
BAN_DestroyObj(oc);
AZ(oc->ban);
if (oc->methods != NULL) {
oc_freeobj(oc);
ds->n_object--;
}
if (oc->methods != NULL)
oc_freeobj(ds, oc);
FREE_OBJ(oc);
ds->n_objectcore--;
......
......@@ -69,11 +69,12 @@ default_oc_getobj(struct dstat *ds, struct objcore *oc)
return (o);
}
static void
default_oc_freeobj(struct objcore *oc)
static void __match_proto__(freeobj_f)
default_oc_freeobj(struct dstat *ds, struct objcore *oc)
{
struct object *o;
AN(ds);
CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
oc->priv = NULL;
oc->methods = NULL;
......@@ -81,9 +82,11 @@ default_oc_freeobj(struct objcore *oc)
STV_Freestore(o);
STV_free(o->objstore);
ds->n_object--;
}
static struct lru *
static struct lru * __match_proto__(getlru_f)
default_oc_getlru(const struct objcore *oc)
{
struct stevedore *stv;
......@@ -285,7 +288,6 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
o->http->magic = HTTP_MAGIC;
o->exp = bo->exp;
VTAILQ_INIT(&o->store);
bo->stats->n_object++;
o->objcore = bo->fetch_objcore;
......@@ -321,6 +323,7 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
o = STV_MkObject(stv, bo, st->ptr, ltot, soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
o->objstore = st;
bo->stats->n_object++;
return (o);
}
......
......@@ -534,6 +534,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo,
o = STV_MkObject(stv, bo, st->ptr, ltot, soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
o->objstore = st;
bo->stats->n_object++;
oc = o->objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
......
......@@ -503,12 +503,13 @@ smp_oc_updatemeta(struct objcore *oc)
}
}
static void __match_proto__()
smp_oc_freeobj(struct objcore *oc)
static void __match_proto__(freeobj_f)
smp_oc_freeobj(struct dstat *ds, struct objcore *oc)
{
struct smp_seg *sg;
struct smp_object *so;
AN(ds);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
......@@ -519,9 +520,14 @@ smp_oc_freeobj(struct objcore *oc)
so->ptr = 0;
assert(sg->nobj > 0);
assert(sg->nfixed > 0);
sg->nobj--;
sg->nfixed--;
if (oc->flags & OC_F_NEEDFIXUP) {
ds->n_vampireobject--;
} else {
assert(sg->nfixed > 0);
sg->nfixed--;
ds->n_object--;
}
Lck_Unlock(&sg->sc->mtx);
}
......@@ -530,7 +536,7 @@ smp_oc_freeobj(struct objcore *oc)
* Find the per-segment lru list for this object
*/
static struct lru *
static struct lru * __match_proto__(getlru_f)
smp_oc_getlru(const struct objcore *oc)
{
struct smp_seg *sg;
......
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