--- bin/varnishd/storage/storage_persistent.h | 1 + bin/varnishd/storage/storage_persistent_subr.c | 27 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index c4837b9..aceb996 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -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); diff --git a/bin/varnishd/storage/storage_persistent_subr.c b/bin/varnishd/storage/storage_persistent_subr.c index 9933541..f73ae06 100644 --- a/bin/varnishd/storage/storage_persistent_subr.c +++ b/bin/varnishd/storage/storage_persistent_subr.c @@ -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); } /*-------------------------------------------------------------------- @@ -268,6 +262,25 @@ smp_new_signspace(const struct smp_sc *sc, struct smp_signspace *spc, } /*-------------------------------------------------------------------- + * 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. * * XXX: more intelligent sizing of things. -- 1.7.9.5 _______________________________________________ varnish-dev mailing list varnish-dev@varnish-cache.org https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev