[PATCH 05/11] vinyl: add helper to start scheduler and enable quota on startup

Vladimir Davydov vdavydov.dev at gmail.com
Thu Sep 20 12:34:10 MSK 2018


There are three places where we start the scheduler fiber and enable
the 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 | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index e1b35f3a..32143af0 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -2565,6 +2565,13 @@ vy_env_delete(struct vy_env *e)
 	free(e);
 }
 
+static void
+vy_env_start_scheduler(struct vy_env *e)
+{
+	vy_scheduler_start(&e->scheduler);
+	vy_quota_enable(&e->quota);
+}
+
 struct vinyl_engine *
 vinyl_engine_new(const char *dir, size_t memory,
 		 int read_threads, int write_threads, bool force_recovery)
@@ -2722,8 +2729,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_enable(&e->quota);
+	vy_env_start_scheduler(e);
 	e->status = VINYL_ONLINE;
 	return 0;
 }
@@ -2757,8 +2763,7 @@ vinyl_engine_begin_initial_recovery(struct engine *engine,
 	} else {
 		if (vy_log_bootstrap() != 0)
 			return -1;
-		vy_scheduler_start(&e->scheduler);
-		vy_quota_enable(&e->quota);
+		vy_env_start_scheduler(e);
 		e->status = VINYL_INITIAL_RECOVERY_REMOTE;
 	}
 	return 0;
@@ -2801,8 +2806,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_enable(&e->quota);
+		vy_env_start_scheduler(e);
 		break;
 	case VINYL_FINAL_RECOVERY_REMOTE:
 		break;
-- 
2.11.0




More information about the Tarantool-patches mailing list