[master] e4d28b8 Try to export the ban list on STV_BanInfo failures.

Martin Blix Grydeland martin at varnish-cache.org
Thu Dec 13 15:17:15 CET 2012


commit e4d28b8ea95c02e7c5fac193b8cc2bbebff16597
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Nov 30 12:05:06 2012 +0100

    Try to export the ban list on STV_BanInfo failures.
    
    When STV_BanInfo fails, it means the stevedore has run out of space to
    persist the list. An export should descrease the size.

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index ec288d9..09cd7d9 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -99,6 +99,7 @@ struct ban_test {
 	const void		*arg2_spec;
 };
 
+static void ban_info(enum baninfo event, const uint8_t *ban, unsigned len);
 static VTAILQ_HEAD(banhead_s,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head);
 static struct lock ban_mtx;
 static struct ban *ban_magic;
@@ -484,7 +485,7 @@ BAN_Insert(struct ban *b)
 	 * can have entered the cache (thus no objects in the mean
 	 * time depending on ban_magic in the list) */
 	if (b != ban_magic)
-		AZ(STV_BanInfo(BI_NEW, b->spec, ln)); /* Notify stevedores */
+		ban_info(BI_NEW, b->spec, ln); /* Notify stevedores */
 	Lck_Unlock(&ban_mtx);
 
 	if (be == NULL)
@@ -596,6 +597,21 @@ ban_export(void)
 	VSB_delete(&vsb);
 }
 
+static void
+ban_info(enum baninfo event, const uint8_t *ban, unsigned len)
+{
+	if (STV_BanInfo(event, ban, len)) {
+		/* One or more stevedores reported failure. Export the
+		 * list instead. The exported list should take up less
+		 * space due to drops being purged and gones being
+		 * truncated. */
+		/* XXX: Keep some measure of how much space can be
+		 * saved, and only export if it's worth it. Assert if
+		 * not */
+		ban_export();
+	}
+}
+
 /*--------------------------------------------------------------------
  * Put a skeleton ban in the list, unless there is an identical,
  * time & condition, ban already in place.
@@ -914,7 +930,7 @@ ban_cleantail(void)
 			VSC_C_main->bans--;
 			VSC_C_main->bans_deleted++;
 			VTAILQ_REMOVE(&ban_head, b, list);
-			AZ(STV_BanInfo(BI_DROP, b->spec, ban_len(b->spec)));
+			ban_info(BI_DROP, b->spec, ban_len(b->spec));
 		} else {
 			b = NULL;
 		}



More information about the varnish-commit mailing list