From 41c902804ffa316e11b95b4576a8136ad1dffc36 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 13 Mar 2022 20:48:33 +0800 Subject: [PATCH] shm --- .../mgmt/bnode/inc/{dndBnode.h => bmInt.h} | 2 + source/dnode/mgmt/bnode/src/dndBnode.c | 8 +-- source/dnode/mgmt/dnode/src/dndMain.c | 70 ++++++------------- source/dnode/mgmt/mnode/inc/{mm.h => mmInt.h} | 2 + source/dnode/mgmt/mnode/src/mmFile.c | 2 +- source/dnode/mgmt/mnode/src/mmHandle.c | 2 +- source/dnode/mgmt/mnode/src/mmMgmt.c | 2 +- source/dnode/mgmt/mnode/src/mmWorker.c | 2 +- .../mgmt/qnode/inc/{dndQnode.h => qmInt.h} | 2 + source/dnode/mgmt/qnode/src/dndQnode.c | 8 +-- .../mgmt/snode/inc/{dndSnode.h => smInt.h} | 2 + source/dnode/mgmt/snode/src/dndSnode.c | 8 +-- .../mgmt/vnode/inc/{dndVnodes.h => vmInt.h} | 3 + source/dnode/mgmt/vnode/src/dndVnodes.c | 8 +-- 14 files changed, 52 insertions(+), 69 deletions(-) rename source/dnode/mgmt/bnode/inc/{dndBnode.h => bmInt.h} (95%) rename source/dnode/mgmt/mnode/inc/{mm.h => mmInt.h} (97%) rename source/dnode/mgmt/qnode/inc/{dndQnode.h => qmInt.h} (95%) rename source/dnode/mgmt/snode/inc/{dndSnode.h => smInt.h} (95%) rename source/dnode/mgmt/vnode/inc/{dndVnodes.h => vmInt.h} (96%) diff --git a/source/dnode/mgmt/bnode/inc/dndBnode.h b/source/dnode/mgmt/bnode/inc/bmInt.h similarity index 95% rename from source/dnode/mgmt/bnode/inc/dndBnode.h rename to source/dnode/mgmt/bnode/inc/bmInt.h index 853b54ff69..8685a35312 100644 --- a/source/dnode/mgmt/bnode/inc/dndBnode.h +++ b/source/dnode/mgmt/bnode/inc/bmInt.h @@ -21,6 +21,8 @@ extern "C" { #endif #include "dndInt.h" +SMgmtFp bmGetMgmtFp(); + int32_t dndInitBnode(SDnode *pDnode); void dndCleanupBnode(SDnode *pDnode); diff --git a/source/dnode/mgmt/bnode/src/dndBnode.c b/source/dnode/mgmt/bnode/src/dndBnode.c index 8152107150..d1ca08ff1e 100644 --- a/source/dnode/mgmt/bnode/src/dndBnode.c +++ b/source/dnode/mgmt/bnode/src/dndBnode.c @@ -14,10 +14,10 @@ */ #define _DEFAULT_SOURCE -#include "dndBnode.h" -#include "dndMgmt.h" -#include "dndTransport.h" -#include "dndWorker.h" +// #include "dndBnode.h" +// #include "dndMgmt.h" +// #include "dndTransport.h" +// #include "dndWorker.h" #if 0 static void dndProcessBnodeQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs); diff --git a/source/dnode/mgmt/dnode/src/dndMain.c b/source/dnode/mgmt/dnode/src/dndMain.c index caa6961c88..53d8e24f55 100644 --- a/source/dnode/mgmt/dnode/src/dndMain.c +++ b/source/dnode/mgmt/dnode/src/dndMain.c @@ -15,44 +15,16 @@ #define _DEFAULT_SOURCE #include "dndMain.h" -// #include "dndBnode.h" #include "dndMgmt.h" -// #include "mm.h" -// #include "dndQnode.h" -// #include "dndSnode.h" #include "dndTransport.h" -// #include "dndVnodes.h" -// #include "monitor.h" -// #include "sync.h" -// #include "tfs.h" -// #include "wal.h" -static int8_t once = DND_ENV_INIT; - -SMgmtFp mmGetNodeFp() { - SMgmtFp nullFp = {0}; - return nullFp; -} - -SMgmtFp vndGetNodeFp() { - SMgmtFp nullFp = {0}; - return nullFp; -} - -SMgmtFp qndGetNodeFp() { - SMgmtFp nullFp = {0}; - return nullFp; -} - -SMgmtFp sndGetNodeFp() { - SMgmtFp nullFp = {0}; - return nullFp; -} +#include "bmInt.h" +#include "mmInt.h" +#include "qmInt.h" +#include "smInt.h" +#include "vmInt.h" -SMgmtFp bndGetNodeFp() { - SMgmtFp nullFp = {0}; - return nullFp; -} +static int8_t once = DND_ENV_INIT; static void dndResetLog(SMgmtWrapper *pMgmt) { char logname[24] = {0}; @@ -63,7 +35,7 @@ static void dndResetLog(SMgmtWrapper *pMgmt) { taosInitLog(logname, 1); } -static bool dndRequireOpenNode(SMgmtWrapper *pMgmt) { +static bool dndRequireNode(SMgmtWrapper *pMgmt) { bool required = (*pMgmt->fp.requiredFp)(pMgmt); if (!required) { dDebug("node:%s, no need to start on this dnode", pMgmt->name); @@ -73,7 +45,7 @@ static bool dndRequireOpenNode(SMgmtWrapper *pMgmt) { return required; } -static void dndClearDnodeMem(SDnode *pDnode) { +static void dndClearMemory(SDnode *pDnode) { for (ENodeType n = 0; n < NODE_MAX; ++n) { SMgmtWrapper *pMgmt = &pDnode->mgmts[n]; tfree(pMgmt->path); @@ -86,7 +58,7 @@ static void dndClearDnodeMem(SDnode *pDnode) { dDebug("dnode object memory is cleared, data:%p", pDnode); } -static int32_t dndInitDnodeResource(SDnode *pDnode) { +static int32_t dndInitResource(SDnode *pDnode) { SDiskCfg dCfg = {0}; tstrncpy(dCfg.dir, pDnode->cfg.dataDir, TSDB_FILENAME_LEN); dCfg.level = 0; @@ -120,7 +92,7 @@ static int32_t dndInitDnodeResource(SDnode *pDnode) { return 0; } -static void dndClearDnodeResource(SDnode *pDnode) { +static void dndClearResource(SDnode *pDnode) { dndCleanupTrans(pDnode); dndStopMgmt(pDnode); dndCleanupMgmt(pDnode); @@ -150,11 +122,11 @@ SDnode *dndCreate(SDndCfg *pCfg) { goto _OVER; } - pDnode->mgmts[MNODE].fp = mmGetNodeFp(); - pDnode->mgmts[VNODES].fp = vndGetNodeFp(); - pDnode->mgmts[QNODE].fp = qndGetNodeFp(); - pDnode->mgmts[SNODE].fp = sndGetNodeFp(); - pDnode->mgmts[BNODE].fp = bndGetNodeFp(); + pDnode->mgmts[MNODE].fp = mmGetMgmtFp(); + pDnode->mgmts[VNODES].fp = vmGetMgmtFp(); + pDnode->mgmts[QNODE].fp = qmGetMgmtFp(); + pDnode->mgmts[SNODE].fp = smGetMgmtFp(); + pDnode->mgmts[BNODE].fp = bmGetMgmtFp(); pDnode->mgmts[MNODE].name = "mnode"; pDnode->mgmts[VNODES].name = "vnodes"; pDnode->mgmts[QNODE].name = "qnode"; @@ -172,7 +144,7 @@ SDnode *dndCreate(SDndCfg *pCfg) { } pMgmt->procType = PROC_SINGLE; - pMgmt->required = dndRequireOpenNode(pMgmt); + pMgmt->required = dndRequireNode(pMgmt); if (pMgmt->required) { if (taosMkDir(pMgmt->path) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -189,7 +161,7 @@ SDnode *dndCreate(SDndCfg *pCfg) { _OVER: if (code != 0 && pDnode) { - dndClearDnodeMem(pDnode); + dndClearMemory(pDnode); tfree(pDnode); dError("failed to create dnode object since %s", terrstr()); } else { @@ -259,8 +231,8 @@ void dndClose(SDnode *pDnode) { dInfo("start to close dnode, data:%p", pDnode); dndSetStatus(pDnode, DND_STAT_STOPPED); - dndClearDnodeResource(pDnode); - dndClearDnodeMem(pDnode); + dndClearResource(pDnode); + dndClearMemory(pDnode); tfree(pDnode); dInfo("dnode object is closed, data:%p", pDnode); } @@ -288,9 +260,9 @@ int32_t dndInit() { return -1; } - // SVnodeOpt vnodeOpt = { - // .nthreads = tsNumOfCommitThreads, .putReqToVQueryQFp = dndPutReqToVQueryQ, .sendReqToDnodeFp = dndSendReqToDnode}; + // .nthreads = tsNumOfCommitThreads, .putReqToVQueryQFp = dndPutReqToVQueryQ, .sendReqToDnodeFp = + // dndSendReqToDnode}; // if (vnodeInit(&vnodeOpt) != 0) { // dError("failed to init vnode since %s", terrstr()); diff --git a/source/dnode/mgmt/mnode/inc/mm.h b/source/dnode/mgmt/mnode/inc/mmInt.h similarity index 97% rename from source/dnode/mgmt/mnode/inc/mm.h rename to source/dnode/mgmt/mnode/inc/mmInt.h index fde2cb7d3d..9d1a5c934f 100644 --- a/source/dnode/mgmt/mnode/inc/mm.h +++ b/source/dnode/mgmt/mnode/inc/mmInt.h @@ -21,6 +21,8 @@ extern "C" { #endif #include "dndInt.h" +SMgmtFp mmGetMgmtFp(); + // interface int32_t mmInit(SDnode *pDnode); void mmCleanup(SDnode *pDnode); diff --git a/source/dnode/mgmt/mnode/src/mmFile.c b/source/dnode/mgmt/mnode/src/mmFile.c index 90b5df3410..e6edfe1dce 100644 --- a/source/dnode/mgmt/mnode/src/mmFile.c +++ b/source/dnode/mgmt/mnode/src/mmFile.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "mm.h" +#include "mmInt.h" #if 0 int32_t mmReadFile(SDnode *pDnode) { diff --git a/source/dnode/mgmt/mnode/src/mmHandle.c b/source/dnode/mgmt/mnode/src/mmHandle.c index f013daaec0..2fb0cb113e 100644 --- a/source/dnode/mgmt/mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mnode/src/mmHandle.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "mm.h" +#include "mmInt.h" #if 0 #include "dndMgmt.h" diff --git a/source/dnode/mgmt/mnode/src/mmMgmt.c b/source/dnode/mgmt/mnode/src/mmMgmt.c index c3a1d18db3..d4e61336ad 100644 --- a/source/dnode/mgmt/mnode/src/mmMgmt.c +++ b/source/dnode/mgmt/mnode/src/mmMgmt.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "mm.h" +#include "mmInt.h" #include "dndMgmt.h" #include "dndTransport.h" diff --git a/source/dnode/mgmt/mnode/src/mmWorker.c b/source/dnode/mgmt/mnode/src/mmWorker.c index a51523e2cb..021f35e8d7 100644 --- a/source/dnode/mgmt/mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mnode/src/mmWorker.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include "mm.h" +#include "mmInt.h" #include "dndMgmt.h" #include "dndTransport.h" diff --git a/source/dnode/mgmt/qnode/inc/dndQnode.h b/source/dnode/mgmt/qnode/inc/qmInt.h similarity index 95% rename from source/dnode/mgmt/qnode/inc/dndQnode.h rename to source/dnode/mgmt/qnode/inc/qmInt.h index 677c234679..48e5ea7dee 100644 --- a/source/dnode/mgmt/qnode/inc/dndQnode.h +++ b/source/dnode/mgmt/qnode/inc/qmInt.h @@ -21,6 +21,8 @@ extern "C" { #endif #include "dndInt.h" +SMgmtFp qmGetMgmtFp(); + int32_t dndInitQnode(SDnode *pDnode); void dndCleanupQnode(SDnode *pDnode); diff --git a/source/dnode/mgmt/qnode/src/dndQnode.c b/source/dnode/mgmt/qnode/src/dndQnode.c index cd21884522..a2c9963772 100644 --- a/source/dnode/mgmt/qnode/src/dndQnode.c +++ b/source/dnode/mgmt/qnode/src/dndQnode.c @@ -14,10 +14,10 @@ */ #define _DEFAULT_SOURCE -#include "dndQnode.h" -#include "dndMgmt.h" -#include "dndTransport.h" -#include "dndWorker.h" +// #include "dndQnode.h" +// #include "dndMgmt.h" +// #include "dndTransport.h" +// #include "dndWorker.h" #if 0 static void dndProcessQnodeQueue(SDnode *pDnode, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/snode/inc/dndSnode.h b/source/dnode/mgmt/snode/inc/smInt.h similarity index 95% rename from source/dnode/mgmt/snode/inc/dndSnode.h rename to source/dnode/mgmt/snode/inc/smInt.h index 8cb883794d..b01bf7640f 100644 --- a/source/dnode/mgmt/snode/inc/dndSnode.h +++ b/source/dnode/mgmt/snode/inc/smInt.h @@ -21,6 +21,8 @@ extern "C" { #endif #include "dndInt.h" +SMgmtFp smGetMgmtFp(); + int32_t dndInitSnode(SDnode *pDnode); void dndCleanupSnode(SDnode *pDnode); diff --git a/source/dnode/mgmt/snode/src/dndSnode.c b/source/dnode/mgmt/snode/src/dndSnode.c index d50c9709ff..a5e3bcefc0 100644 --- a/source/dnode/mgmt/snode/src/dndSnode.c +++ b/source/dnode/mgmt/snode/src/dndSnode.c @@ -14,10 +14,10 @@ */ #define _DEFAULT_SOURCE -#include "dndSnode.h" -#include "dndMgmt.h" -#include "dndTransport.h" -#include "dndWorker.h" +// #include "dndSnode.h" +// #include "dndMgmt.h" +// #include "dndTransport.h" +// #include "dndWorker.h" #if 0 static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/vnode/inc/dndVnodes.h b/source/dnode/mgmt/vnode/inc/vmInt.h similarity index 96% rename from source/dnode/mgmt/vnode/inc/dndVnodes.h rename to source/dnode/mgmt/vnode/inc/vmInt.h index 32f4260542..512f0fb2fa 100644 --- a/source/dnode/mgmt/vnode/inc/dndVnodes.h +++ b/source/dnode/mgmt/vnode/inc/vmInt.h @@ -21,6 +21,9 @@ extern "C" { #endif #include "dndInt.h" +SMgmtFp vmGetMgmtFp() ; + + int32_t dndInitVnodes(SDnode *pDnode); void dndCleanupVnodes(SDnode *pDnode); void dndGetVnodeLoads(SDnode *pDnode, SArray *pLoads); diff --git a/source/dnode/mgmt/vnode/src/dndVnodes.c b/source/dnode/mgmt/vnode/src/dndVnodes.c index 8795551fc0..5240f41ba5 100644 --- a/source/dnode/mgmt/vnode/src/dndVnodes.c +++ b/source/dnode/mgmt/vnode/src/dndVnodes.c @@ -14,10 +14,10 @@ */ #define _DEFAULT_SOURCE -#include "dndVnodes.h" -#include "dndMgmt.h" -#include "dndTransport.h" -#include "sync.h" +// #include "dndVnodes.h" +// #include "dndMgmt.h" +// #include "dndTransport.h" +// #include "sync.h" #if 0 typedef struct { -- GitLab