Commit 1f172c75 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Round to page sizes on signature syncs

parent d49f707a
......@@ -210,6 +210,7 @@ void smp_reset_signspace(struct smp_signspace *spc);
void smp_copy_signspace(struct smp_signspace *dst,
const struct smp_signspace *src);
void smp_trunc_signspace(struct smp_signspace *spc, uint32_t len);
void smp_msync(void *addr, size_t length);
void smp_newsilo(struct smp_sc *sc);
int smp_valid_silo(struct smp_sc *sc);
......
......@@ -156,13 +156,7 @@ smp_reset_sign(struct smp_signctx *ctx)
void
smp_sync_sign(const struct smp_signctx *ctx)
{
int i;
/* XXX: round to pages */
i = msync((void*)ctx->ss, ctx->ss->length + SMP_SIGN_SPACE, MS_SYNC);
if (i && 0)
fprintf(stderr, "SyncSign(%p %s) = %d %s\n",
ctx->ss, ctx->id, i, strerror(errno));
smp_msync(ctx->ss, SMP_SIGN_SPACE + ctx->ss->length);
}
/*--------------------------------------------------------------------
......@@ -267,6 +261,25 @@ smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc,
spc->size = size - SMP_SIGN_SPACE;
}
/*--------------------------------------------------------------------
* Force a write of a memory block (rounded to nearest pages) to
* the backing store.
*/
void
smp_msync(void *addr, size_t length)
{
uintptr_t start, end;
int pagesize;
pagesize = getpagesize();
assert(pagesize > 0 && PWR2(pagesize));
start = RDN2((uintptr_t)addr, pagesize);
end = RUP2((uintptr_t)addr + length, pagesize);
assert(start < end);
AZ(msync((void *)start, end - start, MS_SYNC));
}
/*--------------------------------------------------------------------
* Initialize a Silo with a valid but empty structure.
*
......
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