[PATCH 4/7] Try to export the ban list on STV_BanInfo failures.
Martin Blix Grydeland
martin at varnish-software.com
Mon Dec 3 11:09:52 CET 2012
When STV_BanInfo fails, it means the stevedore has run out of space to
persist the list. An export should descrease the size.
---
bin/varnishd/cache/cache_ban.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 4e912ee..e1b60e0 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;
@@ -476,7 +477,7 @@ BAN_Insert(struct ban *b)
else
be = NULL;
- 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)
@@ -587,6 +588,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.
@@ -898,7 +914,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;
}
--
1.7.10.4
More information about the varnish-dev
mailing list