From e3a7bf7974a585f7ffb035146f44ebd8a40b45f1 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 2 Oct 2018 14:57:23 -0700 Subject: [PATCH] reduce: add _reduce_persist() This is just a wrapper around the pmem_persist/pmem_sync calls. It basically turns this: if (vol->pm_file.pm_is_pmem) { pmem_persist(buf, sizeof(buf)); } else { pmem_msync(buf, sizeof(buf)); } into this: _reduce_persist(vol, buf, sizeof(buf)); Signed-off-by: Jim Harris Change-Id: Id4e3f1538901cf7a3d5f5cec10b18907ca94afe0 Reviewed-on: https://review.gerrithub.io/434114 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Paul Luse Reviewed-by: Ben Walker --- lib/reduce/reduce.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index 563e2dc81..3fdc1c8dc 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -106,6 +106,16 @@ struct spdk_reduce_vol { */ #define REDUCE_NUM_EXTRA_CHUNKS 128 +static void +_reduce_persist(struct spdk_reduce_vol *vol, const void *addr, size_t len) +{ + if (vol->pm_file.pm_is_pmem) { + pmem_persist(addr, len); + } else { + pmem_msync(addr, len); + } +} + static inline uint64_t divide_round_up(uint64_t num, uint64_t divisor) { @@ -478,11 +488,7 @@ spdk_reduce_vol_init(struct spdk_reduce_vol_params *params, * Note that this writes 0xFF to not just the logical map but the chunk maps as well. */ memset(vol->pm_logical_map, 0xFF, vol->pm_file.size - sizeof(*vol->backing_super)); - if (vol->pm_file.pm_is_pmem) { - pmem_persist(vol->pm_file.pm_buf, vol->pm_file.size); - } else { - pmem_msync(vol->pm_file.pm_buf, vol->pm_file.size); - } + _reduce_persist(vol, vol->pm_file.pm_buf, vol->pm_file.size); init_ctx->vol = vol; init_ctx->cb_fn = cb_fn;