Commit 219aa029 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Eliminate struct sess from HSH_Insert()

parent 1bda6584
......@@ -800,7 +800,7 @@ ban_CheckLast(void)
* Ban lurker thread
*/
static int
static int __match_proto__(bgthread_t)
ban_lurker_work(const struct sess *sp, unsigned pass)
{
struct ban *b, *b0, *b2;
......
......@@ -329,7 +329,7 @@ EXP_Rearm(const struct object *o)
* object expires, accounting also for graceability, it is killed.
*/
static void * __match_proto__(void *start_routine(void *))
static void * __match_proto__(bgthread_t)
exp_timer(struct sess *sp, void *priv)
{
struct objcore *oc;
......
......@@ -245,26 +245,21 @@ hsh_testmagic(void *result)
*/
void
HSH_Insert(const struct sess *sp, const void *digest, struct objcore *oc)
HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc)
{
struct worker *wrk;
struct objhead *oh;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(digest);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
wrk = sp->wrk;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
hsh_prealloc(wrk);
if (cache_param->diag_bitmap & 0x80000000)
hsh_testmagic(wrk->nobjhead->digest);
AZ(sp->req);
AN(wrk->nobjhead);
memcpy(wrk->nobjhead->digest, digest, SHA256_LEN);
oh = hash->lookup(sp, wrk->nobjhead);
oh = hash->lookup(wrk, wrk->nobjhead);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
if (oh == wrk->nobjhead)
wrk->nobjhead = NULL;
......@@ -320,7 +315,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
sp->req->hash_objhead = NULL;
} else {
AN(wrk->nobjhead);
oh = hash->lookup(sp, wrk->nobjhead);
oh = hash->lookup(wrk, wrk->nobjhead);
if (oh == wrk->nobjhead)
wrk->nobjhead = NULL;
}
......
......@@ -54,7 +54,7 @@ static struct hcl_hd *hcl_head;
* The ->init method allows the management process to pass arguments
*/
static void
static void __match_proto__(hash_init_f)
hcl_init(int ac, char * const *av)
{
int i;
......@@ -86,7 +86,7 @@ hcl_init(int ac, char * const *av)
* initialization to happen before the first lookup.
*/
static void
static void __match_proto__(hash_start_f)
hcl_start(void)
{
unsigned u;
......@@ -110,15 +110,15 @@ hcl_start(void)
* rare and collisions even rarer.
*/
static struct objhead *
hcl_lookup(const struct sess *sp, struct objhead *noh)
static struct objhead * __match_proto__(hash_lookup_f)
hcl_lookup(struct worker *wrk, struct objhead *noh)
{
struct objhead *oh;
struct hcl_hd *hp;
unsigned u1, digest;
int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
assert(sizeof noh->digest > sizeof digest);
......@@ -153,7 +153,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
* Dereference and if no references are left, free.
*/
static int
static int __match_proto__(hash_deref_f)
hcl_deref(struct objhead *oh)
{
struct hcl_hd *hp;
......
......@@ -373,7 +373,7 @@ hcb_cleaner(struct sess *sp, void *priv)
/*--------------------------------------------------------------------*/
static void
static void __match_proto__(hash_start_f)
hcb_start(void)
{
struct objhead *oh = NULL;
......@@ -387,7 +387,7 @@ hcb_start(void)
hcb_build_bittbl();
}
static int
static int __match_proto__(hash_deref_f)
hcb_deref(struct objhead *oh)
{
int r;
......@@ -412,28 +412,28 @@ hcb_deref(struct objhead *oh)
return (r);
}
static struct objhead *
hcb_lookup(const struct sess *sp, struct objhead *noh)
static struct objhead * __match_proto__(hash_lookup_f)
hcb_lookup(struct worker *wrk, struct objhead *noh)
{
struct objhead *oh;
struct hcb_y *y;
unsigned u;
unsigned with_lock;
(void)sp;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
with_lock = 0;
while (1) {
if (with_lock) {
CAST_OBJ_NOTNULL(y, sp->wrk->nhashpriv, HCB_Y_MAGIC);
CAST_OBJ_NOTNULL(y, wrk->nhashpriv, HCB_Y_MAGIC);
Lck_Lock(&hcb_mtx);
VSC_C_main->hcb_lock++;
assert(noh->refcnt == 1);
oh = hcb_insert(sp->wrk, &hcb_root, noh, 1);
oh = hcb_insert(wrk, &hcb_root, noh, 1);
Lck_Unlock(&hcb_mtx);
} else {
VSC_C_main->hcb_nolock++;
oh = hcb_insert(sp->wrk, &hcb_root, noh, 0);
oh = hcb_insert(wrk, &hcb_root, noh, 0);
}
if (oh != NULL && oh == noh) {
......@@ -468,7 +468,7 @@ hcb_lookup(const struct sess *sp, struct objhead *noh)
}
}
static void
static void __match_proto__(hash_prep_f)
hcb_prep(struct worker *wrk)
{
struct hcb_y *y;
......
......@@ -45,7 +45,7 @@ static struct lock hsl_mtx;
* initialization to happen before the first lookup.
*/
static void
static void __match_proto__(hash_start_f)
hsl_start(void)
{
......@@ -59,13 +59,13 @@ hsl_start(void)
* A reference to the returned object is held.
*/
static struct objhead *
hsl_lookup(const struct sess *sp, struct objhead *noh)
static struct objhead * __match_proto__(hash_lookup_f)
hsl_lookup(struct worker *wrk, struct objhead *noh)
{
struct objhead *oh;
int i;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(noh, OBJHEAD_MAGIC);
Lck_Lock(&hsl_mtx);
VTAILQ_FOREACH(oh, &hsl_head, hoh_list) {
......@@ -92,7 +92,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
* Dereference and if no references are left, free.
*/
static int
static int __match_proto__(hash_deref_f)
hsl_deref(struct objhead *oh)
{
int ret;
......
......@@ -36,7 +36,7 @@ typedef void hash_init_f(int ac, char * const *av);
typedef void hash_start_f(void);
typedef void hash_prep_f(struct worker *);
typedef struct objhead *
hash_lookup_f(const struct sess *sp, struct objhead *nobj);
hash_lookup_f(struct worker *wrk, struct objhead *nobj);
typedef int hash_deref_f(struct objhead *obj);
struct hash_slinger {
......@@ -58,7 +58,7 @@ void HSH_Ref(struct objcore *o);
void HSH_Drop(struct worker *, struct object **);
void HSH_Init(const struct hash_slinger *slinger);
void HSH_AddString(const struct sess *sp, const char *str);
void HSH_Insert(const struct sess *sp, const void *hash, struct objcore *);
void HSH_Insert(struct worker *, const void *hash, struct objcore *);
void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace);
void HSH_config(const char *h_arg);
......
......@@ -267,19 +267,19 @@ smp_open_segs(struct smp_sc *sc, struct smp_signctx *ctx)
* Silo worker thread
*/
static void *
static void * __match_proto__(bgthread_t)
smp_thread(struct sess *sp, void *priv)
{
struct smp_sc *sc;
struct smp_seg *sg;
(void)sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CAST_OBJ_NOTNULL(sc, priv, SMP_SC_MAGIC);
/* First, load all the objects from all segments */
VTAILQ_FOREACH(sg, &sc->segments, list)
if (sg->flags & SMP_SEG_MUSTLOAD)
smp_load_seg(sp, sc, sg);
smp_load_seg(sp->wrk, sc, sg);
sc->flags |= SMP_SC_LOADED;
BAN_TailDeref(&sc->tailban);
......
......@@ -167,8 +167,7 @@ void smp_mgt_init(struct stevedore *parent, int ac, char * const *av);
/* storage_persistent_silo.c */
void smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
struct smp_seg *sg);
void smp_load_seg(struct worker *, const struct smp_sc *sc, struct smp_seg *sg);
void smp_new_seg(struct smp_sc *sc);
void smp_close_seg(struct smp_sc *sc, struct smp_seg *sg);
void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx);
......
......@@ -118,7 +118,7 @@ smp_save_segs(struct smp_sc *sc)
*/
void
smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
struct smp_seg *sg)
{
struct smp_object *so;
......@@ -128,7 +128,7 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
struct smp_signctx ctx[1];
ASSERT_SILO_THREAD(sc);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(sg, SMP_SEG_MAGIC);
CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
assert(sg->flags & SMP_SEG_MUSTLOAD);
......@@ -156,11 +156,11 @@ smp_load_seg(const struct sess *sp, const struct smp_sc *sc,
oc->flags &= ~OC_F_BUSY;
smp_init_oc(oc, sg, no);
oc->ban = BAN_RefBan(oc, so->ban, sc->tailban);
HSH_Insert(sp, so->hash, oc);
HSH_Insert(wrk, so->hash, oc);
EXP_Inject(oc, sg->lru, so->ttl);
sg->nobj++;
}
WRK_SumStat(sp->wrk);
WRK_SumStat(wrk);
sg->flags |= SMP_SEG_LOADED;
}
......
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