Commit 53e74e4d authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Report BAN event persistence failures back to cache_ban.c

parent 8e646cfb
......@@ -1060,7 +1060,7 @@ void STV_free(struct storage *st);
void STV_open(void);
void STV_close(void);
void STV_Freestore(struct object *o);
void STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
/* storage_synth.c */
struct vsb *SMS_Makesynth(struct object *obj);
......
......@@ -484,7 +484,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)
STV_BanInfo(BI_NEW, b->spec, ln); /* Notify stevedores */
AZ(STV_BanInfo(BI_NEW, b->spec, ln)); /* Notify stevedores */
Lck_Unlock(&ban_mtx);
if (be == NULL)
......@@ -690,7 +690,7 @@ BAN_Compile(void)
AZ(ban_shutdown);
/* Do late reporting of ban_magic */
STV_BanInfo(BI_NEW, ban_magic->spec, ban_len(ban_magic->spec));
AZ(STV_BanInfo(BI_NEW, ban_magic->spec, ban_len(ban_magic->spec)));
ban_start = VTAILQ_FIRST(&ban_head);
WRK_BgThread(&ban_thread, "ban-lurker", ban_lurker, NULL);
......@@ -883,7 +883,7 @@ ban_cleantail(void)
VSC_C_main->bans--;
VSC_C_main->bans_deleted++;
VTAILQ_REMOVE(&ban_head, b, list);
STV_BanInfo(BI_DROP, b->spec, ban_len(b->spec));
AZ(STV_BanInfo(BI_DROP, b->spec, ban_len(b->spec)));
} else {
b = NULL;
}
......
......@@ -453,14 +453,23 @@ STV_close(void)
stv->close(stv);
}
void
/*-------------------------------------------------------------------
* Notify the stevedores of BAN related events. A non-zero return
* value indicates that the stevedore is unable to persist the
* event.
*/
int
STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len)
{
struct stevedore *stv;
int r = 0;
VTAILQ_FOREACH(stv, &stv_stevedores, list)
if (stv->baninfo != NULL)
stv->baninfo(stv, event, ban, len);
r |= stv->baninfo(stv, event, ban, len);
return (r);
}
/*--------------------------------------------------------------------
......
......@@ -48,7 +48,7 @@ typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *,
struct objcore **, unsigned ltot, const struct stv_objsecrets *);
typedef void storage_close_f(const struct stevedore *);
typedef void storage_signal_close_f(const struct stevedore *);
typedef void storage_baninfo_f(struct stevedore *, enum baninfo event,
typedef int storage_baninfo_f(struct stevedore *, enum baninfo event,
const uint8_t *ban, unsigned len);
/* Prototypes for VCL variable responders */
......
......@@ -68,37 +68,43 @@ static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos);
* Add bans to silos
*/
static void
static int
smp_appendban(struct smp_sc *sc, struct smp_signspace *spc,
uint32_t len, const uint8_t *ban)
{
(void)sc;
assert(SIGNSPACE_FREE(spc) >= len);
if (SIGNSPACE_FREE(spc) < len)
return (-1);
memcpy(SIGNSPACE_FRONT(spc), ban, len);
smp_append_signspace(spc, len);
return (0);
}
/* Trust that cache_ban.c takes care of locking */
static void
static int
smp_baninfo(struct stevedore *stv, enum baninfo event,
const uint8_t *ban, unsigned len)
{
struct smp_sc *sc;
int r = 0;
CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
switch (event) {
case BI_NEW:
smp_appendban(sc, &sc->ban1, len, ban);
smp_appendban(sc, &sc->ban2, len, ban);
r |= smp_appendban(sc, &sc->ban1, len, ban);
r |= smp_appendban(sc, &sc->ban2, len, ban);
break;
default:
/* Ignored */
break;
}
return (r);
}
/*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment