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 <paul.e.luse@intel.com>
Change-Id: Ida639d2c231833f23131926d442ad430ec903e03
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465805
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
paul luse 2019-08-20 12:25:24 -04:00 committed by Jim Harris
parent ee7024d609
commit ffc17e6e94

View File

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