Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c510e513
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看板
提交
c510e513
编写于
11月 19, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
35ead500
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
122 addition
and
60 deletion
+122
-60
src/common/src/tmount.c
src/common/src/tmount.c
+3
-3
src/dnode/CMakeLists.txt
src/dnode/CMakeLists.txt
+0
-1
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+18
-29
src/inc/dnode.h
src/inc/dnode.h
+0
-4
src/inc/taoserror.h
src/inc/taoserror.h
+0
-8
src/inc/tfs.h
src/inc/tfs.h
+3
-0
src/tfs/inc/tdisk.h
src/tfs/inc/tdisk.h
+2
-1
src/tfs/inc/ttier.h
src/tfs/inc/ttier.h
+3
-0
src/tfs/src/tdisk.c
src/tfs/src/tdisk.c
+17
-3
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+67
-8
src/tfs/src/ttier.c
src/tfs/src/ttier.c
+9
-3
未找到文件。
src/common/src/tmount.c
浏览文件 @
c510e513
...
...
@@ -193,7 +193,7 @@ static SDisk *tdGetDiskByName(char *dirName) {
char
fdirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
SDiskID
*
pDiskID
=
NULL
;
if
(
t
d
FormatDir
(
dirName
,
fdirName
)
<
0
)
{
if
(
t
fs
FormatDir
(
dirName
,
fdirName
)
<
0
)
{
return
NULL
;
}
...
...
@@ -228,7 +228,7 @@ static void tdDecDiskFiles(SDisk *pDisk, bool lock) {
}
}
static
int
t
d
FormatDir
(
char
*
idir
,
char
*
odir
)
{
static
int
t
fs
FormatDir
(
char
*
idir
,
char
*
odir
)
{
wordexp_t
wep
;
int
code
=
wordexp
(
idir
,
&
wep
,
0
);
...
...
@@ -295,7 +295,7 @@ static int tdAddDisk(SDiskCfg *pCfg) {
return
-
1
;
}
if
(
t
d
FormatDir
(
pCfg
->
dir
,
dirName
)
<
0
)
{
if
(
t
fs
FormatDir
(
pCfg
->
dir
,
dirName
)
<
0
)
{
uError
(
"failed to add disk %s to tier %d level since %s"
,
pCfg
->
dir
,
pCfg
->
level
,
tstrerror
(
terrno
));
return
-
1
;
}
...
...
src/dnode/CMakeLists.txt
浏览文件 @
c510e513
...
...
@@ -48,7 +48,6 @@ IF (TD_LINUX)
COMMAND
${
CMAKE_COMMAND
}
-E echo dataDir
${
TD_TESTS_OUTPUT_DIR
}
/data >
${
TD_TESTS_OUTPUT_DIR
}
/cfg/taos.cfg
COMMAND
${
CMAKE_COMMAND
}
-E echo logDir
${
TD_TESTS_OUTPUT_DIR
}
/log >>
${
TD_TESTS_OUTPUT_DIR
}
/cfg/taos.cfg
COMMAND
${
CMAKE_COMMAND
}
-E echo charset UTF-8 >>
${
TD_TESTS_OUTPUT_DIR
}
/cfg/taos.cfg
COMMAND
${
CMAKE_COMMAND
}
-E echo monitor 0 >>
${
TD_TESTS_OUTPUT_DIR
}
/cfg/taos.cfg
COMMENT
"prepare taosd environment"
)
ADD_CUSTOM_TARGET
(
${
PREPARE_ENV_TARGET
}
ALL WORKING_DIRECTORY
${
TD_EXECUTABLE_OUTPUT_PATH
}
DEPENDS
${
PREPARE_ENV_CMD
}
)
ENDIF
()
src/dnode/src/dnodeMain.c
浏览文件 @
c510e513
...
...
@@ -37,8 +37,7 @@
#include "dnodeMPeer.h"
#include "dnodeShell.h"
#include "dnodeTelemetry.h"
#include "tpath.h"
#include "tmount.h"
#include "tfs.h"
static
SRunStatus
tsRunStatus
=
TSDB_RUN_STATUS_STOPPED
;
...
...
@@ -183,45 +182,35 @@ static void dnodeCheckDataDirOpenned(char *dir) {
}
static
int32_t
dnodeInitStorage
()
{
if
(
t
dInitMoun
t
(
tsDiskCfg
,
tsDiskCfgNum
)
<
0
)
{
dError
(
"failed to
add disks to dnode tier
since %s"
,
tstrerror
(
terrno
));
if
(
t
fsIni
t
(
tsDiskCfg
,
tsDiskCfgNum
)
<
0
)
{
dError
(
"failed to
init TFS
since %s"
,
tstrerror
(
terrno
));
return
-
1
;
}
tdGetPrimaryPath
(
tsDataDir
);
tdGetVnodeRootDir
(
tsDataDir
,
tsVnodeDir
);
tfsPrimaryPath
(
tsDataDir
);
sprintf
(
tsMnodeDir
,
"%s/mnode"
,
tsDataDir
);
sprintf
(
tsVnodeDir
,
"%s/vnode"
,
tsDataDir
);
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
sprintf
(
tsVnodeBakDir
,
"%s/vnode_bak"
,
tsDataDir
);
//TODO(dengyihao): no need to init here
tdGetMnodeRootDir
(
tsDataDir
,
tsMnodeDir
);
if
(
dnodeCreateDir
(
tsMnodeDir
)
<
0
)
{
dError
(
"failed to create
mnode
dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
return
-
1
;
}
tdGetDnodeRootDir
(
tsDataDir
,
tsDnodeDir
);
if
(
dnodeCreateDir
(
tsDnodeDir
)
<
0
)
{
dError
(
"failed to create d
node d
ir: %s, reason: %s"
,
tsDnodeDir
,
strerror
(
errno
));
dError
(
"failed to create dir: %s, reason: %s"
,
tsDnodeDir
,
strerror
(
errno
));
return
-
1
;
}
for
(
int
i
=
0
;
i
<
tsDnodeTier
->
nTiers
;
i
++
)
{
char
dirName
[
TSDB_FILENAME_LEN
];
STier
*
pTier
=
tsDnodeTier
->
tiers
+
i
;
for
(
int
j
=
0
;
j
<
pTier
->
nDisks
;
j
++
)
{
SDisk
*
pDisk
=
tdGetDisk
(
tsDnodeTier
,
i
,
j
);
tdGetVnodeRootDir
(
pDisk
->
dir
,
dirName
);
if
(
dnodeCreateDir
(
dirName
)
<
0
)
{
dError
(
"failed to create vnode dir: %s, reason: %s"
,
dirName
,
strerror
(
errno
));
return
-
1
;
}
if
(
tfsCreateDir
(
"vnode"
)
<
0
)
{
dError
(
"failed to create vnode dir since %s"
,
tstrerror
(
terrno
));
return
-
1
;
}
tdGetVnodeBackRootDir
(
pDisk
->
dir
,
dirName
);
if
(
dnodeCreateDir
(
dirName
)
<
0
)
{
dError
(
"failed to create vnode back dir: %s, reason: %s"
,
dirName
,
strerror
(
errno
));
return
-
1
;
}
}
if
(
tfsCreateDir
(
"vnode_bak"
)
<
0
)
{
dError
(
"failed to create vnode_bak dir since %s"
,
tstrerror
(
terrno
));
return
-
1
;
}
dnodeCheckDataDirOpenned
(
tsDnodeDir
);
...
...
@@ -230,7 +219,7 @@ static int32_t dnodeInitStorage() {
return
0
;
}
static
void
dnodeCleanupStorage
()
{
t
dDestroyMount
();
}
static
void
dnodeCleanupStorage
()
{
t
fsDestroy
();
}
bool
dnodeIsFirstDeploy
()
{
return
strcmp
(
tsFirst
,
tsLocalEp
)
==
0
;
...
...
src/inc/dnode.h
浏览文件 @
c510e513
...
...
@@ -20,10 +20,6 @@
extern
"C"
{
#endif
#include "taosdef.h"
#include "tglobal.h"
#include "hash.h"
#include "taoserror.h"
#include "trpc.h"
#include "taosmsg.h"
...
...
src/inc/taoserror.h
浏览文件 @
c510e513
...
...
@@ -80,14 +80,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, 0, 0x0107, "Ref ID is
TAOS_DEFINE_ERROR
(
TSDB_CODE_REF_INVALID_ID
,
0
,
0x0108
,
"Invalid Ref ID"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_REF_ALREADY_EXIST
,
0
,
0x0109
,
"Ref is already there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_REF_NOT_EXIST
,
0
,
0x010A
,
"Ref is not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_INVALID_DISK_TIER
,
0
,
0x010B
,
"Invalid disk tier setting"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_TOO_MANY_DISKS
,
0
,
0x010C
,
"Too many disks in one tier"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_DISK_ALREADY_EXISTS
,
0
,
0x010D
,
"Disk already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_DISK_NOT_DIRECTORY
,
0
,
0x010E
,
"Disk is not a directory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_NO_DISK_SPACE
,
0
,
0x010F
,
"Dnode no disk space"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_DUPLICATE_PRIMARY_DISK
,
0
,
0x0110
,
"Duplicate primary disk"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_LACK_PRIMARY_DISK
,
0
,
0x0111
,
"Lack primary disk"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_COM_NO_DISK_AT_TIER
,
0
,
0x0112
,
"No disk at tier"
)
//client
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_SQL
,
0
,
0x0200
,
"Invalid SQL statement"
)
...
...
src/
tfs/
inc/tfs.h
→
src/inc/tfs.h
浏览文件 @
c510e513
...
...
@@ -24,6 +24,9 @@ extern "C" {
int
tfsInit
(
SDiskCfg
*
pDiskCfg
,
int
ndisk
);
void
tfsDestroy
();
int
tfsUpdateInfo
();
void
tfsPrimaryPath
(
char
*
dst
);
int
tfsCreateDir
(
char
*
name
);
#ifdef __cplusplus
}
...
...
src/tfs/inc/tdisk.h
浏览文件 @
c510e513
...
...
@@ -38,8 +38,9 @@ typedef struct {
SDiskMeta
dmeta
;
}
SDisk
;
SDisk
*
tdNewDisk
(
SDiskID
d
id
,
char
*
dir
);
SDisk
*
tdNewDisk
(
int
level
,
int
id
,
char
*
dir
);
void
tdFreeDisk
(
SDisk
*
pDisk
);
int
tdUpdateDiskInfo
(
SDisk
*
pDisk
);
#ifdef __cplusplus
}
...
...
src/tfs/inc/ttier.h
浏览文件 @
c510e513
...
...
@@ -30,9 +30,12 @@ typedef struct {
SDisk
*
disks
[
TSDB_MAX_DISK_PER_TIER
];
}
STier
;
#define DISK_AT_TIER(pTier, id) ((pTier)->disks + (id))
void
tdInitTier
(
STier
*
pTier
,
int
level
);
void
tdDestroyTier
(
STier
*
pTier
);
SDisk
*
tdAddDiskToTier
(
STier
*
pTier
,
SDiskCfg
*
pCfg
);
int
tdUpdateTierInfo
(
STier
*
pTier
);
#ifdef __cplusplus
}
...
...
src/tfs/src/tdisk.c
浏览文件 @
c510e513
...
...
@@ -15,15 +15,15 @@
#include "tdisk.h"
SDisk
*
tdNewDisk
(
SDiskID
d
id
,
char
*
dir
)
{
SDisk
*
tdNewDisk
(
int
level
,
int
id
,
char
*
dir
)
{
SDisk
*
pDisk
=
(
SDisk
*
)
calloc
(
1
,
sizeof
(
*
pDisk
));
if
(
pDisk
==
NULL
)
{
terrno
=
TSDB_CODE_FS_OUT_OF_MEMORY
;
return
NULL
;
}
pDisk
->
level
=
did
.
level
;
pDisk
->
id
=
did
.
id
;
pDisk
->
level
=
level
;
pDisk
->
id
=
id
;
strncpy
(
pDisk
->
dir
,
dir
,
TSDB_FILENAME_LEN
);
return
pDisk
;
...
...
@@ -33,4 +33,18 @@ void tdFreeDisk(SDisk *pDisk) {
if
(
pDisk
)
{
free
(
pDisk
)
}
}
int
tdUpdateDiskInfo
(
SDisk
*
pDisk
)
{
SysDiskSize
dstat
;
if
(
taosGetDiskSize
(
pDisk
->
dir
,
&
dstat
)
<
0
)
{
fError
(
"failed to get dir %s information since %s"
,
pDisk
->
dir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
pDisk
->
dmeta
.
size
=
dstat
.
tsize
;
pDisk
->
dmeta
.
free
=
dstat
.
avail
;
return
0
;
}
\ No newline at end of file
src/tfs/src/tfs.c
浏览文件 @
c510e513
...
...
@@ -45,6 +45,7 @@ static SFS tdFileSystem = {0};
static
SFS
*
pfs
=
&
tdFileSystem
;
#define TIER_AT(level) (pfs->tiers + (level))
#define DISK_AT(level, id) DISK_AT_TIER(TIER_AT(level), id)
int
tfsInit
(
SDiskCfg
*
pDiskCfg
,
int
ndisk
)
{
ASSERT
(
ndisk
>
0
);
...
...
@@ -68,13 +69,13 @@ int tfsInit(SDiskCfg *pDiskCfg, int ndisk) {
}
for
(
int
idisk
=
0
;
idisk
<
ndisk
;
idisk
++
)
{
if
(
t
dAddDiskToFS
(
pDiskCfg
+
idisk
)
<
0
)
{
if
(
t
fsAddDisk
(
pDiskCfg
+
idisk
)
<
0
)
{
tfsDestroy
();
return
-
1
;
}
}
if
(
t
dCheckFS
()
<
0
)
{
if
(
t
fsCheck
()
<
0
)
{
tfsDestroy
();
return
-
1
;
}
...
...
@@ -92,8 +93,46 @@ void tfsDestroy() {
}
}
static
int
tdAddDiskToFS
(
SDiskCfg
*
pCfg
)
{
if
(
tdCheckAndFormatCfg
(
pCfg
)
<
0
)
return
-
1
;
int
tfsUpdateInfo
()
{
tfsLock
();
for
(
int
level
=
0
;
level
<
pfs
->
nlevel
;
level
++
)
{
if
(
tdUpdateTierInfo
(
TIER_AT
(
level
))
<
0
)
{
// TODO: deal with the error here
}
}
tfsUnLock
();
}
void
tfsPrimaryPath
(
char
*
dst
)
{
strncpy
(
dst
,
DISK_AT
)
}
int
tfsCreateDir
(
char
*
name
)
{
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
for
(
int
level
=
0
;
level
<
pfs
->
nlevel
;
level
++
)
{
STier
*
pTier
=
TIER_AT
(
level
);
for
(
int
id
=
0
;
id
<
pTier
->
ndisk
;
id
++
)
{
SDisk
*
pDisk
=
DISK_AT_TIER
(
pTier
,
id
);
ASSERT
(
pDisk
!=
NULL
);
snprintf
(
dirName
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
pDisk
->
dir
,
name
);
if
(
mkdir
(
dirName
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
}
return
0
;
}
static
int
tfsAddDisk
(
SDiskCfg
*
pCfg
)
{
if
(
tfsCheckAndFormatCfg
(
pCfg
)
<
0
)
return
-
1
;
if
(
tdAddDiskToTier
(
pCfg
,
TIER_AT
(
pCfg
->
level
))
<
0
)
{
fError
(
"failed to add disk %s to FS since %s"
,
pCfg
->
dir
,
tstrerror
(
terrno
));
...
...
@@ -105,7 +144,7 @@ static int tdAddDiskToFS(SDiskCfg *pCfg) {
return
0
;
}
static
int
t
d
CheckAndFormatCfg
(
SDiskCfg
*
pCfg
)
{
static
int
t
fs
CheckAndFormatCfg
(
SDiskCfg
*
pCfg
)
{
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
struct
stat
pstat
;
...
...
@@ -122,7 +161,7 @@ static int tdCheckAndFormatCfg(SDiskCfg *pCfg) {
}
if
(
t
d
FormatDir
(
pCfg
->
dir
,
dirName
)
<
0
)
{
if
(
t
fs
FormatDir
(
pCfg
->
dir
,
dirName
)
<
0
)
{
fError
(
"failed to add disk %s to FS since invalid dir format"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
...
...
@@ -157,7 +196,7 @@ static int tdCheckAndFormatCfg(SDiskCfg *pCfg) {
return
0
;
}
static
int
t
d
FormatDir
(
char
*
idir
,
char
*
odir
)
{
static
int
t
fs
FormatDir
(
char
*
idir
,
char
*
odir
)
{
wordexp_t
wep
=
{
0
};
int
code
=
wordexp
(
idir
,
&
wep
,
0
);
...
...
@@ -177,7 +216,7 @@ static int tdFormatDir(char *idir, char *odir) {
}
static
int
t
dCheckFS
()
{
static
int
t
fsCheck
()
{
if
(
DISK_AT
(
0
,
0
)
==
NULL
)
{
fError
(
"no primary disk is set"
);
terrno
=
TSDB_CODE_FS_NO_PRIMARY_DISK
;
...
...
@@ -192,5 +231,25 @@ static int tdCheckFS() {
}
}
return
0
;
}
static
int
tfsLock
()
{
int
code
=
pthread_mutex_lock
(
&
(
pfs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
tfsUnLock
()
{
int
code
=
pthread_mutex_unlock
(
&
(
pfs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
\ No newline at end of file
src/tfs/src/ttier.c
浏览文件 @
c510e513
...
...
@@ -16,8 +16,6 @@
#include "ttier.h"
#include "tglobal.h"
#define DISK_AT_TIER(pTier, id) ((pTier)->disks + (id))
void
tdInitTier
(
STier
*
pTier
,
int
level
)
{
pTier
->
level
=
level
;
}
...
...
@@ -59,8 +57,16 @@ SDisk *tdAddDiskToTier(STier *pTier, SDiskCfg *pCfg) {
}
}
pTier
->
disks
[
id
]
=
tdNewDisk
(
{
pCfg
->
level
,
id
}
,
pCfg
->
dir
);
pTier
->
disks
[
id
]
=
tdNewDisk
(
pCfg
->
level
,
id
,
pCfg
->
dir
);
if
(
pTier
->
disks
[
id
]
==
NULL
)
return
-
1
;
return
0
;
}
int
tdUpdateTierInfo
(
STier
*
pTier
)
{
for
(
int
id
=
0
;
id
<
pTier
->
ndisk
;
id
++
)
{
if
(
tdUpdateDiskInfo
(
DISK_AT_TIER
(
pTier
,
id
))
<
0
)
{
// TODO: deal with the error here
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录