[6.0] a4c8da94f Remove stale cluster segments when their refcount goes to zero

Martin Blix Grydeland martin at varnish-software.com
Fri Oct 18 13:23:07 UTC 2019


commit a4c8da94fdd4f1d772eeddcbff109d7dcf85fd64
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Aug 30 15:24:32 2019 +0200

    Remove stale cluster segments when their refcount goes to zero
    
    When a cluster is marked stale, there is no mechanism to actually remove
    it once all its containing segments (which would also be marked stale)
    goes away.
    
    Fix this by executing vsm_delseg on the cluster in VSM_Unmap if it is marked
    stale.

diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index 06f13af28..5c2d6efe1 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -933,8 +933,13 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
 		assert(vg->s == NULL);
 		assert(vg->sz == 0);
 		assert(vg->cluster->refs > 0);
-		if (--vg->cluster->refs == 0)
+		if (--vg->cluster->refs == 0) {
 			vsm_unmapseg(vg->cluster);
+			if (vg->cluster->flags & VSM_FLAG_STALE) {
+				AN(vg->flags & VSM_FLAG_STALE);
+				vsm_delseg(vg->cluster, 0);
+			}
+		}
 		vg->b = vg->e = NULL;
 	} else {
 		vsm_unmapseg(vg);


More information about the varnish-commit mailing list