[master] 563bdd941 sml: Delay freeing of trimmed segments always

Nils Goroll nils.goroll at uplex.de
Mon Sep 30 16:15:05 UTC 2024


commit 563bdd94102421c8c2023638dc0d920603e88c53
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Sep 26 11:53:04 2024 +0200

    sml: Delay freeing of trimmed segments always
    
    sml_trimstore() already delays freeing of a replaced last, smaller segment for
    the reallocation case at the bottom of the function: Because a concurrently
    running iterator might have already taken a reference on a to-be-replaced
    segment, it can not be freed immediately, but rather is kept around until the
    busy object is no more.
    
    This trivial change applies the same also for a segment which turns out to be
    unneeded because writing the object ended with a zero length in this segment.
    
    Simple, but consequential, see next commit

diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 9c720aeb4..74657365a 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -560,7 +560,8 @@ sml_trimstore(struct worker *wrk, struct objcore *oc)
 		Lck_Lock(&oc->boc->mtx);
 		VTAILQ_REMOVE(&o->list, st, list);
 		Lck_Unlock(&oc->boc->mtx);
-		sml_stv_free(stv, st);
+		/* sml_bocdone frees this */
+		oc->boc->stevedore_priv = st;
 		return;
 	}
 


More information about the varnish-commit mailing list