Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
65e388a5
T
TDengine
项目概览
慢慢CG
/
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看板
提交
65e388a5
编写于
11月 22, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
e96516ff
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
113 addition
and
14 deletion
+113
-14
src/inc/tfs.h
src/inc/tfs.h
+8
-0
src/tfs/src/tfcntl.c
src/tfs/src/tfcntl.c
+48
-4
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-4
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+0
-6
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+55
-0
未找到文件。
src/inc/tfs.h
浏览文件 @
65e388a5
...
...
@@ -39,6 +39,14 @@ TFSDIR * tfsOpenDir(char *dir);
void
tfsCloseDir
(
TFSDIR
*
tdir
);
const
TFSFILE
*
tfsReadDir
(
TFSDIR
*
tdir
);
const
char
*
tfsAbsName
(
TFSFILE
*
pfile
,
char
dest
[]);
const
char
*
tfsRelName
(
TFSFILE
*
pfile
,
char
dest
[]);
void
tfsDirName
(
TFSFILE
*
pfile
,
char
dest
[]);
void
tfsBaseName
(
TFSFILE
*
pfile
,
char
dest
[]);
int
tfsopen
(
TFSFILE
*
pfile
);
int
tfsclose
(
int
,
fd
);
const
char
*
tfsGetDiskName
(
int
level
,
int
id
);
#ifdef __cplusplus
...
...
src/tfs/src/tfcntl.c
浏览文件 @
65e388a5
...
...
@@ -21,7 +21,8 @@
struct
TFSFILE
{
int
level
;
int
id
;
char
name
[
TSDB_FILENAME_LEN
];
char
rname
[
TSDB_FILENAME_LEN
];
// REL name
char
aname
[
TSDB_FILENAME_LEN
];
// ABS name
};
struct
TFSDIR
{
...
...
@@ -60,12 +61,13 @@ void tfsCloseDir(TFSDIR *tdir) {
const
TFSFILE
*
tfsReadDir
(
TFSDIR
*
tdir
)
{
if
(
tdir
->
dir
==
NULL
)
return
NULL
;
char
rname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
while
(
true
)
{
struct
dirent
*
dp
=
readdir
(
tdir
->
dir
);
if
(
dp
!=
NULL
)
{
tdir
->
tfsfile
.
level
=
tdir
->
level
;
tdir
->
tfsfile
.
id
=
tdir
->
id
;
snprintf
(
tdir
->
tfsfile
.
name
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
tdir
->
name
,
dp
->
d_name
);
snprintf
(
rname
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
tdir
->
name
,
dp
->
d_name
);
tsfInitFile
(
&
(
tdir
->
tfsfile
),
tdir
->
level
,
tdir
->
id
,
rname
);
return
&
(
tdir
->
tfsfile
);
}
...
...
@@ -88,6 +90,41 @@ const TFSFILE *tfsReadDir(TFSDIR *tdir) {
}
}
const
char
*
tfsAbsName
(
TFSFILE
*
pfile
,
char
dest
[])
{
return
pfile
->
aname
;
}
const
char
*
tfsRelName
(
TFSFILE
*
pfile
,
char
dest
[])
{
return
pfile
->
rname
;
}
void
tfsDirName
(
TFSFILE
*
pfile
,
char
dest
[])
{
char
fname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
tfsAbsFname
(
pfile
,
fname
);
strncpy
(
dest
,
dirname
(
fname
),
TSDB_FILENAME_LEN
);
}
void
tfsBaseName
(
TFSFILE
*
pfile
,
char
dest
[])
{
char
fname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
memcpy
((
void
*
)
fname
,
(
void
*
)
pfile
->
rname
,
TSDB_FILENAME_LEN
);
strncpy
(
dest
,
basename
(
fname
),
TSDB_FILENAME_LEN
);
}
int
tfsopen
(
TFSFILE
*
pfile
,
int
flags
)
{
int
fd
=
open
(
pfile
->
aname
,
flags
);
if
(
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
return
fd
;
}
int
tfsclose
(
int
fd
)
{
if
(
close
(
fd
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
return
0
}
static
int
tfsOpenDirImpl
(
TFSDIR
*
tdir
)
{
char
dirName
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
...
...
@@ -115,4 +152,11 @@ static int tfsOpenDirImpl(TFSDIR *tdir) {
ASSERT
(
tdir
->
dir
==
NULL
);
return
0
;
}
static
void
tsfInitFile
(
TFSFILE
*
pfile
,
int
level
,
int
id
,
char
*
rname
)
{
pfile
->
level
=
level
;
pfile
->
id
=
id
;
strncpy
(
pfile
->
rname
,
rname
,
TSDB_FILENAME_LEN
);
snprintf
(
pfile
->
aname
,
TSDB_FILENAME_LEN
,
"%s/%s"
,
tfsGetDiskName
(
level
,
id
),
rname
);
}
\ No newline at end of file
src/tsdb/inc/tsdbMain.h
浏览文件 @
65e388a5
...
...
@@ -189,10 +189,8 @@ typedef struct {
}
STsdbFileInfo
;
typedef
struct
{
// char fname[TSDB_FILENAME_LEN];
// int fd;
STfsFile
tfile
;
int
fd
;
TFSFILE
tfile
;
STsdbFileInfo
info
;
}
SFile
;
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
65e388a5
...
...
@@ -215,12 +215,6 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
goto
_err
;
}
// Open files for write/read
if
(
tsdbSetAndOpenHelperFile
(
pHelper
,
pGroup
)
<
0
)
{
tsdbError
(
"vgId:%d failed to set helper file since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
goto
_err
;
}
newLast
=
TSDB_NLAST_FILE_OPENED
(
pHelper
);
if
(
tsdbLoadCompIdx
(
pHelper
,
NULL
)
<
0
)
{
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
65e388a5
...
...
@@ -68,6 +68,61 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
ASSERT
(
pRepo
!=
NULL
&&
pRepo
->
tsdbFileH
!=
NULL
);
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
// 1. scan and get all files corresponds
TFSDIR
*
tdir
=
NULL
;
char
fname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
regex_t
regex
=
{
0
};
int
code
=
0
;
int
vid
=
0
;
int
fid
=
0
;
const
TFSFILE
*
pfile
=
NULL
;
code
=
regcomp
(
&
regex
,
"^v[0-9]+f[0-9]+
\\
.(head|data|last|h|d|l)$"
,
REG_EXTENDED
);
if
(
code
!=
0
)
{
// TODO: deal the error
}
snprintf
(
dataDir
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/tsdb/data"
,
REPO_ID
(
pRepo
));
tdir
=
tfsOpenDir
(
dataDir
);
if
(
tdir
==
NULL
)
{
// TODO: deal the error
}
while
((
pfile
=
tfsReadDir
(
tdir
))
!=
NULL
)
{
tfsBaseName
(
pfile
,
fname
);
if
(
strcmp
(
fname
,
"."
)
==
0
||
strcmp
(
fname
,
".."
)
==
0
)
continue
;
code
=
regexec
(
&
regex
,
fname
,
0
,
NULL
,
0
);
if
(
code
==
0
)
{
sscanf
(
fname
,
"v%df%d"
,
&
vid
,
&
fid
);
if
(
vid
!=
REPO_ID
(
pRepo
))
{
tfsAbsName
(
pfile
,
fname
);
tsdbError
(
"vgId:%d invalid file %s exists, ignore"
,
REPO_ID
(
pRepo
),
fname
);
continue
;
}
// TODO
{}
}
else
if
(
code
==
REG_NOMATCH
)
{
tfsAbsName
(
pfile
,
fname
);
tsdbWarn
(
"vgId:%d unrecognizable file %s exists, ignore"
,
REPO_ID
(
pRepo
),
fname
);
continue
;
}
else
{
tsdbError
(
"vgId:%d regexec failed since %s"
,
REPO_ID
(
pRepo
),
strerror
(
code
));
// TODO: deal with error
}
}
// 2. Sort all files according to fid
// 3. Recover all files of each fid
while
(
true
)
{
// TODO
}
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录