Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit d11bb69

Browse files
committed
hash: Retire HSH_RUSH_POLICY
From now on, the policy will be derived from the objcore.
1 parent a86f11f commit d11bb69

11 files changed

Lines changed: 32 additions & 38 deletions

bin/varnishd/cache/cache_ban_lurker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
332332
if (i)
333333
ObjSendEvent(wrk, oc, OEV_BANCHG);
334334
}
335-
(void)HSH_DerefObjCore(wrk, &oc, 0);
335+
(void)HSH_DerefObjCore(wrk, &oc);
336336
}
337337
}
338338

bin/varnishd/cache/cache_busyobj.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **pbo)
176176
wrk->stats->ws_backend_overflow++;
177177

178178
if (bo->fetch_objcore != NULL) {
179-
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore,
180-
HSH_RUSH_POLICY);
179+
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore);
181180
}
182181

183182
VRT_Assign_Backend(&bo->director_req, NULL);

bin/varnishd/cache/cache_expire.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
213213
ObjSendEvent(wrk, oc, OEV_EXPIRE);
214214
tmpoc = oc;
215215
assert(oc->refcnt >= 2); /* Silence coverity */
216-
(void)HSH_DerefObjCore(wrk, &oc, 0);
216+
(void)HSH_DerefObjCore(wrk, &oc);
217217
AZ(oc);
218218
assert(tmpoc->refcnt >= 1); /* Silence coverity */
219219
}
@@ -287,7 +287,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags, double now)
287287
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
288288
(intmax_t)oc->hits);
289289
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
290-
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
290+
(void)HSH_DerefObjCore(ep->wrk, &oc);
291291
return;
292292
}
293293

@@ -365,7 +365,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
365365
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
366366
(intmax_t)oc->hits);
367367
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
368-
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
368+
(void)HSH_DerefObjCore(ep->wrk, &oc);
369369
}
370370
return (0);
371371
}

bin/varnishd/cache/cache_fetch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
11101110
http_Teardown(bo->beresp);
11111111
// can not make assumptions about the number of references here #3434
11121112
if (bo->bereq_body != NULL)
1113-
(void) HSH_DerefObjCore(bo->wrk, &bo->bereq_body, 0);
1113+
(void)HSH_DerefObjCore(bo->wrk, &bo->bereq_body);
11141114

11151115
if (oc->boc->state == BOS_FINISHED) {
11161116
AZ(oc->flags & OC_F_FAILED);
@@ -1120,7 +1120,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
11201120
// AZ(oc->boc); // XXX
11211121

11221122
if (bo->stale_oc != NULL)
1123-
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
1123+
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
11241124

11251125
wrk->vsl = NULL;
11261126
HSH_DerefBoc(wrk, oc);
@@ -1209,7 +1209,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
12091209
wrk->stats->bgfetch_no_thread++;
12101210
(void)vbf_stp_fail(req->wrk, bo);
12111211
if (bo->stale_oc != NULL)
1212-
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
1212+
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
12131213
HSH_DerefBoc(wrk, oc);
12141214
SES_Rel(bo->sp);
12151215
THR_SetBusyobj(NULL);
@@ -1232,5 +1232,5 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
12321232
assert(oc->boc == boc);
12331233
HSH_DerefBoc(wrk, oc);
12341234
if (mode == VBF_BACKGROUND)
1235-
(void)HSH_DerefObjCore(wrk, &oc, HSH_RUSH_POLICY);
1235+
(void)HSH_DerefObjCore(wrk, &oc);
12361236
}

bin/varnishd/cache/cache_hash.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
758758
EXP_Remove(ocp[i], NULL);
759759
else
760760
EXP_Rearm(ocp[i], ttl_now, ttl, grace, keep);
761-
(void)HSH_DerefObjCore(wrk, &ocp[i], 0);
761+
(void)HSH_DerefObjCore(wrk, &ocp[i]);
762762
AZ(ocp[i]);
763763
total++;
764764
}
@@ -900,7 +900,7 @@ HSH_Withdraw(struct worker *wrk, struct objcore **ocp)
900900
assert(oh->refcnt > 0);
901901
oc->flags = OC_F_WITHDRAWN;
902902
hsh_rush1(wrk, oc, &rush);
903-
AZ(HSH_DerefObjCoreUnlock(wrk, &oc, 0));
903+
AZ(HSH_DerefObjCoreUnlock(wrk, &oc));
904904

