From a039d024ffcf647d0b506136c2d953f1757026f0 Mon Sep 17 00:00:00 2001 From: Mateusz Kozlowski Date: Thu, 4 Jul 2019 14:41:08 +0200 Subject: [PATCH] lib/ftl: Remove anonymous defrag structure in config Merged configuration fields for defrag into the main config structure. Signed-off-by: Mateusz Kozlowski Change-Id: I315c78e2843bd6a310b484af5b688aca424336b0 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460518 Reviewed-by: Konrad Sztyber Reviewed-by: Wojciech Malikowski Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- include/spdk/ftl.h | 10 ++++------ lib/ftl/ftl_core.c | 4 ++-- lib/ftl/ftl_init.c | 28 +++++++++++++--------------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/include/spdk/ftl.h b/include/spdk/ftl.h index 4df7cfbe9..21dcbc0e7 100644 --- a/include/spdk/ftl.h +++ b/include/spdk/ftl.h @@ -83,13 +83,11 @@ struct spdk_ftl_conf { /* IO pool size per user thread */ size_t user_io_pool_size; - struct { - /* Lowest percentage of invalid lbks for a band to be defragged */ - size_t invalid_thld; + /* Lowest percentage of invalid lbks for a band to be defragged */ + size_t invalid_thld; - /* User writes limits */ - struct spdk_ftl_limit limits[SPDK_FTL_LIMIT_MAX]; - } defrag; + /* User writes limits */ + struct spdk_ftl_limit limits[SPDK_FTL_LIMIT_MAX]; /* Number of interleaving units per ws_opt */ size_t num_interleave_units; diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index 5f3689ecc..f0f095c9b 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -660,7 +660,7 @@ static const struct spdk_ftl_limit * ftl_get_limit(const struct spdk_ftl_dev *dev, int type) { assert(type < SPDK_FTL_LIMIT_MAX); - return &dev->conf.defrag.limits[type]; + return &dev->conf.limits[type]; } static bool @@ -1814,7 +1814,7 @@ ftl_band_needs_defrag(struct ftl_band *band, struct spdk_ftl_dev *dev) return true; } - thld_vld = (ftl_band_num_usable_lbks(band) * conf->defrag.invalid_thld) / 100; + thld_vld = (ftl_band_num_usable_lbks(band) * conf->invalid_thld) / 100; return band->merit > ftl_band_calc_merit(band, &thld_vld); } diff --git a/lib/ftl/ftl_init.c b/lib/ftl/ftl_init.c index 0a0276328..6c73cc813 100644 --- a/lib/ftl/ftl_init.c +++ b/lib/ftl/ftl_init.c @@ -66,20 +66,18 @@ struct ftl_admin_cmpl { static STAILQ_HEAD(, spdk_ftl_dev) g_ftl_queue = STAILQ_HEAD_INITIALIZER(g_ftl_queue); static pthread_mutex_t g_ftl_queue_lock = PTHREAD_MUTEX_INITIALIZER; static const struct spdk_ftl_conf g_default_conf = { - .defrag = { - .limits = { - /* 5 free bands / 0 % host writes */ - [SPDK_FTL_LIMIT_CRIT] = { .thld = 5, .limit = 0 }, - /* 10 free bands / 5 % host writes */ - [SPDK_FTL_LIMIT_HIGH] = { .thld = 10, .limit = 5 }, - /* 20 free bands / 40 % host writes */ - [SPDK_FTL_LIMIT_LOW] = { .thld = 20, .limit = 40 }, - /* 40 free bands / 100 % host writes - defrag starts running */ - [SPDK_FTL_LIMIT_START] = { .thld = 40, .limit = 100 }, - }, - /* 10 percent valid lbks */ - .invalid_thld = 10, + .limits = { + /* 5 free bands / 0 % host writes */ + [SPDK_FTL_LIMIT_CRIT] = { .thld = 5, .limit = 0 }, + /* 10 free bands / 5 % host writes */ + [SPDK_FTL_LIMIT_HIGH] = { .thld = 10, .limit = 5 }, + /* 20 free bands / 40 % host writes */ + [SPDK_FTL_LIMIT_LOW] = { .thld = 20, .limit = 40 }, + /* 40 free bands / 100 % host writes - defrag starts running */ + [SPDK_FTL_LIMIT_START] = { .thld = 40, .limit = 100 }, }, + /* 10 percent valid lbks */ + .invalid_thld = 10, /* 20% spare lbks */ .lba_rsvd = 20, /* 6M write buffer */ @@ -141,7 +139,7 @@ ftl_check_conf(const struct spdk_ftl_conf *conf, { size_t i; - if (conf->defrag.invalid_thld >= 100) { + if (conf->invalid_thld >= 100) { return -1; } if (conf->lba_rsvd >= 100) { @@ -161,7 +159,7 @@ ftl_check_conf(const struct spdk_ftl_conf *conf, } for (i = 0; i < SPDK_FTL_LIMIT_MAX; ++i) { - if (conf->defrag.limits[i].limit > 100) { + if (conf->limits[i].limit > 100) { return -1; } }