[master] 9d6a0e02f debug storage: We need to wrap the extend function, too

Nils Goroll nils.goroll at uplex.de
Fri Apr 11 14:35:08 UTC 2025


commit 9d6a0e02f158f82e401d8c131e1f12aff8b124cf
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Apr 11 16:29:42 2025 +0200

    debug storage: We need to wrap the extend function, too

diff --git a/bin/varnishd/storage/storage_debug.c b/bin/varnishd/storage/storage_debug.c
index e144f9648..7689f2849 100644
--- a/bin/varnishd/storage/storage_debug.c
+++ b/bin/varnishd/storage/storage_debug.c
@@ -80,7 +80,7 @@ smd_max_getspace(struct worker *wrk, struct objcore *oc, ssize_t *sz,
 	AN(sz);
 	used = (ssize_t)oc->stobj->priv2;
 
-	VSLb(wrk->vsl, SLT_Debug, "-sdebug: %zd/%zd", used, max_size);
+	VSLb(wrk->vsl, SLT_Debug, "-sdebug getspace: %zd/%zd", used, max_size);
 
 	if (used >= max_size) {
 		VSLb(wrk->vsl, SLT_Storage, "-sdebug: max_size=%zd reached", max_size);
@@ -91,11 +91,19 @@ smd_max_getspace(struct worker *wrk, struct objcore *oc, ssize_t *sz,
 	*sz = vmin_t(ssize_t, *sz, max_size - used);
 
 	r = SML_methods.objgetspace(wrk, oc, sz, ptr);
-	if (r != 0)
-		oc->stobj->priv2 = (uint64_t)(used + *sz);
 	return (r);
 }
 
+static void v_matchproto_(objextend_f)
+smd_max_extend(struct worker *wrk, struct objcore *oc, ssize_t l)
+{
+
+	assert(l > 0);
+	oc->stobj->priv2 += (uint64_t)l;
+	VSLb(wrk->vsl, SLT_Debug, "-sdebug extend: %zd/%zd", (ssize_t)oc->stobj->priv2, max_size);
+	SML_methods.objextend(wrk, oc, l);
+}
+
 #define dur_arg(a, s, d)					\
 	(! strncmp((a), (s), strlen(s))				\
 	 && (d = VNUM_duration(a + strlen(s))) != nan(""))
@@ -175,6 +183,7 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 					    smd_stevedore.name);
 				}
 				getspace = smd_max_getspace;
+				methods->objextend = smd_max_extend;
 				continue;
 			}
 			if (dur_arg(a, "dinit=", d)) {


More information about the varnish-commit mailing list