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 <james.r.harris@intel.com>
Change-Id: Id4e3f1538901cf7a3d5f5cec10b18907ca94afe0

Reviewed-on: https://review.gerrithub.io/434114
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2018-10-02 14:57:23 -07:00
parent 5ae61d4286
commit e3a7bf7974

View File

@ -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;