From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 01/11] vinyl: add helper to start scheduler and enable quota on startup Date: Fri, 28 Sep 2018 20:39:59 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: There are three places where we start the scheduler fiber and enable the configured memory quota limit: local bootstrap, remote bootstrap, and local recovery completion. I'm planning to add more code there so let's factor it out now. --- src/box/vinyl.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 803f32d5..67b9c589 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -2565,6 +2565,17 @@ vy_env_delete(struct vy_env *e) free(e); } +/** + * Called upon local recovery completion to enable memory quota + * and start the scheduler. + */ +static void +vy_env_complete_recovery(struct vy_env *env) +{ + vy_scheduler_start(&env->scheduler); + vy_quota_set_limit(&env->quota, env->memory); +} + struct vinyl_engine * vinyl_engine_new(const char *dir, size_t memory, int read_threads, int write_threads, bool force_recovery) @@ -2722,8 +2733,7 @@ vinyl_engine_bootstrap(struct engine *engine) assert(e->status == VINYL_OFFLINE); if (vy_log_bootstrap() != 0) return -1; - vy_scheduler_start(&e->scheduler); - vy_quota_set_limit(&e->quota, e->memory); + vy_env_complete_recovery(e); e->status = VINYL_ONLINE; return 0; } @@ -2757,8 +2767,7 @@ vinyl_engine_begin_initial_recovery(struct engine *engine, } else { if (vy_log_bootstrap() != 0) return -1; - vy_scheduler_start(&e->scheduler); - vy_quota_set_limit(&e->quota, e->memory); + vy_env_complete_recovery(e); e->status = VINYL_INITIAL_RECOVERY_REMOTE; } return 0; @@ -2801,8 +2810,7 @@ vinyl_engine_end_recovery(struct engine *engine) vy_recovery_delete(e->recovery); e->recovery = NULL; e->recovery_vclock = NULL; - vy_scheduler_start(&e->scheduler); - vy_quota_set_limit(&e->quota, e->memory); + vy_env_complete_recovery(e); break; case VINYL_FINAL_RECOVERY_REMOTE: break; -- 2.11.0