Commit 74889dda authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make persistent save the entire struct exp rather than only the deadline,

in preparation for moving exp from obj to objcore
parent 9f9c5127
......@@ -928,6 +928,7 @@ extern pthread_t cli_thread;
void EXP_Clr(struct exp *e);
double EXP_Ttl(const struct req *, const struct object*);
double EXP_When(const struct exp *exp);
void EXP_Insert(struct objcore *oc);
void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
void EXP_Init(void);
......
......@@ -87,17 +87,17 @@ EXP_Ttl(const struct req *req, const struct object *o)
}
/*--------------------------------------------------------------------
* Calculate when we should wake up for this object
* Calculate when this object is no longer useful
*/
static double
exp_when(const struct object *o)
double
EXP_When(const struct exp *e)
{
double when;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
when = o->exp.t_origin + o->exp.ttl + o->exp.grace + o->exp.keep;
if (e->t_origin == 0)
return (0.);
when = e->t_origin + e->ttl + e->grace + e->keep;
AZ(isnan(when));
return (when);
}
......@@ -243,7 +243,7 @@ EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep)
if (!isnan(keep))
o->exp.keep = keep;
when = exp_when(o);
when = EXP_When(&o->exp);
VSL(SLT_ExpKill, 0, "EXP_Rearm p=%p E=%.9f e=%.9f f=0x%x", oc,
oc->timer_when, when, oc->flags);
......@@ -391,7 +391,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
if (flags & OC_EF_MOVE) {
o = oc_getobj(&ep->wrk->stats, oc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc->timer_when = exp_when(o);
oc->timer_when = EXP_When(&o->exp);
oc_updatemeta(oc);
}
......
......@@ -473,7 +473,7 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
sc->next_top -= sizeof(**so);
*so = (void*)(sc->base + sc->next_top);
/* Render this smp_object mostly harmless */
(*so)->ttl = 0.;
EXP_Clr(&(*so)->exp);
(*so)->ban = 0.;
(*so)->ptr = 0;
sg->objs = *so;
......@@ -545,7 +545,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo,
/* We have to do this somewhere, might as well be here... */
assert(sizeof so->hash == DIGEST_LEN);
memcpy(so->hash, oc->objhead->digest, DIGEST_LEN);
so->ttl = oc->timer_when;
so->exp = bo->exp;
so->ptr = (uint8_t*)o - sc->base;
so->ban = BAN_Time(oc->ban);
......
......@@ -144,7 +144,7 @@ struct smp_segptr {
struct smp_object {
uint8_t hash[32]; /* really: DIGEST_LEN */
double ttl;
struct exp exp;
double ban;
uint64_t ptr; /* rel to silo */
};
......
......@@ -148,7 +148,7 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
/* Clear the bogus "hold" count */
sg->nobj = 0;
for (;no > 0; so++,no--) {
if (so->ttl == 0 || so->ttl < t_now)
if (EXP_When(&so->exp) < t_now)
continue;
ALLOC_OBJ(oc, OBJCORE_MAGIC);
AN(oc);
......@@ -157,7 +157,7 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
smp_init_oc(oc, sg, no);
oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
HSH_Insert(wrk, so->hash, oc);
EXP_Inject(oc, sg->lru, so->ttl);
EXP_Inject(oc, sg->lru, EXP_When(&so->exp));
sg->nobj++;
}
Pool_Sumstat(wrk);
......@@ -463,7 +463,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc)
if(bad) {
o->exp.ttl = -1;
so->ttl = 0;
EXP_Clr(&so->exp);
}
sg->nfixed++;
......@@ -495,11 +495,11 @@ smp_oc_updatemeta(struct objcore *oc)
/* Lock necessary, we might race close_seg */
Lck_Lock(&sg->sc->mtx);
so->ban = BAN_Time(oc->ban);
so->ttl = oc->timer_when;
so->exp = o->exp;;
Lck_Unlock(&sg->sc->mtx);
} else {
so->ban = BAN_Time(oc->ban);
so->ttl = oc->timer_when;
so->exp = o->exp;;
}
}
......@@ -515,7 +515,7 @@ smp_oc_freeobj(struct objcore *oc)
so = smp_find_so(sg, oc->priv2);
Lck_Lock(&sg->sc->mtx);
so->ttl = 0;
EXP_Clr(&so->exp);
so->ptr = 0;
assert(sg->nobj > 0);
......
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