Commit 6cba43b4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Try to read the silo signature to find the correct address to map

the silo into VM.  If this fails or we get garbage, the silo will
be cleared.

Fixes	#962
parent ae07042e
......@@ -120,6 +120,8 @@ void
smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
{
struct smp_sc *sc;
struct smp_sign sgn;
void *target;
int i;
ASSERT_MGT();
......@@ -158,7 +160,15 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
AZ(ftruncate(sc->fd, sc->mediasize));
sc->base = mmap(NULL, sc->mediasize, PROT_READ|PROT_WRITE,
/* Try to determine correct mmap address */
i = read(sc->fd, &sgn, sizeof sgn);
assert(i == sizeof sgn);
if (!strcmp(sgn.ident, "SILO"))
target = (void*)sgn.mapped;
else
target = NULL;
sc->base = mmap(target, sc->mediasize, PROT_READ|PROT_WRITE,
MAP_NOCORE | MAP_NOSYNC | MAP_SHARED, sc->fd, 0);
if (sc->base == MAP_FAILED)
......@@ -169,8 +179,11 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
sc->ident = SIGN_DATA(&sc->idn);
i = smp_valid_silo(sc);
if (i)
if (i) {
printf("Warning SILO (%s) not reloaded (reason=%d)\n",
sc->filename, i);
smp_newsilo(sc);
}
AZ(smp_valid_silo(sc));
smp_metrics(sc);
......
......@@ -238,26 +238,27 @@ smp_valid_silo(struct smp_sc *sc)
assert(strlen(SMP_IDENT_STRING) < sizeof si->ident);
if (smp_chk_sign(&sc->idn))
return (1);
i = smp_chk_sign(&sc->idn);
if (i)
return (i);
si = sc->ident;
if (strcmp(si->ident, SMP_IDENT_STRING))
return (2);
return (12);
if (si->byte_order != 0x12345678)
return (3);
return (13);
if (si->size != sizeof *si)
return (4);
return (14);
if (si->major_version != 2)
return (5);
return (15);
if (si->mediasize != sc->mediasize)
return (7);
return (17);
if (si->granularity != sc->granularity)
return (8);
return (18);
if (si->align < sizeof(void*))
return (9);
return (19);
if (!PWR2(si->align))
return (10);
return (20);
sc->align = si->align;
sc->unique = si->unique;
......
varnishtest "Test address remapping"
server s1 {
rxreq
txresp
} -start
shell "rm -f ${tmpdir}/_.per?"
varnish v1 \
-arg "-pdiag_bitmap=0x20000" \
-storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \
-vcl+backend {
sub vcl_fetch {
set beresp.storage = "s0";
}
} -start
varnish v1 -stop
varnish v1 -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
} -run
varnish v1 -cliok "storage.list"
varnish v1 -cliok "debug.persistent s0 dump"
varnish v1 -cliok "debug.persistent s0 sync"
varnish v1 -stop
varnish v2 \
-arg "-pdiag_bitmap=0x20000" \
-storage "-spersistent,${tmpdir}/_.per2,10m -spersistent,${tmpdir}/_.per1,10m" \
-vcl+backend { } -start
client c1 -connect ${v2_sock} {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
} -run
# shell "rm -f /tmp/__v1/_.per"
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