Commit 80459a2c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Clean up stuff that were needed for ws_o

parent e9e8d428
......@@ -180,17 +180,6 @@ STV_alloc(struct stevedore *stv, size_t size)
return (st);
}
/*-------------------------------------------------------------------*
* Structure used to transport internal knowledge from STV_NewObject()
* to STV_MkObject(). Nobody else should mess with this struct.
*/
struct stv_objsecrets {
unsigned magic;
#define STV_OBJ_SECRETES_MAGIC 0x78c87247
unsigned wsl;
};
/*--------------------------------------------------------------------
* This function is called by stevedores ->allocobj() method, which
* very often will be stv_default_allocobj() below, to convert a slab
......@@ -200,29 +189,20 @@ struct stv_objsecrets {
*/
struct object *
STV_MkObject(struct stevedore *stv, struct busyobj *bo,
void *ptr, unsigned ltot, const struct stv_objsecrets *soc)
STV_MkObject(struct stevedore *stv, struct busyobj *bo, void *ptr)
{
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);
CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
assert(PAOK(ptr));
assert(PAOK(soc->wsl));
assert(ltot >= sizeof *o + soc->wsl);
o = ptr;
memset(o, 0, sizeof *o);
o->magic = OBJECT_MAGIC;
l = PRNDDN(ltot - sizeof *o);
assert(l >= soc->wsl);
VTAILQ_INIT(&o->body->list);
bo->fetch_objcore->stobj->magic = STOREOBJ_MAGIC;
......@@ -241,13 +221,11 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
*/
struct object *
stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
unsigned ltot, const struct stv_objsecrets *soc)
stv_default_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
{
struct object *o;
struct storage *st;
CHECK_OBJ_NOTNULL(soc, STV_OBJ_SECRETES_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
st = stv->alloc(stv, ltot);
if (st == NULL)
......@@ -256,8 +234,7 @@ stv_default_allocobj(struct stevedore *stv, struct busyobj *bo,
stv->free(st);
return (NULL);
}
ltot = st->space;
o = STV_MkObject(stv, bo, st->ptr, ltot, soc);
o = STV_MkObject(stv, bo, st->ptr);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
st->len = sizeof(*o);
o->objstore = st;
......@@ -277,7 +254,6 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
struct object *o;
struct stevedore *stv, *stv0;
unsigned ltot;
struct stv_objsecrets soc;
int i;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
......@@ -285,20 +261,16 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
assert(wsl > 0);
wsl = PRNDUP(wsl);
memset(&soc, 0, sizeof soc);
soc.magic = STV_OBJ_SECRETES_MAGIC;
soc.wsl = wsl;
ltot = sizeof *o + wsl;
stv = stv0 = stv_pick_stevedore(bo->vsl, &hint);
AN(stv->allocobj);
o = stv->allocobj(stv, bo, ltot, &soc);
o = stv->allocobj(stv, bo, ltot);
if (o == NULL && hint == NULL) {
do {
stv = stv_pick_stevedore(bo->vsl, &hint);
AN(stv->allocobj);
o = stv->allocobj(stv, bo, ltot, &soc);
o = stv->allocobj(stv, bo, ltot);
} while (o == NULL && stv != stv0);
}
if (o == NULL) {
......@@ -306,7 +278,7 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
for (i = 0; o == NULL && i < cache_param->nuke_limit; i++) {
if (EXP_NukeOne(bo->vsl, bo->stats, stv->lru) == -1)
break;
o = stv->allocobj(stv, bo, ltot, &soc);
o = stv->allocobj(stv, bo, ltot);
}
}
......
......@@ -62,7 +62,7 @@ typedef struct storage *storage_alloc_f(struct stevedore *, size_t size);
typedef void storage_trim_f(struct storage *, size_t size, int move_ok);
typedef void storage_free_f(struct storage *);
typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *,
unsigned ltot, const struct stv_objsecrets *);
unsigned ltot);
typedef void storage_close_f(const struct stevedore *);
typedef void storage_signal_close_f(const struct stevedore *);
typedef int storage_baninfo_f(const struct stevedore *, enum baninfo event,
......@@ -123,7 +123,7 @@ 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 stevedore *stv, struct busyobj *bo,
void *ptr, unsigned ltot, const struct stv_objsecrets *soc);
void *ptr);
struct lru *LRU_Alloc(void);
void LRU_Free(struct lru *lru);
......
......@@ -505,8 +505,7 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
*/
static struct object *
smp_allocobj(struct stevedore *stv, struct busyobj *bo,
unsigned ltot, const struct stv_objsecrets *soc)
smp_allocobj(struct stevedore *stv, struct busyobj *bo, unsigned ltot)
{
struct object *o;
struct storage *st;
......@@ -532,9 +531,8 @@ smp_allocobj(struct stevedore *stv, struct busyobj *bo,
return (NULL);
assert(st->space >= ltot);
ltot = st->space;
o = STV_MkObject(stv, bo, st->ptr, ltot, soc);
o = STV_MkObject(stv, bo, st->ptr);
AN(bo->fetch_objcore->stobj->stevedore);
assert(bo->fetch_objcore->stobj->stevedore == stv);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
......
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