From 3f4474d5cbd0c2334151151fdd4c21fbb0091840 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Mon, 9 Aug 2021 15:14:40 +0200 Subject: [PATCH] Update ocf to 21.6 - remove metadata updater - handle 'zero' flag in mempool allocator - adapt ocf_mngt_cache_start() to new OCF API Signed-off-by: Rafal Stefanowski Signed-off-by: Michal Mielewczyk Change-Id: I34afd856cc1306ffe305f71a445e7474c9b0a2d9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9129 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- lib/env_ocf/mpool.c | 4 +-- lib/env_ocf/mpool.h | 2 +- lib/env_ocf/ocf_env.c | 13 +++++++--- lib/env_ocf/ocf_env.h | 5 ++-- module/bdev/ocf/ctx.c | 49 ------------------------------------- module/bdev/ocf/vbdev_ocf.c | 2 +- ocf | 2 +- 7 files changed, 17 insertions(+), 60 deletions(-) diff --git a/lib/env_ocf/mpool.c b/lib/env_ocf/mpool.c index 97ac2a7799..7395a4fd28 100644 --- a/lib/env_ocf/mpool.c +++ b/lib/env_ocf/mpool.c @@ -58,7 +58,7 @@ struct env_mpool { struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size, int flags, int mpool_max, bool fallback, const uint32_t limits[env_mpool_max], - const char *name_perfix) + const char *name_perfix, bool zero) { int i; char name[MEMPOOL_SIZE] = {}; @@ -84,7 +84,7 @@ struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size, size = hdr_size + (elem_size * (1 << i)); mpool->allocator[i] = env_allocator_create_extended(size, name, - limits ? limits[i] : -1); + limits ? limits[i] : -1, zero); if (!mpool->allocator[i]) { goto err; diff --git a/lib/env_ocf/mpool.h b/lib/env_ocf/mpool.h index b5ddb368e2..5b9880e2d9 100644 --- a/lib/env_ocf/mpool.h +++ b/lib/env_ocf/mpool.h @@ -52,7 +52,7 @@ struct env_mpool; struct env_mpool *env_mpool_create(uint32_t hdr_size, uint32_t elem_size, int flags, int mpool_max, bool fallback, const uint32_t limits[env_mpool_max], - const char *name_perfix); + const char *name_perfix, bool zero); void env_mpool_destroy(struct env_mpool *mpools); diff --git a/lib/env_ocf/ocf_env.c b/lib/env_ocf/ocf_env.c index 721138dd68..60238550c3 100644 --- a/lib/env_ocf/ocf_env.c +++ b/lib/env_ocf/ocf_env.c @@ -55,7 +55,11 @@ env_allocator_new(env_allocator *allocator) { void *mem = spdk_mempool_get(allocator->mempool); - if (spdk_likely(mem)) { + if (spdk_unlikely(!mem)) { + return NULL; + } + + if (allocator->zero) { memset(mem, 0, allocator->element_size); } @@ -63,13 +67,13 @@ env_allocator_new(env_allocator *allocator) } env_allocator * -env_allocator_create(uint32_t size, const char *name) +env_allocator_create(uint32_t size, const char *name, bool zero) { - return env_allocator_create_extended(size, name, -1); + return env_allocator_create_extended(size, name, -1, zero); } env_allocator * -env_allocator_create_extended(uint32_t size, const char *name, int limit) +env_allocator_create_extended(uint32_t size, const char *name, int limit, bool zero) { env_allocator *allocator; char qualified_name[128] = {0}; @@ -94,6 +98,7 @@ env_allocator_create_extended(uint32_t size, const char *name, int limit) allocator->element_size = size; allocator->element_count = GET_ELEMENTS_COUNT(limit); + allocator->zero = zero; return allocator; } diff --git a/lib/env_ocf/ocf_env.h b/lib/env_ocf/ocf_env.h index abbe7173e4..e342f1180e 100644 --- a/lib/env_ocf/ocf_env.h +++ b/lib/env_ocf/ocf_env.h @@ -184,11 +184,12 @@ typedef struct { struct spdk_mempool *mempool; size_t element_size; size_t element_count; + bool zero; } env_allocator; -env_allocator *env_allocator_create_extended(uint32_t size, const char *name, int limit); +env_allocator *env_allocator_create_extended(uint32_t size, const char *name, int limit, bool zero); -env_allocator *env_allocator_create(uint32_t size, const char *name); +env_allocator *env_allocator_create(uint32_t size, const char *name, bool zero); void env_allocator_destroy(env_allocator *allocator); diff --git a/module/bdev/ocf/ctx.c b/module/bdev/ocf/ctx.c index e41da05bbc..8666617e88 100644 --- a/module/bdev/ocf/ctx.c +++ b/module/bdev/ocf/ctx.c @@ -431,49 +431,6 @@ vbdev_ocf_ctx_cleaner_kick(ocf_cleaner_t cleaner) priv->poller = SPDK_POLLER_REGISTER(cleaner_poll, cleaner, 0); } -static void -vbdev_ocf_md_kick(void *ctx) -{ - ocf_metadata_updater_t mu = ctx; - ocf_cache_t cache = ocf_metadata_updater_get_cache(mu); - - ocf_metadata_updater_run(mu); - - /* Decrease cache ref count after metadata has been updated */ - ocf_mngt_cache_put(cache); -} - -static int -vbdev_ocf_volume_updater_init(ocf_metadata_updater_t mu) -{ - struct spdk_thread *md_thread = spdk_get_thread(); - - ocf_metadata_updater_set_priv(mu, md_thread); - - return 0; -} - -static void -vbdev_ocf_volume_updater_stop(ocf_metadata_updater_t mu) -{ - -} - -static void -vbdev_ocf_volume_updater_kick(ocf_metadata_updater_t mu) -{ - struct spdk_thread *md_thread = ocf_metadata_updater_get_priv(mu); - ocf_cache_t cache = ocf_metadata_updater_get_cache(mu); - - /* Increase cache ref count prior sending a message to a thread - * for metadata update */ - ocf_mngt_cache_get(cache); - - /* We need to send message to updater thread because - * kick can happen from any thread */ - spdk_thread_send_msg(md_thread, vbdev_ocf_md_kick, mu); -} - /* This function is main way by which OCF communicates with user * We don't want to use SPDK_LOG here because debugging information that is * associated with every print message is not helpful in callback that only prints info @@ -527,12 +484,6 @@ static const struct ocf_ctx_config vbdev_ocf_ctx_cfg = { .secure_erase = vbdev_ocf_ctx_data_secure_erase, }, - .metadata_updater = { - .init = vbdev_ocf_volume_updater_init, - .stop = vbdev_ocf_volume_updater_stop, - .kick = vbdev_ocf_volume_updater_kick, - }, - .cleaner = { .init = vbdev_ocf_ctx_cleaner_init, .stop = vbdev_ocf_ctx_cleaner_stop, diff --git a/module/bdev/ocf/vbdev_ocf.c b/module/bdev/ocf/vbdev_ocf.c index 13973394e2..6ae0860189 100644 --- a/module/bdev/ocf/vbdev_ocf.c +++ b/module/bdev/ocf/vbdev_ocf.c @@ -1105,7 +1105,7 @@ start_cache(struct vbdev_ocf *vbdev) vbdev_ocf_cache_ctx_get(vbdev->cache_ctx); pthread_mutex_init(&vbdev->cache_ctx->lock, NULL); - rc = ocf_mngt_cache_start(vbdev_ocf_ctx, &vbdev->ocf_cache, &vbdev->cfg.cache); + rc = ocf_mngt_cache_start(vbdev_ocf_ctx, &vbdev->ocf_cache, &vbdev->cfg.cache, NULL); if (rc) { SPDK_ERRLOG("Could not start cache %s: %d\n", vbdev->name, rc); vbdev_ocf_mngt_exit(vbdev, unregister_path_dirty, rc); diff --git a/ocf b/ocf index 05401cac64..865d29d0cb 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit 05401cac64b6f8f4e7050ef404ad9c78353c7cdb +Subproject commit 865d29d0cb93a71ce37a8410914c35005aa6ed54