Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c5d18b5a
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c5d18b5a
编写于
5月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: changel lockfree to rwlock
上级
568c6269
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
28 deletion
+29
-28
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+15
-15
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+2
-2
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+2
-2
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+10
-9
未找到文件。
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
c5d18b5a
...
...
@@ -26,21 +26,21 @@ extern "C" {
#endif
typedef
struct
SVnodeMgmt
{
SDnodeData
*
pData
;
SMsgCb
msgCb
;
const
char
*
path
;
const
char
*
name
;
SQWorkerPool
queryPool
;
SQWorkerPool
fetchPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
writePool
;
SWWorkerPool
mergePool
;
SSingleWorker
mgmtWorker
;
SSingleWorker
monitorWorker
;
SHashObj
*
hash
;
SRWLatch
latch
;
SVnodesStat
state
;
STfs
*
pTfs
;
SDnodeData
*
pData
;
SMsgCb
msgCb
;
const
char
*
path
;
const
char
*
name
;
SQWorkerPool
queryPool
;
SQWorkerPool
fetchPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
writePool
;
SWWorkerPool
mergePool
;
SSingleWorker
mgmtWorker
;
SSingleWorker
monitorWorker
;
SHashObj
*
hash
;
TdThreadRwlock
lock
;
SVnodesStat
state
;
STfs
*
pTfs
;
}
SVnodeMgmt
;
typedef
struct
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
c5d18b5a
...
...
@@ -17,7 +17,7 @@
#include "vmInt.h"
SVnodeObj
**
vmGetVnodeListFromHash
(
SVnodeMgmt
*
pMgmt
,
int32_t
*
numOfVnodes
)
{
taos
RLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockRdlock
(
&
pMgmt
->
lock
);
int32_t
num
=
0
;
int32_t
size
=
taosHashGetSize
(
pMgmt
->
hash
);
...
...
@@ -38,7 +38,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
}
}
taos
RUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
*
numOfVnodes
=
num
;
return
pVnodes
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
c5d18b5a
...
...
@@ -20,7 +20,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
pInfo
->
pVloads
=
taosArrayInit
(
pMgmt
->
state
.
totalVnodes
,
sizeof
(
SVnodeLoad
));
if
(
pInfo
->
pVloads
==
NULL
)
return
;
taos
RLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockRdlock
(
&
pMgmt
->
lock
);
void
*
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
NULL
);
while
(
pIter
)
{
...
...
@@ -34,7 +34,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) {
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
taos
RUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
}
void
vmGetMonitorInfo
(
SVnodeMgmt
*
pMgmt
,
SMonVmInfo
*
pInfo
)
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
c5d18b5a
...
...
@@ -20,14 +20,14 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
SVnodeObj
*
pVnode
=
NULL
;
int32_t
refCount
=
0
;
taos
RLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockRdlock
(
&
pMgmt
->
lock
);
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
if
(
pVnode
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
else
{
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
}
taos
RUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
if
(
pVnode
!=
NULL
)
{
dTrace
(
"vgId:%d, acquire vnode, refCount:%d"
,
pVnode
->
vgId
,
refCount
);
...
...
@@ -39,9 +39,9 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
void
vmReleaseVnode
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
if
(
pVnode
==
NULL
)
return
;
taos
RLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockRdlock
(
&
pMgmt
->
lock
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pVnode
->
refCount
,
1
);
taos
RUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
dTrace
(
"vgId:%d, release vnode, refCount:%d"
,
pVnode
->
vgId
,
refCount
);
}
...
...
@@ -70,9 +70,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
return
-
1
;
}
taos
WLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockWrlock
(
&
pMgmt
->
lock
);
int32_t
code
=
taosHashPut
(
pMgmt
->
hash
,
&
pVnode
->
vgId
,
sizeof
(
int32_t
),
&
pVnode
,
sizeof
(
SVnodeObj
*
));
taos
WUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
return
code
;
}
...
...
@@ -80,9 +80,9 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
void
vmCloseVnode
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
char
path
[
TSDB_FILENAME_LEN
]
=
{
0
};
taos
WLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockWrlock
(
&
pMgmt
->
lock
);
taosHashRemove
(
pMgmt
->
hash
,
&
pVnode
->
vgId
,
sizeof
(
int32_t
));
taos
WUnLockLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
lock
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
while
(
pVnode
->
refCount
>
0
)
taosMsleep
(
10
);
...
...
@@ -239,6 +239,7 @@ static void vmCleanup(SVnodeMgmt *pMgmt) {
vmStopWorker
(
pMgmt
);
vnodeCleanup
();
tfsClose
(
pMgmt
->
pTfs
);
taosThreadRwlockDestroy
(
&
pMgmt
->
lock
);
taosMemoryFree
(
pMgmt
);
}
...
...
@@ -260,7 +261,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
msgCb
.
queueFps
[
MERGE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToMergeQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
vmGetQueueSize
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taos
InitRWLatch
(
&
pMgmt
->
latch
);
taos
ThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
SDiskCfg
dCfg
=
{
0
};
tstrncpy
(
dCfg
.
dir
,
tsDataDir
,
TSDB_FILENAME_LEN
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录