Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6b6b7d8d
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看板
提交
6b6b7d8d
编写于
7月 17, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: alloc disk of vnode primary dir in vmAllocPrimaryDisk
上级
b21e6034
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
100 addition
and
6 deletion
+100
-6
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+17
-0
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+51
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+0
-2
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+4
-2
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+27
-1
未找到文件。
include/libs/tfs/tfs.h
浏览文件 @
6b6b7d8d
...
...
@@ -69,6 +69,13 @@ void tfsUpdateSize(STfs *pTfs);
*/
SDiskSize
tfsGetSize
(
STfs
*
pTfs
);
/**
* @brief Get the number of disks at level of multi-tier storage.
*
* @param pTfs
* @return int32_t
*/
int32_t
tfsGetDisksAtLevel
(
STfs
*
pTfs
,
int32_t
level
);
/**
* @brief Get level of multi-tier storage.
*
...
...
@@ -162,6 +169,16 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname);
*/
int32_t
tfsRename
(
STfs
*
pTfs
,
const
char
*
orname
,
const
char
*
nrname
);
/**
* @brief Search fname in level of tfs
*
* @param pTfs The fs object.
* @param level The level to search on
* @param fname The relative file name to be searched
* @param int32_t diskId for successs, -1 for failure
*/
int32_t
tfsSearch
(
STfs
*
pTfs
,
int32_t
level
,
const
char
*
fname
);
/**
* @brief Init file object in tfs.
*
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
6b6b7d8d
...
...
@@ -15,12 +15,62 @@
#define _DEFAULT_SOURCE
#include "vmInt.h"
#include "tfs.h"
#include "vnd.h"
int32_t
vmAllocPrimaryDisk
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
)
{
STfs
*
pTfs
=
pMgmt
->
pTfs
;
int32_t
diskId
=
0
;
if
(
!
pTfs
)
{
return
diskId
;
}
// search fs
char
vnodePath
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
vnodePath
,
TSDB_FILENAME_LEN
-
1
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vgId
);
char
fname
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
fnameTmp
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s"
,
vnodePath
,
TD_DIRSEP
,
VND_INFO_FNAME
);
snprintf
(
fnameTmp
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s"
,
vnodePath
,
TD_DIRSEP
,
VND_INFO_FNAME_TMP
);
diskId
=
tfsSearch
(
pTfs
,
0
,
fname
);
if
(
diskId
>=
0
)
{
return
diskId
;
}
diskId
=
tfsSearch
(
pTfs
,
0
,
fnameTmp
);
if
(
diskId
>=
0
)
{
return
diskId
;
}
// alloc
return
0
;
int32_t
disks
[
TFS_MAX_DISKS_PER_TIER
]
=
{
0
};
int32_t
numOfVnodes
=
0
;
SVnodeObj
**
ppVnodes
=
vmGetVnodeListFromHash
(
pMgmt
,
&
numOfVnodes
);
for
(
int32_t
v
=
0
;
v
<
numOfVnodes
;
v
++
)
{
SVnodeObj
*
pVnode
=
ppVnodes
[
v
];
disks
[
pVnode
->
diskPrimary
]
+=
1
;
}
int32_t
minVal
=
INT_MAX
;
int32_t
ndisk
=
tfsGetDisksAtLevel
(
pTfs
,
0
);
diskId
=
0
;
for
(
int32_t
id
=
0
;
id
<
ndisk
;
id
++
)
{
if
(
minVal
>
disks
[
id
])
{
minVal
=
disks
[
id
];
diskId
=
id
;
}
}
for
(
int32_t
i
=
0
;
i
<
numOfVnodes
;
++
i
)
{
if
(
ppVnodes
==
NULL
||
ppVnodes
[
i
]
==
NULL
)
continue
;
vmReleaseVnode
(
pMgmt
,
ppVnodes
[
i
]);
}
if
(
ppVnodes
!=
NULL
)
{
taosMemoryFree
(
ppVnodes
);
}
dInfo
(
"vgId:%d, alloc disk:%d of level 0. ndisk:%d, vnodes: %d"
,
vgId
,
diskId
,
ndisk
,
numOfVnodes
);
return
diskId
;
}
SVnodeObj
*
vmAcquireVnode
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
)
{
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
6b6b7d8d
...
...
@@ -93,6 +93,7 @@ typedef struct SQueryNode SQueryNode;
#define VNODE_BUFPOOL_SEGMENTS 3
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
// vnd.h
typedef
int32_t
(
*
_query_reseek_func_t
)(
void
*
pQHandle
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
6b6b7d8d
...
...
@@ -16,8 +16,6 @@
#include "vnd.h"
#include "vnodeInt.h"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeCommitImpl
(
SCommitInfo
*
pInfo
);
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
6b6b7d8d
...
...
@@ -38,10 +38,11 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
}
// create vnode env
vnodeGetPrimaryDir
(
path
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
taosMkDir
(
dir
))
{
if
((
pTfs
)
?
tfsMkdir
(
pTfs
,
path
)
:
taosMkDir
(
path
))
{
vError
(
"vgId:%d, failed to mkdir since %s, dir: %s"
,
pCfg
->
vgId
,
strerror
(
errno
),
path
);
return
TAOS_SYSTEM_ERROR
(
errno
);
}
vnodeGetPrimaryDir
(
path
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
pCfg
)
{
info
.
config
=
*
pCfg
;
...
...
@@ -339,6 +340,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
pVnode
->
state
.
applied
=
info
.
state
.
committed
;
pVnode
->
state
.
applyTerm
=
info
.
state
.
commitTerm
;
pVnode
->
pTfs
=
pTfs
;
pVnode
->
diskPrimary
=
diskPrimary
;
pVnode
->
msgCb
=
msgCb
;
taosThreadMutexInit
(
&
pVnode
->
lock
,
NULL
);
pVnode
->
blocked
=
false
;
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
6b6b7d8d
...
...
@@ -113,6 +113,15 @@ SDiskSize tfsGetSize(STfs *pTfs) {
return
size
;
}
int32_t
tfsGetDisksAtLevel
(
STfs
*
pTfs
,
int32_t
level
)
{
if
(
level
<
0
||
level
>=
pTfs
->
nlevel
)
{
return
0
;
}
STfsTier
*
pTier
=
TFS_TIER_AT
(
pTfs
,
level
);
return
pTier
->
ndisk
;
}
int32_t
tfsGetLevel
(
STfs
*
pTfs
)
{
return
pTfs
->
nlevel
;
}
int32_t
tfsAllocDisk
(
STfs
*
pTfs
,
int32_t
expLevel
,
SDiskID
*
pDiskId
)
{
...
...
@@ -277,7 +286,7 @@ int32_t tfsMkdir(STfs *pTfs, const char *rname) {
STfsTier
*
pTier
=
TFS_TIER_AT
(
pTfs
,
level
);
for
(
int32_t
id
=
0
;
id
<
pTier
->
ndisk
;
id
++
)
{
SDiskID
did
=
{.
id
=
id
,
.
level
=
level
};
if
(
tfsMkdirAt
(
pTfs
,
rname
,
did
)
<
0
)
{
if
(
tfsMkdir
Recur
At
(
pTfs
,
rname
,
did
)
<
0
)
{
return
-
1
;
}
}
...
...
@@ -335,6 +344,23 @@ int32_t tfsRename(STfs *pTfs, const char *orname, const char *nrname) {
return
0
;
}
int32_t
tfsSearch
(
STfs
*
pTfs
,
int32_t
level
,
const
char
*
fname
)
{
if
(
level
<
0
||
level
>=
pTfs
->
nlevel
)
{
return
-
1
;
}
char
path
[
TMPNAME_LEN
]
=
{
0
};
STfsTier
*
pTier
=
TFS_TIER_AT
(
pTfs
,
level
);
for
(
int32_t
id
=
0
;
id
<
pTier
->
ndisk
;
id
++
)
{
STfsDisk
*
pDisk
=
pTier
->
disks
[
id
];
snprintf
(
path
,
TMPNAME_LEN
-
1
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
fname
);
if
(
taosCheckExistFile
(
path
))
{
return
id
;
}
}
return
-
1
;
}
STfsDir
*
tfsOpendir
(
STfs
*
pTfs
,
const
char
*
rname
)
{
STfsDir
*
pDir
=
taosMemoryCalloc
(
1
,
sizeof
(
STfsDir
));
if
(
pDir
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录