Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
TDengine
提交
cb98cd3f
T
TDengine
项目概览
XKZJ_WCL
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cb98cd3f
编写于
11月 20, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
aaa1c1cc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
103 addition
and
47 deletion
+103
-47
src/inc/taoserror.h
src/inc/taoserror.h
+8
-0
src/tfs/inc/tdisk.h
src/tfs/inc/tdisk.h
+2
-0
src/tfs/inc/tfslog.h
src/tfs/inc/tfslog.h
+34
-0
src/tfs/inc/ttier.h
src/tfs/inc/ttier.h
+1
-1
src/tfs/src/tdisk.c
src/tfs/src/tdisk.c
+1
-0
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+41
-26
src/tfs/src/ttier.c
src/tfs/src/ttier.c
+16
-20
未找到文件。
src/inc/taoserror.h
浏览文件 @
cb98cd3f
...
...
@@ -389,6 +389,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_SRC_BAD_SEQ, 0, 0x2113, "src bad se
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_INCOMPLETE
,
0
,
0x2114
,
"src incomplete"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_GENERAL
,
0
,
0x2115
,
"src general"
)
// tfs
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_OUT_OF_MEMORY
,
0
,
0x2200
,
"tfs out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_INVLD_CFG
0
,
0x2201
,
"tfs invalid mount config"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_TOO_MANY_MOUNT
0
,
0x2202
,
"tfs too many mount"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_DUP_PRIMARY
0
,
0x2203
,
"tfs duplicate primary mount"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_NO_PRIMARY_DISK
0
,
0x2204
,
"tfs no primary mount"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_FS_NO_MOUNT_AT_TIER
0
,
0x2205
,
"tfs no mount at tier"
)
#ifdef TAOS_ERROR_C
};
...
...
src/tfs/inc/tdisk.h
浏览文件 @
cb98cd3f
...
...
@@ -16,6 +16,8 @@
#ifndef TD_TDISK_H
#define TD_TDISK_H
#include "tfslog.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
src/tfs/inc/tfslog.h
0 → 100644
浏览文件 @
cb98cd3f
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TD_TFSLOG_H
#define TD_TFSLOG_H
#ifdef __cplusplus
extern
"C"
{
#endif
#define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("FS FATAL ", 255, __VA_ARGS__); }}
#define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("FS ERROR ", 255, __VA_ARGS__); }}
#define fWarn(...) { if (fsDebugFlag & DEBUG_WARN) { taosPrintLog("FS WARN ", 255, __VA_ARGS__); }}
#define fInfo(...) { if (fsDebugFlag & DEBUG_INFO) { taosPrintLog("FS ", 255, __VA_ARGS__); }}
#define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("FS ", cqDebugFlag, __VA_ARGS__); }}
#define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("FS ", cqDebugFlag, __VA_ARGS__); }}
#ifdef __cplusplus
}
#endif
#endif
\ No newline at end of file
src/tfs/inc/ttier.h
浏览文件 @
cb98cd3f
...
...
@@ -30,7 +30,7 @@ typedef struct {
SDisk
*
disks
[
TSDB_MAX_DISK_PER_TIER
];
}
STier
;
#define DISK_AT_TIER(pTier, id) ((pTier)->disks
+ (id)
)
#define DISK_AT_TIER(pTier, id) ((pTier)->disks
[id]
)
void
tdInitTier
(
STier
*
pTier
,
int
level
);
void
tdDestroyTier
(
STier
*
pTier
);
...
...
src/tfs/src/tdisk.c
浏览文件 @
cb98cd3f
...
...
@@ -14,6 +14,7 @@
*/
#include "tdisk.h"
#include "taoserror.h"
SDisk
*
tdNewDisk
(
int
level
,
int
id
,
char
*
dir
)
{
SDisk
*
pDisk
=
(
SDisk
*
)
calloc
(
1
,
sizeof
(
*
pDisk
));
...
...
src/tfs/src/tfs.c
浏览文件 @
cb98cd3f
...
...
@@ -14,17 +14,12 @@
*/
#include "os.h"
#include "hash.h"
#include "ttier.h"
#include "tglobal.h"
#include "taoserror.h"
#define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("FS FATAL ", 255, __VA_ARGS__); }}
#define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("FS ERROR ", 255, __VA_ARGS__); }}
#define fWarn(...) { if (fsDebugFlag & DEBUG_WARN) { taosPrintLog("FS WARN ", 255, __VA_ARGS__); }}
#define fInfo(...) { if (fsDebugFlag & DEBUG_INFO) { taosPrintLog("FS ", 255, __VA_ARGS__); }}
#define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("FS ", cqDebugFlag, __VA_ARGS__); }}
#define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("FS ", cqDebugFlag, __VA_ARGS__); }}
#include "tfs.h"
#include "tglobal.h"
#include "ttier.h"
#define TSDB_MAX_TIER 3
...
...
@@ -69,7 +64,7 @@ int tfsInit(SDiskCfg *pDiskCfg, int ndisk) {
}
for
(
int
idisk
=
0
;
idisk
<
ndisk
;
idisk
++
)
{
if
(
tfs
AddDisk
(
pDiskCfg
+
idisk
)
<
0
)
{
if
(
tfs
Mount
(
pDiskCfg
+
idisk
)
<
0
)
{
tfsDestroy
();
return
-
1
;
}
...
...
@@ -106,7 +101,7 @@ int tfsUpdateInfo() {
}
void
tfsPrimaryPath
(
char
*
dst
)
{
strncpy
(
dst
,
DISK_AT
)
strncpy
(
dst
,
DISK_AT
(
0
,
0
)
->
dir
,
TSDB_FILENAME_LEN
);
}
int
tfsCreateDir
(
char
*
name
)
{
...
...
@@ -131,16 +126,23 @@ int tfsCreateDir(char *name) {
return
0
;
}
static
int
tfsAddDisk
(
SDiskCfg
*
pCfg
)
{
static
int
tfsMount
(
SDiskCfg
*
pCfg
)
{
SDiskID
did
;
if
(
tfsCheckAndFormatCfg
(
pCfg
)
<
0
)
return
-
1
;
if
(
tdAddDiskToTier
(
pCfg
,
TIER_AT
(
pCfg
->
level
))
<
0
)
{
did
.
level
=
pCfg
->
level
;
did
.
id
=
tdAddDiskToTier
(
TIER_AT
(
pCfg
->
level
),
pCfg
);
if
(
did
.
id
<
0
)
{
fError
(
"failed to add disk %s to FS since %s"
,
pCfg
->
dir
,
tstrerror
(
terrno
));
return
-
1
;
}
taosHashPut
(
pTiers
->
map
,
(
void
*
)
dirName
,
strnlen
(
dirName
,
TSDB_FILENAME_LEN
),
(
void
*
)(
&
diskid
),
sizeof
(
disk
id
));
taosHashPut
(
pTiers
->
map
,
pCfg
->
dir
,
strnlen
(
pCfg
->
dir
,
TSDB_FILENAME_LEN
),
(
void
*
)(
&
did
),
sizeof
(
d
id
));
if
(
pfs
->
nlevel
<
pCfg
->
level
+
1
)
pfs
->
nlevel
=
pCfg
->
level
+
1
;
// TODO: update meta info
return
0
;
}
...
...
@@ -154,12 +156,19 @@ static int tfsCheckAndFormatCfg(SDiskCfg *pCfg) {
return
-
1
;
}
if
(
pCfg
->
primary
&&
pCfg
->
level
!=
0
)
{
fError
(
"failed to add disk %s to FS since disk is primary but level %d not 0"
,
pCfg
->
dir
,
pCfg
->
level
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
}
if
(
pCfg
->
primary
)
{
if
(
pCfg
->
level
!=
0
)
{
fError
(
"failed to add disk %s to FS since disk is primary but level %d not 0"
,
pCfg
->
dir
,
pCfg
->
level
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
}
if
(
DISK_AT
(
0
,
0
)
!=
NULL
)
{
fError
(
"failed to add disk %s to FS since duplicate primary mount"
,
pCfg
->
dir
,
pCfg
->
level
);
terrno
=
TSDB_CODE_FS_DUP_PRIMARY
;
return
-
1
;
}
}
if
(
tfsFormatDir
(
pCfg
->
dir
,
dirName
)
<
0
)
{
fError
(
"failed to add disk %s to FS since invalid dir format"
,
pCfg
->
dir
);
...
...
@@ -167,14 +176,14 @@ static int tfsCheckAndFormatCfg(SDiskCfg *pCfg) {
return
-
1
;
}
if
(
t
dGetDiskByName
(
dirName
)
)
{
fError
(
"failed to add disk %s to FS since duplicate
add
"
,
pCfg
->
dir
);
if
(
t
fsGetDiskByName
(
dirName
)
!=
NULL
)
{
fError
(
"failed to add disk %s to FS since duplicate
mount
"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
}
if
(
access
(
dirName
,
W_OK
|
R_OK
|
F_OK
)
!=
0
)
{
fError
(
"failed to add disk %s to FS since no
enough
access rights"
,
pCfg
->
dir
);
fError
(
"failed to add disk %s to FS since no
R/W
access rights"
,
pCfg
->
dir
);
terrno
=
TSDB_CODE_FS_INVLD_CFG
;
return
-
1
;
}
...
...
@@ -223,13 +232,14 @@ static int tfsCheck() {
return
-
1
;
}
for
(
int
level
=
0
;
level
<
pfs
->
nlevel
;
level
++
)
{
int
level
=
0
;
do
{
if
(
TIER_AT
(
level
)
->
ndisk
==
0
)
{
fError
(
"no disk at level %d"
,
level
);
terrno
=
TSDB_CODE_FS_NO_
DISK
_AT_TIER
;
terrno
=
TSDB_CODE_FS_NO_
MOUNT
_AT_TIER
;
return
-
1
;
}
}
}
while
(
level
<
pfs
->
nlevel
);
return
0
;
}
...
...
@@ -252,4 +262,9 @@ static tfsUnLock() {
}
return
0
;
}
\ No newline at end of file
}
static
tfsGetDiskByName
(
char
*
dirName
)
{
}
static
SDisk
*
tfsGetDiskByID
(
SDiskID
did
)
{
return
DISK_AT
(
did
.
level
,
did
.
id
);
}
\ No newline at end of file
src/tfs/src/ttier.c
浏览文件 @
cb98cd3f
...
...
@@ -15,6 +15,7 @@
#include "ttier.h"
#include "tglobal.h"
#include "taoserror.h"
void
tdInitTier
(
STier
*
pTier
,
int
level
)
{
pTier
->
level
=
level
;
...
...
@@ -23,8 +24,9 @@ void tdInitTier(STier *pTier, int level) {
void
tdDestroyTier
(
STier
*
pTier
)
{
for
(
int
id
=
0
;
id
<
TSDB_MAX_DISK_PER_TIER
;
id
++
)
{
tdFreeDisk
(
DISK_AT_TIER
(
pTier
,
id
));
DISK_AT_TIER
(
pTier
,
id
)
=
NULL
;
pTier
->
disks
[
id
]
=
NULL
;
}
pTier
->
ndisk
=
0
;
}
SDisk
*
tdAddDiskToTier
(
STier
*
pTier
,
SDiskCfg
*
pCfg
)
{
...
...
@@ -32,35 +34,29 @@ SDisk *tdAddDiskToTier(STier *pTier, SDiskCfg *pCfg) {
int
id
=
0
;
if
(
pTier
->
ndisk
>=
TSDB_MAX_DISK_PER_TIER
)
{
terrno
=
TSDB_CODE_FS_TOO_MANY_
DISKS
;
terrno
=
TSDB_CODE_FS_TOO_MANY_
MOUNT
;
return
-
1
;
}
if
(
pCfg
->
primary
)
{
if
(
DISK_AT
(
0
,
0
)
!=
NULL
)
{
terrno
=
TSDB_CODE_FS_DUP_PRIMARY
;
return
-
1
;
}
}
else
{
if
(
pTier
->
level
==
0
)
{
if
(
DISK_AT_TIER
(
pTier
,
0
)
!=
NULL
)
{
id
=
pTier
->
ndisk
;
}
else
{
id
=
pTier
->
ndisk
+
1
;
if
(
id
>=
TSDB_MAX_DISK_PER_TIER
)
{
terrno
=
TSDB_CODE_FS_TOO_MANY_DISKS
;
return
-
1
;
}
}
}
else
{
if
(
pTier
->
level
==
0
)
{
if
(
DISK_AT_TIER
(
pTier
,
0
)
!=
NULL
)
{
id
=
pTier
->
ndisk
;
}
else
{
id
=
pTier
->
ndisk
+
1
;
if
(
id
>=
TSDB_MAX_DISK_PER_TIER
)
{
terrno
=
TSDB_CODE_FS_TOO_MANY_MOUNT
;
return
-
1
;
}
}
}
else
{
id
=
pTier
->
ndisk
;
}
pTier
->
disks
[
id
]
=
tdNewDisk
(
pCfg
->
level
,
id
,
pCfg
->
dir
);
if
(
pTier
->
disks
[
id
]
==
NULL
)
return
-
1
;
pTier
->
ndisk
++
;
return
0
;
return
id
;
}
int
tdUpdateTierInfo
(
STier
*
pTier
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录