From 6835b6898796ab99749536bd7d8db5f43158fbb8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 10 Jan 2022 00:00:37 -0800 Subject: [PATCH] minor changes --- include/common/tcfg.h | 35 ++++++++++++++++++++++++++ include/common/tglobal.h | 6 +---- source/dnode/mgmt/impl/CMakeLists.txt | 1 + source/dnode/mgmt/impl/src/dnode.c | 12 +++++++++ source/dnode/vnode/impl/src/vnodeMgr.c | 8 ------ 5 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 include/common/tcfg.h diff --git a/include/common/tcfg.h b/include/common/tcfg.h new file mode 100644 index 0000000000..7ccfd4b0f5 --- /dev/null +++ b/include/common/tcfg.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_COMMON_CFG_H_ +#define _TD_COMMON_CFG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tdef.h" + +typedef struct { + char dir[TSDB_FILENAME_LEN]; + int level; + int primary; +} SDiskCfg; + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_COMMON_CFG_H_*/ diff --git a/include/common/tglobal.h b/include/common/tglobal.h index e8a56b77c9..1b96cbdc78 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -21,6 +21,7 @@ extern "C" { #endif #include "tdef.h" +#include "tcfg.h" // cluster extern char tsFirst[]; @@ -105,11 +106,6 @@ extern uint32_t tsMaxRange; extern uint32_t tsCurRange; extern char tsCompressor[]; -typedef struct { - char dir[TSDB_FILENAME_LEN]; - int level; - int primary; -} SDiskCfg; extern int32_t tsDiskCfgNum; extern SDiskCfg tsDiskCfg[]; diff --git a/source/dnode/mgmt/impl/CMakeLists.txt b/source/dnode/mgmt/impl/CMakeLists.txt index 866eced51a..171f9649fb 100644 --- a/source/dnode/mgmt/impl/CMakeLists.txt +++ b/source/dnode/mgmt/impl/CMakeLists.txt @@ -11,6 +11,7 @@ target_link_libraries( PUBLIC wal PUBLIC sync PUBLIC taos + PUBLIC tfs ) target_include_directories( dnode diff --git a/source/dnode/mgmt/impl/src/dnode.c b/source/dnode/mgmt/impl/src/dnode.c index 362838eba0..743b66733d 100644 --- a/source/dnode/mgmt/impl/src/dnode.c +++ b/source/dnode/mgmt/impl/src/dnode.c @@ -23,6 +23,7 @@ #include "dndVnodes.h" #include "sync.h" #include "wal.h" +#include "tfs.h" EStat dndGetStat(SDnode *pDnode) { return pDnode->stat; } @@ -185,6 +186,16 @@ SDnode *dndInit(SDnodeOpt *pOption) { return NULL; } + SDiskCfg dCfg; + strcpy(dCfg.dir, pDnode->opt.dataDir); + dCfg.level = 0; + dCfg.primary = 1; + if (tfsInit(&dCfg, 1) != 0) { + dError("failed to init tfs env"); + dndCleanup(pDnode); + return NULL; + } + if (vnodeInit(pDnode->opt.numOfCommitThreads) != 0) { dError("failed to init vnode env"); dndCleanup(pDnode); @@ -259,6 +270,7 @@ void dndCleanup(SDnode *pDnode) { dndCleanupVnodes(pDnode); dndCleanupDnode(pDnode); vnodeClear(); + tfsDestroy(); walCleanUp(); rpcCleanup(); diff --git a/source/dnode/vnode/impl/src/vnodeMgr.c b/source/dnode/vnode/impl/src/vnodeMgr.c index 54df6c892d..fae96ae22c 100644 --- a/source/dnode/vnode/impl/src/vnodeMgr.c +++ b/source/dnode/vnode/impl/src/vnodeMgr.c @@ -24,13 +24,6 @@ int vnodeInit(uint16_t nthreads) { return 0; } - SDiskCfg dCfg; - strcpy(dCfg.dir, tsDataDir); - dCfg.level = 0; - dCfg.primary = 1; - - tfsInit(&dCfg, 1); - // Start commit handers if (nthreads > 0) { vnodeMgr.nthreads = nthreads; @@ -79,7 +72,6 @@ void vnodeClear() { tfree(vnodeMgr.threads); pthread_cond_destroy(&(vnodeMgr.hasTask)); pthread_mutex_destroy(&(vnodeMgr.mutex)); - tfsDestroy(); } int vnodeScheduleTask(SVnodeTask* pTask) { -- GitLab