reduce: close pm_file during unload

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ibd0026a95cbda1577155a0d9520a93e2e4ba921b

Reviewed-on: https://review.gerrithub.io/430649
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2018-09-23 21:32:56 -07:00
parent dfd44de7de
commit c6323a8d52
3 changed files with 28 additions and 8 deletions

View File

@ -101,6 +101,8 @@ struct spdk_reduce_pm_file {
/** Size of the persistent memory file in bytes. */
uint64_t size;
void (*close)(struct spdk_reduce_pm_file *);
};
typedef void (*spdk_reduce_vol_op_complete)(void *ctx, int ziperrno);

View File

@ -239,6 +239,10 @@ spdk_reduce_vol_unload(struct spdk_reduce_vol *vol,
return;
}
if (vol->pm_file.close != NULL) {
vol->pm_file.close(&vol->pm_file);
}
free(vol);
cb_fn(cb_arg, 0);
}

View File

@ -147,6 +147,21 @@ get_backing_device_size(void)
CU_ASSERT(backing_size == expected_backing_size);
}
static void
pm_file_close(struct spdk_reduce_pm_file *pm_file)
{
free(g_volatile_pm_buf);
g_volatile_pm_buf = NULL;
}
static void
pm_file_destroy(void)
{
CU_ASSERT(g_persistent_pm_buf != NULL);
free(g_persistent_pm_buf);
g_persistent_pm_buf = NULL;
}
static int
pm_file_init(struct spdk_reduce_pm_file *pm_file, struct spdk_reduce_vol_params *params)
{
@ -161,6 +176,7 @@ pm_file_init(struct spdk_reduce_pm_file *pm_file, struct spdk_reduce_vol_params
SPDK_CU_ASSERT_FATAL(g_volatile_pm_buf != NULL);
pm_file->pm_buf = g_volatile_pm_buf;
pm_file->close = pm_file_close;
return 0;
}
@ -233,10 +249,9 @@ init(void)
g_ziperrno = -1;
spdk_reduce_vol_unload(g_vol, unload_cb, NULL);
CU_ASSERT(g_ziperrno == 0);
free(g_persistent_pm_buf);
g_persistent_pm_buf = NULL;
free(g_volatile_pm_buf);
g_volatile_pm_buf = NULL;
CU_ASSERT(g_volatile_pm_buf == NULL);
pm_file_destroy();
}
static void
@ -270,10 +285,9 @@ init_md(void)
g_ziperrno = -1;
spdk_reduce_vol_unload(g_vol, unload_cb, NULL);
CU_ASSERT(g_ziperrno == 0);
free(g_persistent_pm_buf);
g_persistent_pm_buf = NULL;
free(g_volatile_pm_buf);
g_volatile_pm_buf = NULL;
CU_ASSERT(g_volatile_pm_buf == NULL);
pm_file_destroy();
}
int