From d435babc783fa73f430fd8fc620c285ecb7c9906 Mon Sep 17 00:00:00 2001 From: Nils Goroll Date: Sat, 12 Oct 2024 23:45:49 +0200 Subject: [PATCH] =?UTF-8?q?Who=20said=20they=20wanted=20to=20keep=2032bit?= =?UTF-8?q?=20alive=20as=20an=20option=3F=20=F0=9F=A4=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/varnishd/storage/storage_simple.c | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 835a8f42fd..b3e5283c48 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -327,13 +327,34 @@ struct sml_hdl { uint64_t avail, returned; }; +static inline uint64_t +st2lease(const struct storage *st) +{ + uint64_t r = (uintptr_t)st; + + if (sizeof(void *) < 8) + r <<= 1; + + return (r); +} + +static inline struct storage * +lease2st(uint64_t l) +{ + + if (sizeof(void *) < 8) + l >>= 1; + + return ((void *)l); +} + static inline void sml_ai_viov_fill(struct viov *viov, struct storage *st) { INIT_OBJ(viov, VIOV_MAGIC); viov->iov.iov_base = st->ptr; viov->iov.iov_len = st->len; - viov->lease = (uintptr_t)st; + viov->lease = st2lease(st); VAI_ASSERT_LEASE(viov->lease); } @@ -460,7 +481,7 @@ sml_ai_lease_boc(struct worker *wrk, vai_hdl vhdl, struct viov *viov, int viovcn VSLb(wrk->vsl, SLT_Debug, "off %zu + l %zu == space st %p next st %p stvprv %p", hdl->st_off, l, hdl->st, next, hdl->boc->stevedore_priv); #endif - viov->lease = (uintptr_t)hdl->st; + viov->lease = st2lease(hdl->st); hdl->st_off = 0; hdl->st = next; } @@ -499,7 +520,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, uint64_t *leases, int leasecnt) for (p = leases, end = leases + leasecnt; p < end; p++) { if (*p == sml_ai_lease_frag) continue; - CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC); + CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC); VTAILQ_REMOVE(&hdl->obj->list, st, list); if (st == hdl->boc->stevedore_priv) hdl->boc->stevedore_priv = trim_once; @@ -509,7 +530,7 @@ sml_ai_return(struct worker *wrk, vai_hdl vhdl, uint64_t *leases, int leasecnt) for (p = leases; p < end; p++) { if (*p == sml_ai_lease_frag) continue; - CAST_OBJ_NOTNULL(st, (void *)*p, STORAGE_MAGIC); + CAST_OBJ_NOTNULL(st, lease2st(*p), STORAGE_MAGIC); sml_stv_free(hdl->stv, st); } }