bdev/compress: replace RPC parm name with pm_path
We decided to name compress bdevs with COMP_ and then the name of the underlying bdev so the RPC parm name was stale. Previously hardcoded the path to PM for early dev so replaced name with pm_path. Note that a sample create looks like this now: rpc.py construct_compress_bdev -b NVMe0n1 -p ~/pm_files -d compress_isal And that devs need to pay attention for the pathname they provide, its easy to leave orphaned pm files around and they can get big. Change-Id: Ifb5245c922461bbecec4bef266bdeb25e8b87f31 Signed-off-by: paul luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452235 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7bffdb2db9
commit
600341b6c5
@ -60,8 +60,6 @@
|
|||||||
|
|
||||||
#define COMP_BDEV_NAME "compress"
|
#define COMP_BDEV_NAME "compress"
|
||||||
|
|
||||||
/* TODO: need to get this from RPC on create or reduce metadata on load */
|
|
||||||
#define TEST_MD_PATH "/tmp"
|
|
||||||
#define DEV_CHUNK_SZ (16 * 1024)
|
#define DEV_CHUNK_SZ (16 * 1024)
|
||||||
#define DEV_LBA_SZ 512
|
#define DEV_LBA_SZ 512
|
||||||
#define DEV_BACKING_IO_SZ (4 * 1024)
|
#define DEV_BACKING_IO_SZ (4 * 1024)
|
||||||
@ -991,7 +989,7 @@ _prepare_for_load_init(struct spdk_bdev *bdev)
|
|||||||
|
|
||||||
/* Call reducelib to initialize a new volume */
|
/* Call reducelib to initialize a new volume */
|
||||||
static void
|
static void
|
||||||
vbdev_init_reduce(struct spdk_bdev *bdev, const char *vbdev_name, const char *comp_pmd)
|
vbdev_init_reduce(struct spdk_bdev *bdev, const char *pm_path, const char *comp_pmd)
|
||||||
{
|
{
|
||||||
struct vbdev_compress *meta_ctx;
|
struct vbdev_compress *meta_ctx;
|
||||||
int rc;
|
int rc;
|
||||||
@ -1015,7 +1013,7 @@ vbdev_init_reduce(struct spdk_bdev *bdev, const char *vbdev_name, const char *co
|
|||||||
* in load.
|
* in load.
|
||||||
*/
|
*/
|
||||||
spdk_reduce_vol_init(&meta_ctx->params, &meta_ctx->backing_dev,
|
spdk_reduce_vol_init(&meta_ctx->params, &meta_ctx->backing_dev,
|
||||||
TEST_MD_PATH,
|
pm_path,
|
||||||
vbdev_reduce_init_cb,
|
vbdev_reduce_init_cb,
|
||||||
meta_ctx);
|
meta_ctx);
|
||||||
}
|
}
|
||||||
@ -1110,7 +1108,7 @@ comp_bdev_ch_destroy_cb(void *io_device, void *ctx_buf)
|
|||||||
|
|
||||||
/* RPC entry point for compression vbdev creation. */
|
/* RPC entry point for compression vbdev creation. */
|
||||||
int
|
int
|
||||||
create_compress_bdev(const char *bdev_name, const char *vbdev_name, const char *comp_pmd)
|
create_compress_bdev(const char *bdev_name, const char *pm_path, const char *comp_pmd)
|
||||||
{
|
{
|
||||||
struct spdk_bdev *bdev;
|
struct spdk_bdev *bdev;
|
||||||
|
|
||||||
@ -1119,7 +1117,7 @@ create_compress_bdev(const char *bdev_name, const char *vbdev_name, const char *
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
vbdev_init_reduce(bdev, vbdev_name, comp_pmd);
|
vbdev_init_reduce(bdev, pm_path, comp_pmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno);
|
|||||||
* Create new compression bdev.
|
* Create new compression bdev.
|
||||||
*
|
*
|
||||||
* \param bdev_name Bdev on which compression bdev will be created.
|
* \param bdev_name Bdev on which compression bdev will be created.
|
||||||
* \param vbdev_name Compression bdev name.
|
* \param pm_path Path to persistent memory.
|
||||||
* \param comp_pmd Compression PMD name.
|
* \param comp_pmd Compression PMD name.
|
||||||
* \return 0 on success, other on failure.
|
* \return 0 on success, other on failure.
|
||||||
*/
|
*/
|
||||||
int create_compress_bdev(const char *bdev_name, const char *vbdev_name, const char *comp_pmd);
|
int create_compress_bdev(const char *bdev_name, const char *pm_path, const char *comp_pmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete compress bdev.
|
* Delete compress bdev.
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
/* Structure to hold the parameters for this RPC method. */
|
/* Structure to hold the parameters for this RPC method. */
|
||||||
struct rpc_construct_compress {
|
struct rpc_construct_compress {
|
||||||
char *base_bdev_name;
|
char *base_bdev_name;
|
||||||
char *name;
|
char *pm_path;
|
||||||
char *comp_pmd;
|
char *comp_pmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ static void
|
|||||||
free_rpc_construct_compress(struct rpc_construct_compress *r)
|
free_rpc_construct_compress(struct rpc_construct_compress *r)
|
||||||
{
|
{
|
||||||
free(r->base_bdev_name);
|
free(r->base_bdev_name);
|
||||||
free(r->name);
|
free(r->pm_path);
|
||||||
free(r->comp_pmd);
|
free(r->comp_pmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Structure to decode the input parameters for this RPC method. */
|
/* Structure to decode the input parameters for this RPC method. */
|
||||||
static const struct spdk_json_object_decoder rpc_construct_compress_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_construct_compress_decoders[] = {
|
||||||
{"base_bdev_name", offsetof(struct rpc_construct_compress, base_bdev_name), spdk_json_decode_string},
|
{"base_bdev_name", offsetof(struct rpc_construct_compress, base_bdev_name), spdk_json_decode_string},
|
||||||
{"name", offsetof(struct rpc_construct_compress, name), spdk_json_decode_string},
|
{"pm_path", offsetof(struct rpc_construct_compress, pm_path), spdk_json_decode_string},
|
||||||
{"comp_pmd", offsetof(struct rpc_construct_compress, comp_pmd), spdk_json_decode_string},
|
{"comp_pmd", offsetof(struct rpc_construct_compress, comp_pmd), spdk_json_decode_string},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,6 +69,7 @@ spdk_rpc_construct_compress_bdev(struct spdk_jsonrpc_request *request,
|
|||||||
{
|
{
|
||||||
struct rpc_construct_compress req = {NULL};
|
struct rpc_construct_compress req = {NULL};
|
||||||
struct spdk_json_write_ctx *w;
|
struct spdk_json_write_ctx *w;
|
||||||
|
char *name;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (spdk_json_decode_object(params, rpc_construct_compress_decoders,
|
if (spdk_json_decode_object(params, rpc_construct_compress_decoders,
|
||||||
@ -78,7 +79,7 @@ spdk_rpc_construct_compress_bdev(struct spdk_jsonrpc_request *request,
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = create_compress_bdev(req.base_bdev_name, req.name, req.comp_pmd);
|
rc = create_compress_bdev(req.base_bdev_name, req.pm_path, req.comp_pmd);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
@ -89,9 +90,11 @@ spdk_rpc_construct_compress_bdev(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_json_write_string(w, req.name);
|
name = spdk_sprintf_alloc("COMP_%s", req.base_bdev_name);
|
||||||
|
spdk_json_write_string(w, name);
|
||||||
spdk_jsonrpc_end_result(request, w);
|
spdk_jsonrpc_end_result(request, w);
|
||||||
free_rpc_construct_compress(&req);
|
free_rpc_construct_compress(&req);
|
||||||
|
free(name);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
|
@ -134,12 +134,12 @@ if __name__ == "__main__":
|
|||||||
def construct_compress_bdev(args):
|
def construct_compress_bdev(args):
|
||||||
print(rpc.bdev.construct_compress_bdev(args.client,
|
print(rpc.bdev.construct_compress_bdev(args.client,
|
||||||
base_bdev_name=args.base_bdev_name,
|
base_bdev_name=args.base_bdev_name,
|
||||||
name=args.name,
|
pm_path=args.pm_path,
|
||||||
comp_pmd=args.comp_pmd))
|
comp_pmd=args.comp_pmd))
|
||||||
p = subparsers.add_parser('construct_compress_bdev',
|
p = subparsers.add_parser('construct_compress_bdev',
|
||||||
help='Add a compress vbdev')
|
help='Add a compress vbdev')
|
||||||
p.add_argument('-b', '--base_bdev_name', help="Name of the base bdev")
|
p.add_argument('-b', '--base_bdev_name', help="Name of the base bdev")
|
||||||
p.add_argument('-c', '--name', help="Name of the compress vbdev")
|
p.add_argument('-p', '--pm_path', help="Path to persistent memory")
|
||||||
p.add_argument('-d', '--comp_pmd', help="Name of the compression device driver")
|
p.add_argument('-d', '--comp_pmd', help="Name of the compression device driver")
|
||||||
p.set_defaults(func=construct_compress_bdev)
|
p.set_defaults(func=construct_compress_bdev)
|
||||||
|
|
||||||
|
@ -15,18 +15,18 @@ def set_bdev_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None):
|
|||||||
return client.call('set_bdev_options', params)
|
return client.call('set_bdev_options', params)
|
||||||
|
|
||||||
|
|
||||||
def construct_compress_bdev(client, base_bdev_name, name, comp_pmd):
|
def construct_compress_bdev(client, base_bdev_name, pm_path, comp_pmd):
|
||||||
"""Construct a compress virtual block device.
|
"""Construct a compress virtual block device.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
base_bdev_name: name of the underlying base bdev
|
base_bdev_name: name of the underlying base bdev
|
||||||
name: name for the compress vbdev
|
pm_path: path to persistent memory
|
||||||
comp_pmd: name of of the DPDK compression driver to use
|
comp_pmd: name of of the DPDK compression driver to use
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Name of created virtual block device.
|
Name of created virtual block device.
|
||||||
"""
|
"""
|
||||||
params = {'base_bdev_name': base_bdev_name, 'name': name, 'comp_pmd': comp_pmd}
|
params = {'base_bdev_name': base_bdev_name, 'pm_path': pm_path, 'comp_pmd': comp_pmd}
|
||||||
|
|
||||||
return client.call('construct_compress_bdev', params)
|
return client.call('construct_compress_bdev', params)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user