[master] 63dbc260a Remove stale cluster segments when their refcount goes to zero

Martin Blix Grydeland martin at varnish-software.com
Mon Sep 9 08:23:06 UTC 2019


commit 63dbc260a86aecb694a6483ddfb4a2818d884945
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 6454b06b1..a1961de8d 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -975,8 +975,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