905905
hsh_rush2(wrk, &rush);
906906
}
@@ -1088,7 +1088,7 @@ HSH_DerefBoc(struct worker *wrk, struct objcore *oc)
10881088
*/
10891089

10901090
int
1091-
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
1091+
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp)
10921092
{
10931093
struct objcore *oc;
10941094
struct objhead *oh;
@@ -1101,11 +1101,11 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
11011101
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
11021102

11031103
Lck_Lock(&oh->mtx);
1104-
return (HSH_DerefObjCoreUnlock(wrk, &oc, rushmax));
1104+
return (HSH_DerefObjCoreUnlock(wrk, &oc));
11051105
}
11061106

11071107
int
1108-
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
1108+
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp)
11091109
{
11101110
struct objcore *oc;
11111111
struct objhead *oh;
@@ -1115,8 +1115,6 @@ HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
11151115
TAKE_OBJ_NOTNULL(oc, ocp, OBJCORE_MAGIC);
11161116
assert(oc->refcnt > 0);
11171117

1118-
(void)rushmax;
1119-
11201118
oh = oc->objhead;
11211119
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
11221120

bin/varnishd/cache/cache_objhead.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,8 @@ int HSH_Snipe(const struct worker *, struct objcore *);
7676
struct boc *HSH_RefBoc(const struct objcore *);
7777
void HSH_DerefBoc(struct worker *wrk, struct objcore *);
7878
void HSH_DeleteObjHead(const struct worker *, struct objhead *);
79-
80-
int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax);
81-
#define HSH_RUSH_POLICY -1
82-
83-
int HSH_DerefObjCoreUnlock(struct worker *, struct objcore **, int rushmax);
79+
int HSH_DerefObjCore(struct worker *, struct objcore **);
80+
int HSH_DerefObjCoreUnlock(struct worker *, struct objcore **);
8481
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **);
8582
void HSH_Ref(struct objcore *o);
8683
void HSH_AddString(struct req *, void *ctx, const char *str);

