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

View File

@ -64,8 +64,8 @@ struct ftl_bdev_init_opts {
uint32_t mode; uint32_t mode;
/* UUID if device is restored from SSD */ /* UUID if device is restored from SSD */
struct spdk_uuid uuid; struct spdk_uuid uuid;
/* Allow for partial restore after dirty shutdown */ /* FTL library configuration */
bool allow_open_bands; struct spdk_ftl_conf ftl_conf;
}; };
typedef void (*ftl_bdev_init_fn)(const struct ftl_bdev_info *, void *, int); 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 *punits;
char *uuid; char *uuid;
char *cache_bdev; char *cache_bdev;
bool allow_open_bands; struct spdk_ftl_conf ftl_conf;
}; };
static void 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}, {"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}, {"cache", offsetof(struct rpc_construct_ftl, cache_bdev), spdk_json_decode_string, true},
{ {
"allow_open_bands", offsetof(struct rpc_construct_ftl, allow_open_bands), "allow_open_bands", offsetof(struct rpc_construct_ftl, ftl_conf) +
spdk_json_decode_bool, true 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]; char range[FTL_RANGE_MAX_LENGTH];
int rc; int rc;
spdk_ftl_conf_init_defaults(&req.ftl_conf);
if (spdk_json_decode_object(params, rpc_construct_ftl_decoders, if (spdk_json_decode_object(params, rpc_construct_ftl_decoders,
SPDK_COUNTOF(rpc_construct_ftl_decoders), SPDK_COUNTOF(rpc_construct_ftl_decoders),
&req)) { &req)) {
@ -128,7 +130,7 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request,
opts.name = req.name; opts.name = req.name;
opts.mode = SPDK_FTL_MODE_CREATE; opts.mode = SPDK_FTL_MODE_CREATE;
opts.cache_bdev = req.cache_bdev; opts.cache_bdev = req.cache_bdev;
opts.allow_open_bands = req.allow_open_bands; opts.ftl_conf = req.ftl_conf;
/* Parse trtype */ /* Parse trtype */
rc = spdk_nvme_transport_id_parse_trtype(&opts.trid.trtype, req.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) 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 """Construct FTL bdev
Args: Args:
@ -611,12 +611,13 @@ def construct_ftl_bdev(client, name, trtype, traddr, punits, allow_open_bands, u
params = {'name': name, params = {'name': name,
'trtype': trtype, 'trtype': trtype,
'traddr': traddr, 'traddr': traddr,
'punits': punits, 'punits': punits}
'allow_open_bands': allow_open_bands}
if uuid: if uuid:
params['uuid'] = uuid params['uuid'] = uuid
if cache: if cache:
params['cache'] = cache params['cache'] = cache
if allow_open_bands:
params['allow_open_bands'] = allow_open_bands
return client.call('construct_ftl_bdev', params) return client.call('construct_ftl_bdev', params)