From ffc17e6e94d3ff6f9ff7441b5a42211e2d32df50 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 20 Aug 2019 12:25:24 -0400 Subject: [PATCH] lib/reduce: enable deletion of a vol w/o a pmem file First is a patch series that enables an application to delete a compression vbdev when the volume is missing it's pmem file. Signed-off-by: paul luse Change-Id: Ida639d2c231833f23131926d442ad430ec903e03 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465805 Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/reduce/reduce.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index 7874185ea..03ea2ca81 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -646,6 +646,8 @@ spdk_reduce_vol_init(struct spdk_reduce_vol_params *params, &init_ctx->backing_cb_args); } +static void destroy_load_cb(void *cb_arg, struct spdk_reduce_vol *vol, int reduce_errno); + static void _load_read_super_and_path_cpl(void *cb_arg, int reduce_errno) { @@ -666,6 +668,18 @@ _load_read_super_and_path_cpl(void *cb_arg, int reduce_errno) goto error; } + /* If the cb_fn is destroy_load_cb, it means we are wanting to destroy this compress bdev. + * So don't bother getting the volume ready to use - invoke the callback immediately + * so destroy_load_cb can delete the metadata off of the block device and delete the + * persistent memory file if it exists. + */ + memcpy(vol->pm_file.path, load_ctx->path, sizeof(vol->pm_file.path)); + if (load_ctx->cb_fn == (*destroy_load_cb)) { + load_ctx->cb_fn(load_ctx->cb_arg, vol, 0); + _init_load_cleanup(NULL, load_ctx); + return; + } + memcpy(&vol->params, &vol->backing_super->params, sizeof(vol->params)); vol->backing_io_units_per_chunk = vol->params.chunk_size / vol->params.backing_io_unit_size; vol->logical_blocks_per_chunk = vol->params.chunk_size / vol->params.logical_block_size; @@ -684,7 +698,6 @@ _load_read_super_and_path_cpl(void *cb_arg, int reduce_errno) goto error; } - memcpy(vol->pm_file.path, load_ctx->path, sizeof(vol->pm_file.path)); vol->pm_file.size = _get_pm_file_size(&vol->params); vol->pm_file.pm_buf = pmem_map_file(vol->pm_file.path, 0, 0, 0, &mapped_len, &vol->pm_file.pm_is_pmem);