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

STV_{alloc|free|trim}() are only used from SML.

parent cb7c4704
......@@ -1042,10 +1042,6 @@ void RFC2616_Vary_AE(struct http *hp);
/* stevedore.c */
int STV_NewObject(struct worker *, struct objcore *,
const char *hint, unsigned len);
struct storage *STV_alloc(const struct stevedore *, size_t size);
void STV_trim(const struct stevedore *, struct storage *, size_t size,
int move_ok);
void STV_free(const struct stevedore *, struct storage *st);
void STV_open(void);
void STV_close(void);
int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
......
......@@ -101,35 +101,6 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint)
return (stv);
}
/*-------------------------------------------------------------------*/
struct storage *
STV_alloc(const struct stevedore *stv, size_t size)
{
struct storage *st;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
if (size > cache_param->fetch_maxchunksize)
size = cache_param->fetch_maxchunksize;
assert(size <= UINT_MAX); /* field limit in struct storage */
for (;;) {
/* try to allocate from it */
AN(stv->alloc);
st = stv->alloc(stv, size);
if (st != NULL)
break;
if (size <= cache_param->fetch_chunksize)
break;
size >>= 1;
}
CHECK_OBJ_ORNULL(st, STORAGE_MAGIC);
return (st);
}
/*-------------------------------------------------------------------
* Allocate storage for an object, based on the header information.
......@@ -174,27 +145,6 @@ STV_NewObject(struct worker *wrk, struct objcore *oc,
/*-------------------------------------------------------------------*/
void
STV_trim(const struct stevedore *stv, struct storage *st, size_t size,
int move_ok)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
if (stv->trim)
stv->trim(st, size, move_ok);
}
void
STV_free(const struct stevedore *stv, struct storage *st)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
AN(stv->free);
stv->free(st);
}
void
STV_open(void)
{
......
......@@ -86,9 +86,9 @@ struct stevedore {
unsigned transient;
storage_init_f *init; /* called by mgt process */
storage_open_f *open; /* called by cache process */
storage_alloc_f *alloc; /* --//-- */
storage_trim_f *trim; /* --//-- */
storage_free_f *free; /* --//-- */
storage_alloc_f *alloc; /* --//-- only if SML */
storage_trim_f *trim; /* --//-- only if SML */
storage_free_f *free; /* --//-- only if SML */
storage_close_f *close; /* --//-- */
storage_allocobj_f *allocobj; /* --//-- */
storage_signal_close_f *signal_close; /* --//-- */
......
......@@ -39,6 +39,57 @@
#include "storage/storage.h"
#include "storage/storage_simple.h"
/*-------------------------------------------------------------------*/
static struct storage *
sml_stv_alloc(const struct stevedore *stv, size_t size)
{
struct storage *st;
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
if (size > cache_param->fetch_maxchunksize)
size = cache_param->fetch_maxchunksize;
assert(size <= UINT_MAX); /* field limit in struct storage */
for (;;) {
/* try to allocate from it */
AN(stv->alloc);
st = stv->alloc(stv, size);
if (st != NULL)
break;
if (size <= cache_param->fetch_chunksize)
break;
size >>= 1;
}
CHECK_OBJ_ORNULL(st, STORAGE_MAGIC);
return (st);
}
static void
sml_stv_free(const struct stevedore *stv, struct storage *st)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
AN(stv->free);
stv->free(st);
}
static void
sml_stv_trim(const struct stevedore *stv, struct storage *st, size_t size,
int move_ok)
{
CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
if (stv->trim)
stv->trim(st, size, move_ok);
}
/*--------------------------------------------------------------------
* This function is called by stevedores ->allocobj() method, which
* very often will be SML_allocobj() below, to convert a slab
......@@ -142,7 +193,7 @@ sml_objfree(struct worker *wrk, struct objcore *oc)
CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
o->magic = 0;
STV_free(oc->stobj->stevedore, o->objstore);
sml_stv_free(oc->stobj->stevedore, o->objstore);
memset(oc->stobj, 0, sizeof oc->stobj);
......@@ -269,7 +320,7 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size)
for (fail = 0; fail <= cache_param->nuke_limit; fail++) {
/* try to allocate from it */
AN(stv->alloc);
st = STV_alloc(stv, size);
st = sml_stv_alloc(stv, size);
if (st != NULL)
break;
......@@ -372,9 +423,9 @@ sml_trimstore(struct worker *wrk, struct objcore *oc)
return;
if (st->len == 0) {
VTAILQ_REMOVE(&o->list, st, list);
STV_free(stv, st);
sml_stv_free(stv, st);
} else if (st->len < st->space) {
STV_trim(stv, st, st->len, 1);
sml_stv_trim(stv, st, st->len, 1);
}
}
......@@ -393,13 +444,13 @@ sml_slim(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->esidata != NULL) {
STV_free(stv, o->esidata);
sml_stv_free(stv, o->esidata);
o->esidata = NULL;
}
VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
VTAILQ_REMOVE(&o->list, st, list);
STV_free(stv, st);
sml_stv_free(stv, 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