bdev/ftl: construct_ftl_bdev respects default ftl config

Changed initialization of the ftl lib when using an rpc call to
allow for usage of any default configuration parameters (currently
only allow_open_bands is exposed).

Signed-off-by: Mateusz Kozlowski <mateusz.kozlowski@intel.com>
Change-Id: I73457dfcacc6b1adeffd13ecc6e98001749e00cf
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459741
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Mateusz Kozlowski 2019-06-28 10:16:46 +02:00 committed by Ben Walker
parent d270cd36ad
commit 60c8845fd0
4 changed files with 15 additions and 15 deletions

View File

@ -782,13 +782,8 @@ bdev_ftl_create(struct spdk_nvme_ctrlr *ctrlr, const struct ftl_bdev_init_opts *
struct spdk_bdev *cache_bdev = NULL;
struct nvme_bdev_ctrlr *ftl_ctrlr;
struct spdk_ftl_dev_init_opts opts = {};
struct spdk_ftl_conf conf = {};
int rc;
spdk_ftl_conf_init_defaults(&conf);
conf.allow_open_bands = bdev_opts->allow_open_bands;
ftl_ctrlr = bdev_ftl_add_ctrlr(ctrlr, &bdev_opts->trid);
if (!ftl_ctrlr) {
spdk_nvme_detach(ctrlr);
@ -842,7 +837,7 @@ bdev_ftl_create(struct spdk_nvme_ctrlr *ctrlr, const struct ftl_bdev_init_opts *
opts.uuid = bdev_opts->uuid;
opts.name = ftl_bdev->bdev.name;
opts.cache_bdev_desc = ftl_bdev->cache_bdev_desc;
opts.conf = &conf;
opts.conf = &bdev_opts->ftl_conf;
/* TODO: set threads based on config */
opts.core_thread = opts.read_thread = spdk_get_thread();
@ -928,6 +923,8 @@ bdev_ftl_initialize_cb(void *ctx, int status)
goto out;
}
spdk_ftl_conf_init_defaults(&opts->ftl_conf);
if (bdev_ftl_read_bdev_config(sp, opts, &g_num_conf_bdevs)) {
goto out;
}

View File

@ -64,8 +64,8 @@ struct ftl_bdev_init_opts {
uint32_t mode;
/* UUID if device is restored from SSD */
struct spdk_uuid uuid;
/* Allow for partial restore after dirty shutdown */
bool allow_open_bands;
/* FTL library configuration */
struct spdk_ftl_conf ftl_conf;
};
typedef void (*ftl_bdev_init_fn)(const struct ftl_bdev_info *, void *, int);

View File

@ -46,7 +46,7 @@ struct rpc_construct_ftl {
char *punits;
char *uuid;
char *cache_bdev;
bool allow_open_bands;
struct spdk_ftl_conf ftl_conf;
};
static void
@ -68,8 +68,8 @@ static const struct spdk_json_object_decoder rpc_construct_ftl_decoders[] = {
{"uuid", offsetof(struct rpc_construct_ftl, uuid), spdk_json_decode_string, true},
{"cache", offsetof(struct rpc_construct_ftl, cache_bdev), spdk_json_decode_string, true},
{
"allow_open_bands", offsetof(struct rpc_construct_ftl, allow_open_bands),
spdk_json_decode_bool, true
"allow_open_bands", offsetof(struct rpc_construct_ftl, ftl_conf) +
offsetof(struct spdk_ftl_conf, allow_open_bands), spdk_json_decode_bool, true
},
};
@ -111,6 +111,8 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request,
char range[FTL_RANGE_MAX_LENGTH];
int rc;
spdk_ftl_conf_init_defaults(&req.ftl_conf);
if (spdk_json_decode_object(params, rpc_construct_ftl_decoders,
SPDK_COUNTOF(rpc_construct_ftl_decoders),
&req)) {
@ -128,7 +130,7 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request,
opts.name = req.name;
opts.mode = SPDK_FTL_MODE_CREATE;
opts.cache_bdev = req.cache_bdev;
opts.allow_open_bands = req.allow_open_bands;
opts.ftl_conf = req.ftl_conf;
/* Parse trtype */
rc = spdk_nvme_transport_id_parse_trtype(&opts.trid.trtype, req.trtype);

View File

@ -596,7 +596,7 @@ def destruct_split_vbdev(client, base_bdev):
return client.call('destruct_split_vbdev', params)
def construct_ftl_bdev(client, name, trtype, traddr, punits, allow_open_bands, uuid=None, cache=None):
def construct_ftl_bdev(client, name, trtype, traddr, punits, allow_open_bands=None, uuid=None, cache=None):
"""Construct FTL bdev
Args:
@ -611,12 +611,13 @@ def construct_ftl_bdev(client, name, trtype, traddr, punits, allow_open_bands, u
params = {'name': name,
'trtype': trtype,
'traddr': traddr,
'punits': punits,
'allow_open_bands': allow_open_bands}
'punits': punits}
if uuid:
params['uuid'] = uuid
if cache:
params['cache'] = cache
if allow_open_bands:
params['allow_open_bands'] = allow_open_bands
return client.call('construct_ftl_bdev', params)