Commit 4f479297 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add an objcore->getxid() method.

parent 3ef44da5
...@@ -395,12 +395,14 @@ struct storage { ...@@ -395,12 +395,14 @@ struct storage {
*/ */
typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc); typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc);
typedef unsigned getxid_f(struct worker *wrk, struct objcore *oc);
typedef void updatemeta_f(struct objcore *oc); typedef void updatemeta_f(struct objcore *oc);
typedef void freeobj_f(struct objcore *oc); typedef void freeobj_f(struct objcore *oc);
typedef struct lru *getlru_f(const struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc);
struct objcore_methods { struct objcore_methods {
getobj_f *getobj; getobj_f *getobj;
getxid_f *getxid;
updatemeta_f *updatemeta; updatemeta_f *updatemeta;
freeobj_f *freeobj; freeobj_f *freeobj;
getlru_f *getlru; getlru_f *getlru;
...@@ -429,6 +431,16 @@ struct objcore { ...@@ -429,6 +431,16 @@ struct objcore {
struct ban *ban; struct ban *ban;
}; };
static inline unsigned
oc_getxid(struct worker *wrk, struct objcore *oc)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(oc->methods);
AN(oc->methods->getxid);
return (oc->methods->getxid(wrk, oc));
}
static inline struct object * static inline struct object *
oc_getobj(struct worker *wrk, struct objcore *oc) oc_getobj(struct worker *wrk, struct objcore *oc)
{ {
......
...@@ -401,7 +401,7 @@ exp_timer(struct sess *sp, void *priv) ...@@ -401,7 +401,7 @@ exp_timer(struct sess *sp, void *priv)
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
o = oc_getobj(sp->wrk, oc); o = oc_getobj(sp->wrk, oc);
WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f", WSL(sp->wrk, SLT_ExpKill, 0, "%u %.0f",
o->xid, EXP_Ttl(NULL, o) - t); oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t);
(void)HSH_Deref(sp->wrk, oc, NULL); (void)HSH_Deref(sp->wrk, oc, NULL);
} }
NEEDLESS_RETURN(NULL); NEEDLESS_RETURN(NULL);
...@@ -414,10 +414,9 @@ exp_timer(struct sess *sp, void *priv) ...@@ -414,10 +414,9 @@ exp_timer(struct sess *sp, void *priv)
*/ */
int int
EXP_NukeOne(struct worker *w, struct lru *lru) EXP_NukeOne(struct worker *wrk, struct lru *lru)
{ {
struct objcore *oc; struct objcore *oc;
struct object *o;
/* Find the first currently unused object on the LRU. */ /* Find the first currently unused object on the LRU. */
Lck_Lock(&lru->mtx); Lck_Lock(&lru->mtx);
...@@ -446,9 +445,8 @@ EXP_NukeOne(struct worker *w, struct lru *lru) ...@@ -446,9 +445,8 @@ EXP_NukeOne(struct worker *w, struct lru *lru)
return (-1); return (-1);
/* XXX: bad idea for -spersistent */ /* XXX: bad idea for -spersistent */
o = oc_getobj(w, oc); WSL(wrk, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc));
WSL(w, SLT_ExpKill, 0, "%u LRU", o->xid); (void)HSH_Deref(wrk, oc, NULL);
(void)HSH_Deref(w, NULL, &o);
return (1); return (1);
} }
......
...@@ -48,6 +48,15 @@ static const struct stevedore * volatile stv_next; ...@@ -48,6 +48,15 @@ static const struct stevedore * volatile stv_next;
* Default objcore methods * Default objcore methods
*/ */
static unsigned __match_proto__(getxid_f)
default_oc_getxid(struct worker *wrk, struct objcore *oc)
{
struct object *o;
o = oc_getobj(wrk, oc);
return (o->xid);
}
static struct object * __match_proto__(getobj_f) static struct object * __match_proto__(getobj_f)
default_oc_getobj(struct worker *wrk, struct objcore *oc) default_oc_getobj(struct worker *wrk, struct objcore *oc)
{ {
...@@ -84,6 +93,7 @@ default_oc_getlru(const struct objcore *oc) ...@@ -84,6 +93,7 @@ default_oc_getlru(const struct objcore *oc)
static struct objcore_methods default_oc_methods = { static struct objcore_methods default_oc_methods = {
.getobj = default_oc_getobj, .getobj = default_oc_getobj,
.getxid = default_oc_getxid,
.freeobj = default_oc_freeobj, .freeobj = default_oc_freeobj,
.getlru = default_oc_getlru, .getlru = default_oc_getlru,
}; };
......
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