Commit c92ad59c authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Utilize the oc->priv2 variable to store the pointer to the allocating

stevedore for the default case (malloc and file)

Change the type of oc->priv2 from unsigned to uintptr_t (due to
padding this does not increase the size of objcore).

Change the default_oc_getlru to find the stevedore through the
oc->priv2 instead of having to go through (and page-in) the object.
parent e556146d
......@@ -371,7 +371,7 @@ struct objcore {
int refcnt;
struct objcore_methods *methods;
void *priv;
unsigned priv2;
uintptr_t priv2;
struct objhead *objhead;
struct busyobj *busyobj;
double timer_when;
......
......@@ -85,10 +85,10 @@ default_oc_freeobj(struct objcore *oc)
static struct lru *
default_oc_getlru(const struct objcore *oc)
{
struct object *o;
struct stevedore *stv;
CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
return (o->objstore->stevedore->lru);
CAST_OBJ_NOTNULL(stv, (void *)oc->priv2, STEVEDORE_MAGIC);
return (stv->lru);
}
static struct objcore_methods default_oc_methods = {
......@@ -227,12 +227,13 @@ struct stv_objsecrets {
*/
struct object *
STV_MkObject(struct busyobj *bo, struct objcore **ocp, void *ptr, unsigned ltot,
const struct stv_objsecrets *soc)
STV_MkObject(struct stevedore *stv, struct busyobj *bo, struct objcore **ocp,
void *ptr, unsigned ltot, const struct stv_objsecrets *soc)
{
struct object *o;
unsigned l;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(soc, STV_OBJ_SECRETES_MAGIC);
AN(ocp);
......@@ -270,6 +271,7 @@ STV_MkObject(struct busyobj *bo, struct objcore **ocp, void *ptr, unsigned ltot,
o->objcore->methods = &default_oc_methods;
o->objcore->priv = o;
o->objcore->priv2 = (uintptr_t)stv;
}
return (o);
}
......@@ -297,7 +299,7 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
return (NULL);
}
ltot = st->len = st->space;
o = STV_MkObject(bo, ocp, st->ptr, ltot, soc);
o = STV_MkObject(stv, bo, ocp, st->ptr, ltot, soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
o->objstore = st;
return (o);
......
......@@ -92,8 +92,9 @@ extern struct stevedore *stv_transient;
int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx);
uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity,
const char *ctx);
struct object *STV_MkObject(struct busyobj *bo, struct objcore **ocp,
void *ptr, unsigned ltot, const struct stv_objsecrets *soc);
struct object *STV_MkObject(struct stevedore *stv, struct busyobj *bo,
struct objcore **ocp, void *ptr, unsigned ltot,
const struct stv_objsecrets *soc);
struct lru *LRU_Alloc(void);
void LRU_Free(struct lru *lru);
......
......@@ -485,7 +485,7 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo, struct objcore **ocp,
assert(st->space >= ltot);
ltot = st->len = st->space;
o = STV_MkObject(bo, ocp, st->ptr, ltot, soc);
o = STV_MkObject(stv, bo, ocp, st->ptr, ltot, soc);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
o->objstore = st;
......
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