bdev/compress: add RPC to specify PMD
By default QAT will be selected if available however a new RPC can be used to either auto-select (default) or specify either ISAL or QAT. Change-Id: I37cf7640bbd8cef455583e1eccb8adb59cc419d8 Signed-off-by: paul luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456693 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
ef6878072c
commit
bfda995be2
@ -64,6 +64,8 @@
|
||||
#define NUM_MBUFS 512
|
||||
#define POOL_CACHE_SIZE 256
|
||||
|
||||
static enum compress_pmd g_opts;
|
||||
|
||||
/* Global list of available compression devices. */
|
||||
struct compress_dev {
|
||||
struct rte_compressdev_info cdev_info; /* includes device friendly name */
|
||||
@ -141,6 +143,8 @@ static struct rte_mempool *g_mbuf_mp = NULL; /* mbuf mempool */
|
||||
static struct rte_mempool *g_comp_op_mp = NULL; /* comp operations, must be rte* mempool */
|
||||
static struct rte_mbuf_ext_shared_info g_shinfo = {}; /* used by DPDK mbuf macros */
|
||||
static bool g_qat_available = false;
|
||||
static bool g_isal_available = false;
|
||||
|
||||
/* Create shrared (between all ops per PMD) compress xforms. */
|
||||
static struct rte_comp_xform g_comp_xform = (struct rte_comp_xform)
|
||||
{
|
||||
@ -284,6 +288,9 @@ create_compress_dev(uint8_t index, uint16_t num_lcores)
|
||||
if (strcmp(device->cdev_info.driver_name, QAT_PMD) == 0) {
|
||||
g_qat_available = true;
|
||||
}
|
||||
if (strcmp(device->cdev_info.driver_name, ISAL_PMD) == 0) {
|
||||
g_isal_available = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1104,8 +1111,30 @@ _prepare_for_load_init(struct spdk_bdev *bdev)
|
||||
return meta_ctx;
|
||||
}
|
||||
|
||||
static bool
|
||||
_set_pmd(struct vbdev_compress *comp_dev)
|
||||
{
|
||||
comp_dev->drv_name = "None";
|
||||
if (g_opts == COMPRESS_PMD_AUTO) {
|
||||
if (g_qat_available) {
|
||||
comp_dev->drv_name = QAT_PMD;
|
||||
} else {
|
||||
comp_dev->drv_name = ISAL_PMD;
|
||||
}
|
||||
} else if (g_opts == COMPRESS_PMD_QAT_ONLY && g_qat_available) {
|
||||
comp_dev->drv_name = QAT_PMD;
|
||||
} else if (g_opts == COMPRESS_PMD_ISAL_ONLY && g_isal_available) {
|
||||
comp_dev->drv_name = ISAL_PMD;
|
||||
} else {
|
||||
SPDK_ERRLOG("Requested PMD is not available.\n");
|
||||
return false;
|
||||
}
|
||||
SPDK_NOTICELOG("PMD being used: %s\n", comp_dev->drv_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Call reducelib to initialize a new volume */
|
||||
static void
|
||||
static int
|
||||
vbdev_init_reduce(struct spdk_bdev *bdev, const char *pm_path)
|
||||
{
|
||||
struct vbdev_compress *meta_ctx;
|
||||
@ -1113,13 +1142,13 @@ vbdev_init_reduce(struct spdk_bdev *bdev, const char *pm_path)
|
||||
|
||||
meta_ctx = _prepare_for_load_init(bdev);
|
||||
if (meta_ctx == NULL) {
|
||||
return;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (g_qat_available == true) {
|
||||
meta_ctx->drv_name = QAT_PMD;
|
||||
} else {
|
||||
meta_ctx->drv_name = ISAL_PMD;
|
||||
if (_set_pmd(meta_ctx) == false) {
|
||||
SPDK_ERRLOG("could not find required pmd\n");
|
||||
free(meta_ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = spdk_bdev_open(meta_ctx->base_bdev, true, vbdev_compress_base_bdev_hotremove_cb,
|
||||
@ -1127,7 +1156,7 @@ vbdev_init_reduce(struct spdk_bdev *bdev, const char *pm_path)
|
||||
if (rc) {
|
||||
SPDK_ERRLOG("could not open bdev %s\n", spdk_bdev_get_name(meta_ctx->base_bdev));
|
||||
free(meta_ctx);
|
||||
return;
|
||||
return -EINVAL;
|
||||
}
|
||||
meta_ctx->base_ch = spdk_bdev_get_io_channel(meta_ctx->base_desc);
|
||||
|
||||
@ -1135,6 +1164,7 @@ vbdev_init_reduce(struct spdk_bdev *bdev, const char *pm_path)
|
||||
pm_path,
|
||||
vbdev_reduce_init_cb,
|
||||
meta_ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We provide this callback for the SPDK channel code to create a channel using
|
||||
@ -1239,8 +1269,7 @@ create_compress_bdev(const char *bdev_name, const char *pm_path)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
vbdev_init_reduce(bdev, pm_path);
|
||||
return 0;
|
||||
return vbdev_init_reduce(bdev, pm_path);;
|
||||
}
|
||||
|
||||
/* On init, just init the compress drivers. All metadata is stored on disk. */
|
||||
@ -1315,12 +1344,6 @@ vbdev_compress_claim(struct vbdev_compress *comp_bdev)
|
||||
goto error_bdev_name;
|
||||
}
|
||||
|
||||
if (g_qat_available == true) {
|
||||
comp_bdev->drv_name = QAT_PMD;
|
||||
} else {
|
||||
comp_bdev->drv_name = ISAL_PMD;
|
||||
}
|
||||
|
||||
/* Note: some of the fields below will change in the future - for example,
|
||||
* blockcnt specifically will not match (the compressed volume size will
|
||||
* be slightly less than the base bdev size)
|
||||
@ -1444,10 +1467,11 @@ vbdev_reduce_load_cb(void *cb_arg, struct spdk_reduce_vol *vol, int reduce_errno
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_qat_available == true) {
|
||||
meta_ctx->drv_name = QAT_PMD;
|
||||
} else {
|
||||
meta_ctx->drv_name = ISAL_PMD;
|
||||
if (_set_pmd(meta_ctx) == false) {
|
||||
SPDK_ERRLOG("could not find required pmd\n");
|
||||
free(meta_ctx);
|
||||
spdk_bdev_module_examine_done(&compress_if);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update information following volume load. */
|
||||
@ -1491,4 +1515,12 @@ vbdev_compress_examine(struct spdk_bdev *bdev)
|
||||
spdk_reduce_vol_load(&meta_ctx->backing_dev, vbdev_reduce_load_cb, meta_ctx);
|
||||
}
|
||||
|
||||
int
|
||||
set_compress_pmd(enum compress_pmd *opts)
|
||||
{
|
||||
g_opts = *opts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("vbdev_compress", SPDK_LOG_VBDEV_COMPRESS)
|
||||
|
@ -38,6 +38,15 @@
|
||||
|
||||
#include "spdk/bdev.h"
|
||||
|
||||
enum compress_pmd {
|
||||
COMPRESS_PMD_AUTO = 0,
|
||||
COMPRESS_PMD_QAT_ONLY,
|
||||
COMPRESS_PMD_ISAL_ONLY,
|
||||
COMPRESS_PMD_MAX
|
||||
};
|
||||
|
||||
int set_compress_pmd(enum compress_pmd *opts);
|
||||
|
||||
typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno);
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,56 @@
|
||||
#include "spdk/string.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
struct rpc_set_compress_pmd {
|
||||
enum compress_pmd pmd;
|
||||
};
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_compress_pmd_decoder[] = {
|
||||
{"pmd", offsetof(struct rpc_set_compress_pmd, pmd), spdk_json_decode_int32},
|
||||
};
|
||||
|
||||
static void
|
||||
spdk_rpc_set_compress_pmd(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_set_compress_pmd req;
|
||||
struct spdk_json_write_ctx *w;
|
||||
int rc, jerr = 0;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_compress_pmd_decoder,
|
||||
SPDK_COUNTOF(rpc_compress_pmd_decoder),
|
||||
&req)) {
|
||||
SPDK_ERRLOG("spdk_json_decode_object failed\n");
|
||||
rc = -EINVAL;
|
||||
jerr = SPDK_JSONRPC_ERROR_PARSE_ERROR;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (req.pmd >= COMPRESS_PMD_MAX) {
|
||||
rc = -EINVAL;
|
||||
jerr = SPDK_JSONRPC_ERROR_INVALID_PARAMS;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
rc = set_compress_pmd(&req.pmd);
|
||||
if (rc) {
|
||||
rc = -EINVAL;
|
||||
jerr = SPDK_JSONRPC_ERROR_INTERNAL_ERROR;
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
if (w != NULL) {
|
||||
spdk_json_write_bool(w, true);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
|
||||
return;
|
||||
invalid:
|
||||
spdk_jsonrpc_send_error_response(request, jerr, spdk_strerror(-rc));
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_compress_pmd", spdk_rpc_set_compress_pmd, SPDK_RPC_RUNTIME)
|
||||
|
||||
/* Structure to hold the parameters for this RPC method. */
|
||||
struct rpc_construct_compress {
|
||||
char *base_bdev_name;
|
||||
|
@ -154,6 +154,13 @@ if __name__ == "__main__":
|
||||
p.add_argument('name', help='compress bdev name')
|
||||
p.set_defaults(func=delete_compress_bdev)
|
||||
|
||||
def set_compress_pmd(args):
|
||||
rpc.bdev.set_compress_pmd(args.client,
|
||||
pmd=args.pmd)
|
||||
p = subparsers.add_parser('set_compress_pmd', help='Set pmd option for a compress disk')
|
||||
p.add_argument('-p', '--pmd', type=int, help='0 = auto-select, 1= QAT only, 2 = ISAL only')
|
||||
p.set_defaults(func=set_compress_pmd)
|
||||
|
||||
def construct_crypto_bdev(args):
|
||||
print_string(rpc.bdev.construct_crypto_bdev(args.client,
|
||||
base_bdev_name=args.base_bdev_name,
|
||||
|
@ -40,6 +40,17 @@ def delete_compress_bdev(client, name):
|
||||
return client.call('delete_compress_bdev', params)
|
||||
|
||||
|
||||
def set_compress_pmd(client, pmd):
|
||||
"""Set pmd options for the bdev compress.
|
||||
|
||||
Args:
|
||||
pmd: 0 = auto-select, 1 = QAT, 2 = ISAL
|
||||
"""
|
||||
params = {'pmd': pmd}
|
||||
|
||||
return client.call('set_compress_pmd', params)
|
||||
|
||||
|
||||
def construct_crypto_bdev(client, base_bdev_name, name, crypto_pmd, key):
|
||||
"""Construct a crypto virtual block device.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user