Commit 71891866 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Simplify HSH_Lookup 3/N

Use req->hash_always_miss directly

Inspired by:    #2856
parent 5ee0e257
...@@ -338,8 +338,7 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) ...@@ -338,8 +338,7 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh)
*/ */
enum lookup_e enum lookup_e
HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
int always_insert)
{ {
struct worker *wrk; struct worker *wrk;
struct objhead *oh; struct objhead *oh;
...@@ -384,7 +383,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ...@@ -384,7 +383,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
Lck_AssertHeld(&oh->mtx); Lck_AssertHeld(&oh->mtx);
if (always_insert) { if (req->hash_always_miss) {
/* XXX: should we do predictive Vary in this case ? */ /* XXX: should we do predictive Vary in this case ? */
/* Insert new objcore in objecthead and release mutex */ /* Insert new objcore in objecthead and release mutex */
*bocp = hsh_insert_busyobj(wrk, oh); *bocp = hsh_insert_busyobj(wrk, oh);
...@@ -472,7 +471,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ...@@ -472,7 +471,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
wrk->stats->cache_hitmiss++; wrk->stats->cache_hitmiss++;
VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl);
return (HSH_HITMISS); return (HSH_HITMISS);
} }
if (oc->hits < LONG_MAX) if (oc->hits < LONG_MAX)
oc->hits++; oc->hits++;
AN(hsh_deref_objhead_unlock(wrk, &oh)); AN(hsh_deref_objhead_unlock(wrk, &oh));
......
...@@ -68,8 +68,7 @@ int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax); ...@@ -68,8 +68,7 @@ int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax);
#define HSH_RUSH_POLICY -1 #define HSH_RUSH_POLICY -1
#define HSH_RUSH_ALL INT_MAX #define HSH_RUSH_ALL INT_MAX
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **);
int always_insert);
void HSH_Ref(struct objcore *o); void HSH_Ref(struct objcore *o);
void HSH_AddString(struct req *, void *ctx, const char *str); void HSH_AddString(struct req *, void *ctx, const char *str);
unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now, unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now,
......
...@@ -495,7 +495,7 @@ cnt_lookup(struct worker *wrk, struct req *req) ...@@ -495,7 +495,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
AZ(req->objcore); AZ(req->objcore);
if (req->hash_objhead) if (req->hash_objhead)
had_objhead = 1; had_objhead = 1;
lr = HSH_Lookup(req, &oc, &busy, req->hash_always_miss ? 1 : 0); lr = HSH_Lookup(req, &oc, &busy);
if (lr == HSH_BUSY) { if (lr == HSH_BUSY) {
/* /*
* We lost the session to a busy object, disembark the * We lost the session to a busy object, disembark the
...@@ -986,7 +986,8 @@ cnt_purge(struct worker *wrk, struct req *req) ...@@ -986,7 +986,8 @@ cnt_purge(struct worker *wrk, struct req *req)
VRY_Prep(req); VRY_Prep(req);
AZ(req->objcore); AZ(req->objcore);
lr = HSH_Lookup(req, &oc, &boc, 1); req->hash_always_miss = 1;
lr = HSH_Lookup(req, &oc, &boc);
assert (lr == HSH_MISS); assert (lr == HSH_MISS);
AZ(oc); AZ(oc);
CHECK_OBJ_NOTNULL(boc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(boc, OBJCORE_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