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

Commit 5005ea9

Browse files
committed
hash: Retire HSH_RUSH_POLICY
From now on, the policy will be derived from the objcore.
1 parent 3cde9a9 commit 5005ea9

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
@@ -179,8 +179,7 @@ VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **pbo)
179179
wrk->stats->ws_backend_overflow++;
180180

181181
if (bo->fetch_objcore != NULL) {
182-
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore,
183-
HSH_RUSH_POLICY);
182+
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore);
184183
}
185184

186185
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
}
@@ -309,7 +309,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags, double now)
309309
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
310310
(intmax_t)oc->hits);
311311
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
312-
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
312+
(void)HSH_DerefObjCore(ep->wrk, &oc);
313313
return;
314314
}
315315

@@ -387,7 +387,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
387387
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
388388
(intmax_t)oc->hits);
389389
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
390-
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
390+
(void)HSH_DerefObjCore(ep->wrk, &oc);
391391
}
392392
return (0);
393393
}

bin/varnishd/cache/cache_fetch.c

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

11191119
if (oc->boc->state == BOS_FINISHED) {
11201120
AZ(oc->flags & OC_F_FAILED);
@@ -1124,7 +1124,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
11241124
// AZ(oc->boc); // XXX
11251125

11261126
if (bo->stale_oc != NULL)
1127-
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
1127+
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
11281128

11291129
wrk->vsl = NULL;
11301130
HSH_DerefBoc(wrk, oc);
@@ -1215,7 +1215,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
12151215
"No thread available for bgfetch");
12161216
(void)vbf_stp_fail(req->wrk, bo);
12171217
if (bo->stale_oc != NULL)
1218-
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
1218+
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
12191219
HSH_DerefBoc(wrk, oc);
12201220
SES_Rel(bo->sp);
12211221
THR_SetBusyobj(NULL);
@@ -1238,5 +1238,5 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
12381238
assert(oc->boc == boc);
12391239
HSH_DerefBoc(wrk, oc);
12401240
if (mode == VBF_BACKGROUND)
1241-
(void)HSH_DerefObjCore(wrk, &oc, HSH_RUSH_POLICY);
1241+
(void)HSH_DerefObjCore(wrk, &oc);
12421242
}

bin/varnishd/cache/cache_hash.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
760760
EXP_Remove(ocp[i], NULL);
761761
else
762762
EXP_Reduce(ocp[i], ttl_now, ttl, grace, keep);
763-
(void)HSH_DerefObjCore(wrk, &ocp[i], 0);
763+
(void)HSH_DerefObjCore(wrk, &ocp[i]);
764764
AZ(ocp[i]);
765765
total++;
766766
}
@@ -903,7 +903,7 @@ HSH_Withdraw(struct worker *wrk, struct objcore **ocp)
903903
assert(oh->refcnt > 0);
904904
oc->flags = OC_F_WITHDRAWN;
905905
hsh_rush1(wrk, oc, &rush);
906-
AZ(HSH_DerefObjCoreUnlock(wrk, &oc, 0));
906+
AZ(HSH_DerefObjCoreUnlock(wrk, &oc));
907907

908908
hsh_rush2(wrk, &rush);
909909
}
@@ -1098,7 +1098,7 @@ HSH_DerefBoc(struct worker *wrk, struct objcore *oc)
10981098
*/
10991099

11001100
int
1101-
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
1101+
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp)
11021102
{
11031103
struct objcore *oc;
11041104
struct objhead *oh;
@@ -1111,11 +1111,11 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
11111111
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
11121112

11131113
Lck_Lock(&oh->mtx);
1114-
return (HSH_DerefObjCoreUnlock(wrk, &oc, rushmax));
1114+
return (HSH_DerefObjCoreUnlock(wrk, &oc));
11151115
}
11161116