bin/varnishd/cache/cache_req_body.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
8181
if (STV_NewObject(req->wrk, req->body_oc, stv, 0) == 0) {
8282
req->req_body_status = BS_ERROR;
8383
HSH_DerefBoc(req->wrk, req->body_oc);
84-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
84+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
8585
(void)VFP_Error(vfc, "Object allocation failed:"
8686
" Ran out of space in %s", stv->vclname);
8787
return (-1);
@@ -95,7 +95,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
9595
if (VFP_Open(ctx, vfc) < 0) {
9696
req->req_body_status = BS_ERROR;
9797
HSH_DerefBoc(req->wrk, req->body_oc);
98-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
98+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
9999
return (-1);
100100
}
101101

@@ -143,7 +143,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
143143
VSLb_ts_req(req, "ReqBody", VTIM_real());
144144
if (func != NULL) {
145145
HSH_DerefBoc(req->wrk, req->body_oc);
146-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
146+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
147147
if (vfps == VFP_END && r == 0 && (flush & OBJ_ITER_END) == 0)
148148
r = func(priv, flush | OBJ_ITER_END, NULL, 0);
149149
if (vfps != VFP_END) {
@@ -159,7 +159,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
159159

160160
if (vfps != VFP_END) {
161161
req->req_body_status = BS_ERROR;
162-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
162+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
163163
return (-1);
164164
}
165165

@@ -280,7 +280,7 @@ VRB_Free(struct req *req)
280280
if (req->body_oc == NULL)
281281
return;
282282

283-
r = HSH_DerefObjCore(req->wrk, &req->body_oc, 0);
283+
r = HSH_DerefObjCore(req->wrk, &req->body_oc);
284284

285285
// each busyobj may have gained a reference
286286
assert (r >= 0);

bin/varnishd/cache/cache_req_fsm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
219219
ObjTouch(req->wrk, req->objcore, req->t_prev);
220220

221221
if (Resp_Setup_Deliver(req)) {
222-
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
222+
(void)HSH_DerefObjCore(wrk, &req->objcore);
223223
req->err_code = 500;
224224
req->req_step = R_STP_SYNTH;
225225
return (REQ_FSM_MORE);
@@ -237,7 +237,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
237237

238238
if (wrk->vpi->handling != VCL_RET_DELIVER) {
239239
HSH_Cancel(wrk, req->objcore, NULL);
240-
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
240+
(void)HSH_DerefObjCore(wrk, &req->objcore);
241241
http_Teardown(req->resp);
242242

243243
switch (wrk->vpi->handling) {
@@ -412,7 +412,7 @@ cnt_synth(struct worker *wrk, struct req *req)
412412
VSLb(req->vsl, SLT_Error, "Could not get storage");
413413
req->doclose = SC_OVERLOAD;
414414
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
415-
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
415+
(void)HSH_DerefObjCore(wrk, &req->objcore);
416416
http_Teardown(req->resp);
417417
return (REQ_FSM_DONE);
418418
}
@@ -510,7 +510,7 @@ cnt_transmit(struct worker *wrk, struct req *req)
510510
if (boc != NULL)
511511
HSH_DerefBoc(wrk, req->objcore);
512512

513-
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
513+
(void)HSH_DerefObjCore(wrk, &req->objcore);
514514
http_Teardown(req->resp);
515515

516516
req->vdp_filter_list = NULL;
@@ -537,7 +537,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
537537
if (req->objcore->flags & OC_F_FAILED) {
538538
req->err_code = 503;
539539
req->req_step = R_STP_SYNTH;
540-
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
540+
(void)HSH_DerefObjCore(wrk, &req->objcore);
541541
AZ(req->objcore);
542542
return (REQ_FSM_MORE);
543543
}
@@ -665,7 +665,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
665665
}
666666

667667
/* Drop our object, we won't need it */
668-
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
668+
(void)HSH_DerefObjCore(wrk, &req->objcore);
669669

670670
if (busy != NULL) {
671671
HSH_Withdraw(wrk, &busy);
@@ -695,7 +695,7 @@ cnt_miss(struct worker *wrk, struct req *req)
695695
wrk->stats->cache_miss++;
696696
VBF_Fetch(wrk, req, req->objcore, req->stale_oc, VBF_NORMAL);
697697
if (req->stale_oc != NULL)
698-
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
698+
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
699699
req->req_step = R_STP_FETCH;
700700
return (REQ_FSM_MORE);
701701
case VCL_RET_FAIL:
@@ -715,7 +715,7 @@ cnt_miss(struct worker *wrk, struct req *req)
715715
}
716716
VRY_Clear(req);
717717
if (req->stale_oc != NULL)
718-
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
718+
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
719719
HSH_Withdraw(wrk, &req->objcore);
720720
return (REQ_FSM_MORE);
721721
}

bin/varnishd/cache/cache_vrt_var.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ VRT_u_bereq_body(VRT_CTX)
630630
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
631631
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
632632
if (ctx->bo->bereq_body != NULL) {
633-
(void)HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body, 0);
633+
(void)HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body);
634634
http_Unset(ctx->bo->bereq, H_Content_Length);
635635
}
636636

bin/varnishd/storage/storage_lru.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ LRU_NukeOne(struct worker *wrk, struct lru *lru)
205205
ObjSlim(wrk, oc);
206206

207207
VSLb(wrk->vsl, SLT_ExpKill, "LRU xid=%ju", VXID(ObjGetXID(wrk, oc)));
208-
(void)HSH_DerefObjCore(wrk, &oc, 0); // Ref from HSH_Snipe
208+
(void)HSH_DerefObjCore(wrk, &oc); // Ref from HSH_Snipe
209209
return (1);
210210
}

0 commit comments

Comments
 (0)