From e8b0b58cf67375f857f8073540adc9d125373fda Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 25 Feb 2022 14:20:33 +0800 Subject: [PATCH] tfs cfg --- include/dnode/mgmt/dnode.h | 17 ++++++++++------- source/dnode/mgmt/daemon/src/dmnCfg.c | 2 ++ source/dnode/mgmt/impl/src/dndEnv.c | 13 ++++++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index a929f7a3fb..bb0f66ca09 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -17,6 +17,7 @@ #define _TD_DNODE_H_ #include "tdef.h" +#include "tcfg.h" #ifdef __cplusplus extern "C" { @@ -40,13 +41,15 @@ void dndCleanup(); /* ------------------------ SDnode ----------------------- */ typedef struct { - int32_t numOfSupportVnodes; - uint16_t serverPort; - char dataDir[TSDB_FILENAME_LEN]; - char localEp[TSDB_EP_LEN]; - char localFqdn[TSDB_FQDN_LEN]; - char firstEp[TSDB_EP_LEN]; - char secondEp[TSDB_EP_LEN]; + int32_t numOfSupportVnodes; + uint16_t serverPort; + char dataDir[TSDB_FILENAME_LEN]; + char localEp[TSDB_EP_LEN]; + char localFqdn[TSDB_FQDN_LEN]; + char firstEp[TSDB_EP_LEN]; + char secondEp[TSDB_EP_LEN]; + SDiskCfg *pDisks; + int32_t numOfDisks; } SDnodeObjCfg; /** diff --git a/source/dnode/mgmt/daemon/src/dmnCfg.c b/source/dnode/mgmt/daemon/src/dmnCfg.c index 1e7d1d11ea..57c788dee1 100644 --- a/source/dnode/mgmt/daemon/src/dmnCfg.c +++ b/source/dnode/mgmt/daemon/src/dmnCfg.c @@ -28,6 +28,8 @@ SDnodeObjCfg dmnGetObjCfg() { objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn)); snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort); + objCfg.pDisks = tsDiskCfg; + objCfg.numOfDisks = tsDiskCfgNum; return objCfg; } diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index 247f52f958..9467b56e6b 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -81,7 +81,7 @@ static TdFilePtr dndCheckRunning(char *dataDir) { return pFile; } -static int32_t dndCreateImp(SDnode *pDnode, SDnodeObjCfg *pCfg) { +static int32_t dndInitDir(SDnode *pDnode, SDnodeObjCfg *pCfg) { pDnode->pLockFile = dndCheckRunning(pCfg->dataDir); if (pDnode->pLockFile == NULL) { return -1; @@ -166,7 +166,7 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) { dndSetStat(pDnode, DND_STAT_INIT); - if (dndCreateImp(pDnode, pCfg) != 0) { + if (dndInitDir(pDnode, pCfg) != 0) { dError("failed to init dnode dir since %s", terrstr()); dndClose(pDnode); return NULL; @@ -176,7 +176,14 @@ SDnode *dndCreate(SDnodeObjCfg *pCfg) { tstrncpy(dCfg.dir, pDnode->cfg.dataDir, TSDB_FILENAME_LEN); dCfg.level = 0; dCfg.primary = 1; - pDnode->pTfs = tfsOpen(&dCfg, 1); + SDiskCfg *pDisks = pDnode->cfg.pDisks; + int32_t numOfDisks = pDnode->cfg.numOfDisks; + if (numOfDisks <= 0 || pDisks == NULL) { + pDisks = &dCfg; + numOfDisks = 1; + } + + pDnode->pTfs = tfsOpen(pDisks, numOfDisks); if (pDnode->pTfs == NULL) { dError("failed to init tfs since %s", terrstr()); dndClose(pDnode); -- GitLab