Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f100a328
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f100a328
编写于
4月 07, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
afbaeb0d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
49 deletion
+74
-49
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+63
-40
source/dnode/vnode/src/tsdb/dev/tsdbFSet.h
source/dnode/vnode/src/tsdb/dev/tsdbFSet.h
+11
-9
未找到文件。
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
f100a328
...
...
@@ -42,7 +42,8 @@ static int32_t destroy_file_system(struct STFileSystem **ppFS) {
}
static
int32_t
get_current_json
(
STsdb
*
pTsdb
,
char
fname
[])
{
return
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
pTsdb
->
path
,
TD_DIRSEP
,
"current.json"
),
0
;
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
pTsdb
->
path
,
TD_DIRSEP
,
"current.json"
);
return
0
;
}
static
int32_t
get_current_temp
(
STsdb
*
pTsdb
,
char
fname
[],
EFsEditType
etype
)
{
...
...
@@ -69,12 +70,43 @@ static int32_t load_fs_from_file(const char *fname, struct STFileSystem *pFS) {
}
static
int32_t
commit_edit
(
struct
STFileSystem
*
pFS
,
EFsEditType
etype
)
{
ASSERTS
(
0
,
"TODO: Not implemented yet"
);
int32_t
code
;
char
ofname
[
TSDB_FILENAME_LEN
];
char
nfname
[
TSDB_FILENAME_LEN
];
get_current_json
(
pFS
->
pTsdb
,
nfname
);
get_current_temp
(
pFS
->
pTsdb
,
ofname
,
etype
);
code
=
taosRenameFile
(
ofname
,
nfname
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
code
);
return
code
;
}
ASSERTS
(
0
,
"TODO: Do changes to pFS"
);
return
0
;
}
static
int32_t
abort_edit
(
struct
STFileSystem
*
pFS
,
EFsEditType
etype
)
{
ASSERTS
(
0
,
"TODO: Not implemented yet"
);
int32_t
code
;
char
fname
[
TSDB_FILENAME_LEN
];
get_current_temp
(
pFS
->
pTsdb
,
fname
,
etype
);
code
=
taosRemoveFile
(
fname
);
if
(
code
)
code
=
TAOS_SYSTEM_ERROR
(
code
);
return
code
;
}
static
int32_t
scan_file_system
(
struct
STFileSystem
*
pFS
)
{
// ASSERTS(0, "TODO: Not implemented yet");
return
0
;
}
static
int32_t
scan_and_schedule_merge
(
struct
STFileSystem
*
pFS
)
{
// ASSERTS(0, "TODO: Not implemented yet");
return
0
;
}
...
...
@@ -107,8 +139,6 @@ static int32_t open_file_system(struct STFileSystem *pFS, int8_t rollback) {
code
=
abort_edit
(
pFS
,
TSDB_FS_EDIT_COMMIT
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
else
{
ASSERTS
(
1
,
"Do nothing"
);
}
// check current.json.t existence
...
...
@@ -122,6 +152,12 @@ static int32_t open_file_system(struct STFileSystem *pFS, int8_t rollback) {
}
}
code
=
scan_file_system
(
pFS
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
scan_and_schedule_merge
(
pFS
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
//
...
...
@@ -182,7 +218,6 @@ _exit:
int32_t
tsdbCloseFileSystem
(
struct
STFileSystem
**
ppFS
)
{
if
(
ppFS
[
0
]
==
NULL
)
return
0
;
close_file_system
(
ppFS
[
0
]);
destroy_file_system
(
ppFS
);
return
0
;
...
...
@@ -207,55 +242,43 @@ _exit:
__func__
,
//
lino
,
//
tstrerror
(
code
));
}
else
{
tsdbInfo
(
"vgId:%d %s done, etype:%d"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
etype
);
}
return
code
;
}
int32_t
tsdbFileSystemEditCommit
(
struct
STFileSystem
*
pFS
,
EFsEditType
etype
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
char
ofname
[
TSDB_FILENAME_LEN
];
char
nfname
[
TSDB_FILENAME_LEN
];
get_current_json
(
pFS
->
pTsdb
,
nfname
);
get_current_temp
(
pFS
->
pTsdb
,
ofname
,
etype
);
code
=
taosRenameFile
(
ofname
,
nfname
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
_exit:
int32_t
code
=
commit_edit
(
pFS
,
etype
);
tsem_post
(
&
pFS
->
canEdit
);
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
lino
,
//
tsdbError
(
"vgId:%d %s failed since %s"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
tstrerror
(
code
));
}
else
{
tsdbInfo
(
"vgId:%d %s done, etype:%d"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
etype
);
}
tsem_post
(
&
pFS
->
canEdit
);
return
code
;
}
int32_t
tsdbFileSystemEditAbort
(
struct
STFileSystem
*
pFS
,
EFsEditType
etype
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
char
fname
[
TSDB_FILENAME_LEN
];
get_current_temp
(
pFS
->
pTsdb
,
fname
,
etype
);
code
=
taosRemoveFile
(
fname
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
int32_t
code
=
abort_edit
(
pFS
,
etype
);
tsem_post
(
&
pFS
->
canEdit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed
at line %d since %s
"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
lino
,
//
tstrerror
(
code
)
);
tsdbError
(
"vgId:%d %s failed
since %s, etype:%d
"
,
//
TD_VID
(
pFS
->
pTsdb
->
pVnode
),
//
__func__
,
//
tstrerror
(
code
),
//
etype
);
}
tsem_post
(
&
pFS
->
canEdit
);
return
code
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbFSet.h
浏览文件 @
f100a328
...
...
@@ -24,11 +24,6 @@ extern "C" {
/* Exposed Handle */
struct
SFileSet
;
struct
SSttFileLayer
{
int32_t
level
;
int32_t
nFile
;
struct
STFile
*
fileList
;
};
#define TSDB_STT_FILE_LEVEL_MAX 3
...
...
@@ -36,10 +31,17 @@ struct SSttFileLayer {
/* Exposed Structs */
struct
SFileSet
{
int32_t
fid
;
int64_t
nextid
;
struct
STFile
*
files
[
TSDB_FTYPE_MAX
];
struct
SSttFileLayer
sttLayers
[
TSDB_STT_FILE_LEVEL_MAX
];
int32_t
fid
;
int64_t
nextid
;
struct
STFile
*
fHead
;
// .head
struct
STFile
*
fData
;
// .data
struct
STFile
*
fSma
;
// .sma
struct
STFile
*
fTomb
;
// .tomb
struct
{
int32_t
level
;
int32_t
nFile
;
struct
STFile
*
fileList
;
}
lStt
[
TSDB_STT_FILE_LEVEL_MAX
];
};
#ifdef __cplusplus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录