11171117
int
1118-
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
1118+
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp)
11191119
{
11201120
struct objcore *oc;
11211121
struct objhead *oh;
@@ -1125,8 +1125,6 @@ HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
11251125
TAKE_OBJ_NOTNULL(oc, ocp, OBJCORE_MAGIC);
11261126
assert(oc->refcnt > 0);
11271127

1128-
(void)rushmax;
1129-
11301128
oh = oc->objhead;
11311129
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
11321130

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
@@ -80,7 +80,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
8080
if (STV_NewObject(req->wrk, req->body_oc, stv, 0) == 0) {
8181
req->req_body_status = BS_ERROR;
8282
HSH_DerefBoc(req->wrk, req->body_oc);
83-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
83+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
8484
(void)VFP_Error(vfc, "Object allocation failed:"
8585
" Ran out of space in %s", stv->vclname);
8686
return (-1);
@@ -94,7 +94,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
9494
if (VFP_Open(ctx, vfc) < 0) {
9595
req->req_body_status = BS_ERROR;
9696
HSH_DerefBoc(req->wrk, req->body_oc);
97-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
97+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
9898
return (-1);
9999
}
100100

@@ -142,7 +142,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
142142
VSLb_ts_req(req, "ReqBody", VTIM_real());
143143
if (func != NULL) {
144144
HSH_DerefBoc(req->wrk, req->body_oc);
145-
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
145+
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
146146
if (vfps == VFP_END && r == 0 && (flush & OBJ_ITER_END) == 0)
147147
r = func(priv, flush | OBJ_ITER_END, NULL, 0);
148148
if (vfps != VFP_END) {
@@ -158,7 +158,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
158158

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

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

282-
r = HSH_DerefObjCore(req->wrk, &req->body_oc, 0);
282+
r = HSH_DerefObjCore(req->wrk, &req->body_oc);
283283

284284
// each busyobj may have gained a reference
285285
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) {
@@ -411,7 +411,7 @@ cnt_synth(struct worker *wrk, struct req *req)
411411
VSLb(req->vsl, SLT_Error, "Could not get storage");
412412
req->doclose = SC_OVERLOAD;
413413
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
414-
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
414+
(void)HSH_DerefObjCore(wrk, &req->objcore);
415415
http_Teardown(req->resp);
416416
return (REQ_FSM_DONE);
417417
}
@@ -509,7 +509,7 @@ cnt_transmit(struct worker *wrk, struct req *req)
509509
if (boc != NULL)
510510
HSH_DerefBoc(wrk, req->objcore);
511511

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

515515
req->vdp_filter_list = NULL;
@@ -536,7 +536,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
536536
if (req->objcore->flags & OC_F_FAILED) {
537537
req->err_code = 503;
538538
req->req_step = R_STP_SYNTH;
539-
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
539+
(void)HSH_DerefObjCore(wrk, &req->objcore);
540540
AZ(req->objcore);
541541
return (REQ_FSM_MORE);
542542
}
@@ -664,7 +664,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
664664
}
665665

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

669669
if (busy != NULL) {
670670
HSH_Withdraw(wrk, &busy);
@@ -694,7 +694,7 @@ cnt_miss(struct worker *wrk, struct req *req)
694694
wrk->stats->cache_miss++;
695695
VBF_Fetch(wrk, req, req->objcore, req->stale_oc, VBF_NORMAL);
696696
if (req->stale_oc != NULL)
697-
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
697+
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
698698
req->req_step = R_STP_FETCH;
699699
return (REQ_FSM_MORE);
700700
case VCL_RET_FAIL:
@@ -714,7 +714,7 @@ cnt_miss(struct worker *wrk, struct req *req)
714714
}
715715
VRY_Clear(req);
716716
if (req->stale_oc != NULL)
717-
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
717+
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
718718
HSH_Withdraw(wrk, &req->objcore);
719719
return (REQ_FSM_MORE);
720720
}

bin/varnishd/cache/cache_vrt_var.c

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

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)