diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2020-11-24 20:00:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 20:00:02 +0200 |
commit | e9d59e37d98db379fcbeeffeb6046af0f9cb2d2f (patch) | |
tree | c3021cf3e74efe8c47f63a39ad581347604bc404 | |
parent | ab3b4c6ff82f2cbbcaf5816b9d599abce5ac2160 (diff) |
Migrate metadata log to SQLite (#10139)
40 files changed, 244110 insertions, 2598 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 00f9f12b97..2d4ca19873 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -597,6 +597,10 @@ set(RRD_PLUGIN_FILES database/rrdsetvar.h database/rrdvar.c database/rrdvar.h + database/sqlite/sqlite_functions.c + database/sqlite/sqlite_functions.h + database/sqlite/sqlite3.c + database/sqlite/sqlite3.h database/engine/rrdengine.c database/engine/rrdengine.h database/engine/rrddiskprotocol.h @@ -612,7 +616,6 @@ set(RRD_PLUGIN_FILES database/engine/pagecache.h database/engine/rrdenglocking.c database/engine/rrdenglocking.h - database/engine/metadata_log/metadatalog.c database/engine/metadata_log/metadatalog.h database/engine/metadata_log/metadatalogapi.c database/engine/metadata_log/metadatalogapi.h @@ -623,8 +626,6 @@ set(RRD_PLUGIN_FILES database/engine/metadata_log/metalogpluginsd.h database/engine/metadata_log/compaction.c database/engine/metadata_log/compaction.h - database/engine/global_uuid_map/global_uuid_map.c - database/engine/global_uuid_map/global_uuid_map.h ) set(WEB_PLUGIN_FILES @@ -1293,6 +1294,7 @@ endif() -Wl,--wrap=web_client_api_request_v1 -Wl,--wrap=rrdhost_find_by_guid -Wl,--wrap=rrdset_find_byname + -Wl,--wrap=sql_create_host_by_uuid -Wl,--wrap=rrdset_find -Wl,--wrap=rrdpush_receiver_thread_spawn -Wl,--wrap=debug_int @@ -1317,6 +1319,7 @@ endif() -Wl,--wrap=web_client_api_request_v1 -Wl,--wrap=rrdhost_find_by_guid -Wl,--wrap=rrdset_find_byname + -Wl,--wrap=sql_create_host_by_uuid -Wl,--wrap=rrdset_find -Wl,--wrap=rrdpush_receiver_thread_spawn -Wl,--wrap=debug_int diff --git a/Makefile.am b/Makefile.am index d5daff71d3..c7c2f8ab1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -377,6 +377,10 @@ RRD_PLUGIN_FILES = \ if ENABLE_DBENGINE RRD_PLUGIN_FILES += \ + database/sqlite/sqlite_functions.c \ + database/sqlite/sqlite_functions.h \ + database/sqlite/sqlite3.c \ + database/sqlite/sqlite3.h \ database/engine/rrdengine.c \ database/engine/rrdengine.h \ database/engine/rrddiskprotocol.h \ @@ -392,7 +396,6 @@ if ENABLE_DBENGINE database/engine/pagecache.h \ database/engine/rrdenglocking.c \ database/engine/rrdenglocking.h \ - database/engine/metadata_log/metadatalog.c \ database/engine/metadata_log/metadatalog.h \ database/engine/metadata_log/metadatalogapi.c \ database/engine/metadata_log/metadatalogapi.h \ @@ -403,8 +406,6 @@ if ENABLE_DBENGINE database/engine/metadata_log/metalogpluginsd.h \ database/engine/metadata_log/compaction.c \ database/engine/metadata_log/compaction.h \ - database/engine/global_uuid_map/global_uuid_map.c \ - database/engine/global_uuid_map/global_uuid_map.h \ $(NULL) endif diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c index a02dcf006e..aee8d33434 100644 --- a/collectors/plugins.d/pluginsd_parser.c +++ b/collectors/plugins.d/pluginsd_parser.c @@ -274,7 +274,7 @@ PARSER_RC pluginsd_end(char **words, void *user, PLUGINSD_ACTION *plugins_actio PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_action) { RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host; - if (unlikely(!host)) { + if (unlikely(!host && !((PARSER_USER_OBJECT *) user)->host_exists)) { debug(D_PLUGINSD, "Ignoring chart belonging to missing or ignored host."); return PARSER_RC_OK; } @@ -303,7 +303,10 @@ PARSER_RC pluginsd_chart(char **words, void *user, PLUGINSD_ACTION *plugins_act // make sure we have the required variables if (unlikely((!type || !*type || !id || !*id))) { - error("requested a CHART, without a type.id, on host '%s'. Disabling it.", host->hostname); + if (likely(host)) + error("requested a CHART, without a type.id, on host '%s'. Disabling it.", host->hostname); + else + error("requested a CHART, without a type.id. Disabling it."); ((PARSER_USER_OBJECT *) user)->enabled = 0; return PARSER_RC_ERROR; } @@ -375,7 +378,7 @@ PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins RRDSET *st = ((PARSER_USER_OBJECT *) user)->st; RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host; - if (unlikely(!host)) { + if (unlikely(!host && !((PARSER_USER_OBJECT *) user)->host_exists)) { debug(D_PLUGINSD, "Ignoring dimension belonging to missing or ignored host."); return PARSER_RC_OK; } @@ -387,7 +390,7 @@ PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins goto disable; } - if (unlikely(!st)) { + if (unlikely(!st && !((PARSER_USER_OBJECT *) user)->st_exists)) { error("requested a DIMENSION, without a CHART, on host '%s'. Disabling it.", host->hostname); goto disable; } @@ -409,7 +412,7 @@ PARSER_RC pluginsd_dimension(char **words, void *user, PLUGINSD_ACTION *plugins if (unlikely(!algorithm || !*algorithm)) algorithm = "absolute"; - if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) + if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) debug( D_PLUGINSD, "creating dimension in chart %s, id='%s', name='%s', algorithm='%s', multiplier=%ld, divisor=%ld, hidden='%s'", diff --git a/collectors/plugins.d/pluginsd_parser.h b/collectors/plugins.d/pluginsd_parser.h index ba79373cd6..61e9c9babb 100644 --- a/collectors/plugins.d/pluginsd_parser.h +++ b/collectors/plugins.d/pluginsd_parser.h @@ -16,6 +16,8 @@ typedef struct parser_user_object { struct label *new_labels; size_t count; int enabled; + uint8_t st_exists; + uint8_t host_exists; void *private; // the user can set this for private use } PARSER_USER_OBJECT; diff --git a/collectors/statsd.plugin/statsd.c b/collectors/statsd.plugin/statsd.c index d9b326f605..a8f94130ab 100644 --- a/collectors/statsd.plugin/statsd.c +++ b/collectors/statsd.plugin/statsd.c @@ -1464,8 +1464,6 @@ static inline RRDSET *statsd_private_rrdset_create( , chart_type // chart type , memory_mode // memory mode , history // history - , 0 // not archived - , NULL // no known UUID ); rrdset_flag_set(st, RRDSET_FLAG_STORE_FIRST); @@ -2004,8 +2002,6 @@ static inline void statsd_update_app_chart(STATSD_APP *app, STATSD_APP_CHART *ch , chart->chart_type // chart type , app->rrd_memory_mode // memory mode , app->rrd_history_entries // history - , 0 // not archived - , NULL // no known UUID ); rrdset_flag_set(chart->st, RRDSET_FLAG_STORE_FIRST); diff --git a/configure.ac b/configure.ac index 2d5e84c490..30bf4898d6 100644 --- a/configure.ac +++ b/configure.ac @@ -1549,7 +1549,6 @@ AC_CONFIG_FILES([ database/Makefile database/engine/Makefile database/engine/metadata_log/Makefile - database/engine/global_uuid_map/Makefile diagrams/Makefile exporting/Makefile exporting/graphite/Makefile diff --git a/daemon/common.h b/daemon/common.h index b101afc97b..7a55022bb1 100644 --- a/daemon/common.h +++ b/daemon/common.h @@ -73,10 +73,6 @@ // netdata agent spawn server #include "spawn/spawn.h" -#ifdef ENABLE_DBENGINE -#include "database/engine/global_uuid_map/global_uuid_map.h" -#endif - // the netdata deamon #include "daemon.h" #include "main.h" diff --git a/daemon/main.c b/daemon/main.c index ee45e6b3a4..7c002ac47b 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -61,9 +61,6 @@ void netdata_cleanup_and_exit(int ret) { #ifdef ENABLE_HTTPS security_clean_openssl(); #endif -#ifdef ENABLE_DBENGINE - free_global_guid_map(); -#endif info("EXIT: all done - netdata is now exiting - bye bye..."); exit(ret); } @@ -1451,9 +1448,6 @@ int main(int argc, char **argv) { struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info)); get_system_info(system_info); -#ifdef ENABLE_DBENGINE - init_global_guid_map(); -#endif if(rrd_init(netdata_configured_hostname, system_info)) fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname); @@ -1471,10 +1465,6 @@ int main(int argc, char **argv) { // Load host labels reload_host_labels(); -#ifdef ENABLE_DBENGINE - if (localhost->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) - metalog_commit_update_host(localhost); -#endif // ------------------------------------------------------------------------ // spawn the threads diff --git a/database/engine/Makefile.am b/database/engine/Makefile.am index 90fdc6bac7..43405001d7 100644 --- a/database/engine/Makefile.am +++ b/database/engine/Makefile.am @@ -5,7 +5,6 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in SUBDIRS = \ metadata_log \ - global_uuid_map \ $(NULL) dist_noinst_DATA = \ diff --git a/database/engine/global_uuid_map/Makefile.am b/database/engine/global_uuid_map/Makefile.am deleted file mode 100644 index 161784b8f6..0000000000 --- a/database/engine/global_uuid_map/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later - -AUTOMAKE_OPTIONS = subdir-objects -MAINTAINERCLEANFILES = $(srcdir)/Makefile.in - -dist_noinst_DATA = \ - README.md \ - $(NULL) diff --git a/database/engine/global_uuid_map/README.md b/database/engine/global_uuid_map/README.md deleted file mode 100644 index e69de29bb2..0000000000 --- a/database/engine/global_uuid_map/README.md +++ /dev/null diff --git a/database/engine/global_uuid_map/global_uuid_map.c b/database/engine/global_uuid_map/global_uuid_map.c deleted file mode 100644 index 6669517ba1..0000000000 --- a/database/engine/global_uuid_map/global_uuid_map.c +++ /dev/null @@ -1,292 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "global_uuid_map.h" - -static Pvoid_t JGUID_map = (Pvoid_t) NULL; -static Pvoid_t JGUID_object_map = (Pvoid_t) NULL; -static uv_rwlock_t guid_lock; -static uv_rwlock_t object_lock; -static uv_rwlock_t global_lock; - - -void free_global_guid_map() -{ - JudyHSFreeArray(&JGUID_map, PJE0); - JudyHSFreeArray(&JGUID_object_map, PJE0); -} - -static void free_single_uuid(uuid_t *uuid) -{ - Pvoid_t *PValue, *PValue1; - char *existing_object; - Word_t size; - - PValue = JudyHSGet(JGUID_map, (void *) uuid, (Word_t) sizeof(uuid_t)); - if (likely(PValue)) { - existing_object = *PValue; - GUID_TYPE object_type = existing_object[0]; - size = (Word_t)object_type ? (object_type * 16) + 1 : strlen((char *)existing_object + 1) + 2; - PValue1 = JudyHSGet(JGUID_object_map, (void *)existing_object, (Word_t)size); - if (PValue1 && *PValue1) { - freez(*PValue1); - } - JudyHSDel(&JGUID_object_map, (void *)existing_object, - (Word_t)object_type ? (object_type * 16) + 1 : strlen((char *)existing_object + 1) + 2, PJE0); - JudyHSDel(&JGUID_map, (void *)uuid, (Word_t)sizeof(uuid_t), PJE0); - freez(existing_object); - } -} - -void free_uuid(uuid_t *uuid) -{ - GUID_TYPE ret; - char object[49]; - - ret = find_object_by_guid(uuid, object, sizeof(object)); - if (GUID_TYPE_DIMENSION == ret) - free_single_uuid((uuid_t *)(object + 16 + 16)); - - if (GUID_TYPE_CHART == ret) - free_single_uuid((uuid_t *)(object + 16)); - - free_single_uuid(uuid); - return; -} - - -void dump_object(uuid_t *index, void *object) -{ - char uuid_s[36 + 1]; - uuid_unparse_lower(*index, uuid_s); - char local_object[3 * 36 + 2 + 1]; - - switch (*(char *) object) { - case GUID_TYPE_CHAR: - debug(D_GUIDLOG, "OBJECT GUID %s on [%s]", uuid_s, (char *)object + 1); - break; - case GUID_TYPE_CHART: - uuid_unparse_lower((const unsigned char *)object + 1, local_object); - uuid_unparse_lower((const unsigned char *)object + 17, local_object+37); - local_object[36] = ':'; - local_object[74] = '\0'; - debug(D_GUIDLOG, "CHART GUID %s on [%s]", uuid_s, local_object); - break; - case GUID_TYPE_DIMENSION: - uuid_unparse_lower((const unsigned char *)object + 1, local_object); - uuid_unparse_lower((const unsigned char *)object + 17, local_object + 37); - uuid_unparse_lower((const unsigned char *)object + 33, local_object + 74); - local_object[36] = ':'; - local_object[73] = ':'; - local_object[110] = '\0'; - debug(D_GUIDLOG, "DIM GUID %s on [%s]", uuid_s, local_object); - break; - default: - debug(D_GUIDLOG, "Unknown object"); - } -} - -/* Returns 0 if it successfully stores the uuid-object mapping or if an identical mapping already exists */ -static inline int guid_store_nolock(uuid_t *uuid, void *object, GUID_TYPE object_type) -{ - char *existing_object; - GUID_TYPE existing_object_type; - - if (unlikely(!object) || uuid == NULL) - return 0; - - Pvoid_t *PValue; - - PValue = JudyHSIns(&JGUID_map, (void *) uuid, (Word_t) sizeof(uuid_t), PJE0); - if (PPJERR == PValue) - fatal("JudyHSIns() fatal error."); - if (*PValue) { - existing_object = *PValue; - existing_object_type = existing_object[0]; - if (existing_object_type != object_type) - return 1; - switch (existing_object_type) { - case GUID_TYPE_DIMENSION: - if (memcmp(existing_object, object, 1 + 16 + 16 + 16)) - return 1; - break; - case GUID_TYPE_CHART: - if (memcmp(existing_object, object, 1 + 16 + 16)) - return 1; - break; - case GUID_TYPE_CHAR: - if (strcmp(existing_object + 1, (char *)object)) - return 1; - break; - default: - return 1; - } - freez(existing_object); - } - - *PValue = (Pvoid_t *) object; - - PValue = JudyHSIns(&JGUID_object_map, (void *)object, (Word_t) object_type?(object_type * 16)+1:strlen((char *) object+1)+2, PJE0); - if (PPJERR == PValue) - fatal("JudyHSIns() fatal error."); - if (*PValue == NULL) { - uuid_t *value = (uuid_t *) mallocz(sizeof(uuid_t)); - uuid_copy(*value, *uuid); - *PValue = value; - } - -#ifdef NETDATA_INTERNAL_CHECKS - static uint32_t count = 0; - count++; - char uuid_s[36 + 1]; - uuid_unparse_lower(*uuid, uuid_s); - debug(D_GUIDLOG,"GUID added item %" PRIu32" [%s] as:", count, uuid_s); - dump_object(uuid, object); -#endif - return 0; -} - - -/* - * Given a GUID, find if an object is stored - * - Optionally return the object - */ - -GUID_TYPE find_object_by_guid(uuid_t *uuid, char *object, size_t max_bytes) -{ - Pvoid_t *PValue; - GUID_TYPE value_type; - - uv_rwlock_rdlock(&global_lock); - PValue = JudyHSGet(JGUID_map, (void *) uuid, (Word_t) sizeof(uuid_t)); - if (unlikely(!PValue)) { - uv_rwlock_rdunlock(&global_lock); - return GUID_TYPE_NOTFOUND; - } - - value_type = *(char *) *PValue; - - if (likely(object && max_bytes)) { - switch (value_type) { - case GUID_TYPE_CHAR: - if (unlikely(max_bytes - 1 < strlen((char *) *PValue+1))) { - uv_rwlock_rdunlock(&global_lock); - return GUID_TYPE_NOSPACE; - } - strncpyz(object, (char *) *PValue+1, max_bytes - 1); - break; - case GUID_TYPE_HOST: - case GUID_TYPE_CHART: - case GUID_TYPE_DIMENSION: - if (unlikely(max_bytes < (size_t) value_type * 16)) { - uv_rwlock_rdunlock(&global_lock); - return GUID_TYPE_NOSPACE; - } - memcpy(object, *PValue+1, value_type * 16); - break; - default: - uv_rwlock_rdunlock(&global_lock); - return GUID_TYPE_NOTFOUND; - } - } - -#ifdef NETDATA_INTERNAL_CHECKS - dump_object(uuid, *PValue); -#endif - uv_rwlock_rdunlock(&global_lock); - return value_type; -} - -/* - * Find a GUID of an object - * - Optionally return the GUID - * - */ - -int find_guid_by_object(char *object, uuid_t *uuid, GUID_TYPE object_type) -{ - Pvoid_t *PValue; - - uv_rwlock_rdlock(&global_lock); - PValue = JudyHSGet(JGUID_object_map, (void *)object, (Word_t)object_type?object_type*16+1:strlen(object+1)+2); - if (unlikely(!PValue)) { - uv_rwlock_rdunlock(&global_lock); - return 1; - } - - if (likely(uuid)) - uuid_copy(*uuid, *PValue); - uv_rwlock_rdunlock(&global_lock); - return 0; -} - -int find_or_generate_guid(void *object, uuid_t *uuid, GUID_TYPE object_type, int replace_instead_of_generate) -{ - char *target_object; - uuid_t temp_uuid; - int rc; - - switch (object_type) { - case GUID_TYPE_DIMENSION: - if (unlikely(find_or_generate_guid((void *) ((RRDDIM *)object)->id, &temp_uuid, GUID_TYPE_CHAR, 0))) - return 1; - target_object = mallocz(49); - target_object[0] = object_type; - memcpy(target_object + 1, ((RRDDIM *)object)->rrdset->rrdhost->host_uuid, 16); - memcpy(target_object + 17, ((RRDDIM *)object)->rrdset->chart_uuid, 16); - memcpy(target_object + 33, temp_uuid, 16); - break; - case GUID_TYPE_CHART: - if (unlikely(find_or_generate_guid((void *) ((RRDSET *)object)->id, &temp_uuid, GUID_TYPE_CHAR, 0))) - return 1; - target_object = mallocz(33); - target_object[0] = object_type; - memcpy(target_object + 1, (((RRDSET *)object))->rrdhost->host_uuid, 16); - memcpy(target_object + 17, temp_uuid, 16); - break; - case GUID_TYPE_HOST: - target_object = mallocz(17); - target_object[0] = object_type; - memcpy(target_object + 1, (((RRDHOST *)object))->host_uuid, 16); - break; - case GUID_TYPE_CHAR: - target_object = mallocz(strlen((char *) object)+2); - target_object[0] = object_type; - strcpy(target_object+1, (char *) object); - break; - default: - return 1; - } - rc = find_guid_by_object(target_object, uuid, object_type); - if (rc) { - if (!replace_instead_of_generate) /* else take *uuid as user input */ - uuid_generate(*uuid); - uv_rwlock_wrlock(&global_lock); - rc = guid_store_nolock(uuid, target_object, object_type); - uv_rwlock_wrunlock(&global_lock); - if (rc) - freez(target_object); - return rc; - } -#ifdef NETDATA_INTERNAL_CHECKS - dump_object(uuid, target_object); -#endif - freez(target_object); - return 0; -} - -void init_global_guid_map() -{ - static int init = 0; - - if (init) - return; - - init = 1; - info("Configuring locking mechanism for global GUID map"); - fatal_assert(0 == uv_rwlock_init(&guid_lock)); - fatal_assert(0 == uv_rwlock_init(&object_lock)); - fatal_assert(0 == uv_rwlock_init(&global_lock)); - return; -} - - diff --git a/database/engine/global_uuid_map/global_uuid_map.h b/database/engine/global_uuid_map/global_uuid_map.h deleted file mode 100644 index f31f3c0079..0000000000 --- a/database/engine/global_uuid_map/global_uuid_map.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_GLOBAL_UUID_MAP_H -#define NETDATA_GLOBAL_UUID_MAP_H - -#include "libnetdata/libnetdata.h" -#include <Judy.h> -#include "../../rrd.h" - -typedef enum guid_type { - GUID_TYPE_CHAR, - GUID_TYPE_HOST, - GUID_TYPE_CHART, - GUID_TYPE_DIMENSION, - GUID_TYPE_NOTFOUND, - GUID_TYPE_NOSPACE -} GUID_TYPE; - -extern GUID_TYPE find_object_by_guid(uuid_t *uuid, char *object, size_t max_bytes); -extern int find_guid_by_object(char *object, uuid_t *uuid, GUID_TYPE); -extern void init_global_guid_map(); -extern int find_or_generate_guid(void *object, uuid_t *uuid, GUID_TYPE object_type, int replace_instead_of_generate); -extern void free_uuid(uuid_t *uuid); -extern void free_global_guid_map(); -#endif //NETDATA_GLOBAL_UUID_MAP_H diff --git a/database/engine/metadata_log/compaction.c b/database/engine/metadata_log/compaction.c index c261cd9454..ba19e1edfb 100644 --- a/database/engine/metadata_log/compaction.c +++ b/database/engine/metadata_log/compaction.c @@ -3,319 +3,6 @@ #include "metadatalog.h" -void after_compact_old_records(struct metalog_worker_config* wc) -{ - struct metalog_instance *ctx = wc->ctx; - int error; - - mlf_flush_records_buffer(wc, &ctx->compaction_state.records_log, &ctx->compaction_state.new_metadata_logfiles); - uv_run(wc->loop, UV_RUN_DEFAULT); - - error = uv_thread_join(wc->now_compacting_files); - if (error) { - error("uv_thread_join(): %s", uv_strerror(error)); - } - freez(wc->now_compacting_files); - /* unfreeze command processing */ - wc->now_compacting_files = NULL; - - wc->cleanup_thread_compacting_files = 0; - - /* interrupt event loop */ - uv_stop(wc->loop); - - info("Finished metadata log compaction (id:%"PRIu32").", ctx->current_compaction_id); -} - -static void metalog_flush_compaction_records(struct metalog_instance *ctx) -{ - struct metalog_cmd cmd; - struct completion compaction_completion; - - init_completion(&compaction_completion); - - cmd.opcode = METALOG_COMPACTION_FLUSH; - cmd.record_io_descr.completion = &compaction_completion; - metalog_enq_cmd(&ctx->worker_config, &cmd); - - wait_for_completion(&compaction_completion); - destroy_completion(&compaction_completion); -} - -/* The caller must have called metalog_flush_compaction_records() before to synchronize and quiesce the event loop. */ -static void compaction_test_quota(struct metalog_worker_config *wc) -{ - struct metalog_instance *ctx = wc->ctx; - struct logfile_compaction_state *compaction_state; - struct metadata_logfile *oldmetalogfile, *newmetalogfile; - unsigned current_size; - int ret; - - compaction_state = &ctx->compaction_state; - newmetalogfile = compaction_state->new_metadata_logfiles.last; - - oldmetalogfile = ctx->metadata_logfiles.first; - - current_size = newmetalogfile->pos; - if (unlikely(current_size >= MAX_METALOGFILE_SIZE && newmetalogfile->starting_fi |