From 60c8845fd07e65b4b129389e7aef2ed221481bd5 Mon Sep 17 00:00:00 2001 From: Mateusz Kozlowski Date: Fri, 28 Jun 2019 10:16:46 +0200 Subject: [PATCH] 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 Change-Id: I73457dfcacc6b1adeffd13ecc6e98001749e00cf Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459741 Reviewed-by: Konrad Sztyber Reviewed-by: Wojciech Malikowski Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- lib/bdev/nvme/bdev_ftl.c | 9 +++------ lib/bdev/nvme/bdev_ftl.h | 4 ++-- lib/bdev/nvme/bdev_ftl_rpc.c | 10 ++++++---- scripts/rpc/bdev.py | 7 ++++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/bdev/nvme/bdev_ftl.c b/lib/bdev/nvme/bdev_ftl.c index 4d035af94..831bac737 100644 --- a/lib/bdev/nvme/bdev_ftl.c +++ b/lib/bdev/nvme/bdev_ftl.c @@ -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; } diff --git a/lib/bdev/nvme/bdev_ftl.h b/lib/bdev/nvme/bdev_ftl.h index cea59cec3..a815b1344 100644 --- a/lib/bdev/nvme/bdev_ftl.h +++ b/lib/bdev/nvme/bdev_ftl.h @@ -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); diff --git a/lib/bdev/nvme/bdev_ftl_rpc.c b/lib/bdev/nvme/bdev_ftl_rpc.c index f9821e696..462375cfd 100644 --- a/lib/bdev/nvme/bdev_ftl_rpc.c +++ b/lib/bdev/nvme/bdev_ftl_rpc.c @@ -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); diff --git a/scripts/rpc/bdev.py b/scripts/rpc/bdev.py index a1247bd3d..4c42e87b0 100644 --- a/scripts/rpc/bdev.py +++ b/scripts/rpc/bdev.py @@ -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)