Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e843619b
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看板
提交
e843619b
编写于
1月 15, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact tsdb fs
上级
d795ff85
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
21 deletion
+33
-21
src/tsdb/inc/tsdbFS.h
src/tsdb/inc/tsdbFS.h
+5
-4
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+2
-1
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+3
-3
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+23
-13
未找到文件。
src/tsdb/inc/tsdbFS.h
浏览文件 @
e843619b
...
@@ -24,7 +24,7 @@ extern "C" {
...
@@ -24,7 +24,7 @@ extern "C" {
// ================== CURRENT file header info
// ================== CURRENT file header info
typedef
struct
{
typedef
struct
{
uint32_t
version
;
// Current file
version
uint32_t
version
;
// Current file
system version (relating to code)
uint32_t
len
;
// Encode content length (including checksum)
uint32_t
len
;
// Encode content length (including checksum)
}
SFSHeader
;
}
SFSHeader
;
...
@@ -72,9 +72,10 @@ STsdbFS *tsdbNewFS(int keep, int days);
...
@@ -72,9 +72,10 @@ STsdbFS *tsdbNewFS(int keep, int days);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tsdbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
);
int
tsdbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
);
void
tsdbCloseFS
(
STsdbFS
*
pFs
);
void
tsdbCloseFS
(
STsdbFS
*
pFs
);
int
tsdbStartTxn
(
STsdbFS
*
pfs
);
uint32_t
tsdbStartFSTxn
(
STsdbFS
*
pfs
);
int
tsdbEndTxn
(
STsdbFS
*
pfs
);
int
tsdbEndFSTxn
(
STsdbFS
*
pfs
);
int
tsdbEndTxnWithError
(
STsdbFS
*
pfs
);
int
tsdbEndFSTxnWithError
(
STsdbFS
*
pfs
);
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
);
void
tsdbUpdateMFile
(
STsdbFS
*
pfs
,
const
SMFile
*
pMFile
);
void
tsdbUpdateMFile
(
STsdbFS
*
pfs
,
const
SMFile
*
pMFile
);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
...
...
src/tsdb/inc/tsdbFile.h
浏览文件 @
e843619b
...
@@ -57,10 +57,11 @@ void tsdbInitMFile(SMFile* pMFile, SDiskID did, int vid, uint32_t ver);
...
@@ -57,10 +57,11 @@ void tsdbInitMFile(SMFile* pMFile, SDiskID did, int vid, uint32_t ver);
void
tsdbInitMFileEx
(
SMFile
*
pMFile
,
SMFile
*
pOMFile
);
void
tsdbInitMFileEx
(
SMFile
*
pMFile
,
SMFile
*
pOMFile
);
int
tsdbEncodeSMFile
(
void
**
buf
,
SMFile
*
pMFile
);
int
tsdbEncodeSMFile
(
void
**
buf
,
SMFile
*
pMFile
);
void
*
tsdbDecodeSMFile
(
void
*
buf
,
SMFile
*
pMFile
);
void
*
tsdbDecodeSMFile
(
void
*
buf
,
SMFile
*
pMFile
);
int
tsdbApplyMFileChange
(
SMFile
*
from
,
SMFile
*
to
);
int
tsdbCreateMFile
(
SMFile
*
pMFile
);
int
tsdbCreateMFile
(
SMFile
*
pMFile
);
int
tsdbUpdateMFileHeader
(
SMFile
*
pMFile
);
int
tsdbUpdateMFileHeader
(
SMFile
*
pMFile
);
static
FORCE_INLINE
void
tsdbSetMFileInfo
(
SMFile
*
pMFile
,
SMInfo
*
pInfo
)
{
pMFile
->
info
=
*
pInfo
;
}
static
FORCE_INLINE
void
tsdbSetMFileInfo
(
SMFile
*
pMFile
,
SM
F
Info
*
pInfo
)
{
pMFile
->
info
=
*
pInfo
;
}
static
FORCE_INLINE
int
tsdbOpenMFile
(
SMFile
*
pMFile
,
int
flags
)
{
static
FORCE_INLINE
int
tsdbOpenMFile
(
SMFile
*
pMFile
,
int
flags
)
{
ASSERT
(
TSDB_FILE_CLOSED
(
pMFile
));
ASSERT
(
TSDB_FILE_CLOSED
(
pMFile
));
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
e843619b
...
@@ -361,7 +361,7 @@ static int tsdbStartCommit(STsdbRepo *pRepo) {
...
@@ -361,7 +361,7 @@ static int tsdbStartCommit(STsdbRepo *pRepo) {
tsdbInfo
(
"vgId:%d start to commit! keyFirst %"
PRId64
" keyLast %"
PRId64
" numOfRows %"
PRId64
" meta rows: %d"
,
tsdbInfo
(
"vgId:%d start to commit! keyFirst %"
PRId64
" keyLast %"
PRId64
" numOfRows %"
PRId64
" meta rows: %d"
,
REPO_ID
(
pRepo
),
pMem
->
keyFirst
,
pMem
->
keyLast
,
pMem
->
numOfRows
,
listNEles
(
pMem
->
actList
));
REPO_ID
(
pRepo
),
pMem
->
keyFirst
,
pMem
->
keyLast
,
pMem
->
numOfRows
,
listNEles
(
pMem
->
actList
));
if
(
tsdbStartTxn
(
REPO_FS
(
pRepo
))
<
0
)
return
-
1
;
if
(
tsdbStart
FS
Txn
(
REPO_FS
(
pRepo
))
<
0
)
return
-
1
;
pRepo
->
code
=
TSDB_CODE_SUCCESS
;
pRepo
->
code
=
TSDB_CODE_SUCCESS
;
return
0
;
return
0
;
...
@@ -369,9 +369,9 @@ static int tsdbStartCommit(STsdbRepo *pRepo) {
...
@@ -369,9 +369,9 @@ static int tsdbStartCommit(STsdbRepo *pRepo) {
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
if
(
eno
!=
TSDB_CODE_SUCCESS
)
{
if
(
eno
!=
TSDB_CODE_SUCCESS
)
{
tsdbEndTxnWithError
(
REPO_FS
(
pRepo
));
tsdbEnd
FS
TxnWithError
(
REPO_FS
(
pRepo
));
}
else
{
}
else
{
tsdbEndTxn
(
REPO_FS
(
pRepo
));
tsdbEnd
FS
Txn
(
REPO_FS
(
pRepo
));
}
}
tsdbInfo
(
"vgId:%d commit over, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
tsdbInfo
(
"vgId:%d commit over, %s"
,
REPO_ID
(
pRepo
),
(
eno
==
TSDB_CODE_SUCCESS
)
?
"succeed"
:
"failed"
);
...
...
src/tsdb/src/tsdbFS.c
浏览文件 @
e843619b
...
@@ -40,7 +40,7 @@ static void *tsdbDecodeFSHeader(void *buf, SFSHeader *pHeader) {
...
@@ -40,7 +40,7 @@ static void *tsdbDecodeFSHeader(void *buf, SFSHeader *pHeader) {
static
int
tsdbEncodeFSMeta
(
void
**
buf
,
STsdbFSMeta
*
pMeta
)
{
static
int
tsdbEncodeFSMeta
(
void
**
buf
,
STsdbFSMeta
*
pMeta
)
{
int
tlen
=
0
;
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU
64
(
buf
,
pMeta
->
version
);
tlen
+=
taosEncodeFixedU
32
(
buf
,
pMeta
->
version
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pMeta
->
totalPoints
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pMeta
->
totalPoints
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pMeta
->
totalStorage
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pMeta
->
totalStorage
);
...
@@ -48,7 +48,7 @@ static int tsdbEncodeFSMeta(void **buf, STsdbFSMeta *pMeta) {
...
@@ -48,7 +48,7 @@ static int tsdbEncodeFSMeta(void **buf, STsdbFSMeta *pMeta) {
}
}
static
void
*
tsdbDecodeFSMeta
(
void
*
buf
,
STsdbFSMeta
*
pMeta
)
{
static
void
*
tsdbDecodeFSMeta
(
void
*
buf
,
STsdbFSMeta
*
pMeta
)
{
buf
=
taosDecodeFixedU
64
(
buf
,
&
(
pMeta
->
version
));
buf
=
taosDecodeFixedU
32
(
buf
,
&
(
pMeta
->
version
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pMeta
->
totalPoints
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pMeta
->
totalPoints
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pMeta
->
totalStorage
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pMeta
->
totalStorage
));
...
@@ -70,7 +70,7 @@ static int tsdbEncodeDFileSetArray(void **buf, SArray *pArray) {
...
@@ -70,7 +70,7 @@ static int tsdbEncodeDFileSetArray(void **buf, SArray *pArray) {
return
tlen
;
return
tlen
;
}
}
static
int
tsdbDecodeDFileSetArray
(
void
*
buf
,
SArray
*
pArray
)
{
static
void
*
tsdbDecodeDFileSetArray
(
void
*
buf
,
SArray
*
pArray
)
{
uint64_t
nset
;
uint64_t
nset
;
SDFileSet
dset
;
SDFileSet
dset
;
...
@@ -89,7 +89,7 @@ static int tsdbEncodeFSStatus(void **buf, SFSStatus *pStatus) {
...
@@ -89,7 +89,7 @@ static int tsdbEncodeFSStatus(void **buf, SFSStatus *pStatus) {
int
tlen
=
0
;
int
tlen
=
0
;
tlen
+=
tsdbEncodeSMFile
(
buf
,
&
(
pStatus
->
pmf
)
);
tlen
+=
tsdbEncodeSMFile
(
buf
,
pStatus
->
pmf
);
tlen
+=
tsdbEncodeDFileSetArray
(
buf
,
pStatus
->
df
);
tlen
+=
tsdbEncodeDFileSetArray
(
buf
,
pStatus
->
df
);
return
tlen
;
return
tlen
;
...
@@ -113,6 +113,8 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) {
...
@@ -113,6 +113,8 @@ static SFSStatus *tsdbNewFSStatus(int maxFSet) {
return
NULL
;
return
NULL
;
}
}
TSDB_FSET_SET_CLOSED
(
&
(
pStatus
->
mf
));
pStatus
->
df
=
taosArrayInit
(
maxFSet
,
sizeof
(
SDFileSet
));
pStatus
->
df
=
taosArrayInit
(
maxFSet
,
sizeof
(
SDFileSet
));
if
(
pStatus
->
df
==
NULL
)
{
if
(
pStatus
->
df
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
...
@@ -137,6 +139,8 @@ static void tsdbResetFSStatus(SFSStatus *pStatus) {
...
@@ -137,6 +139,8 @@ static void tsdbResetFSStatus(SFSStatus *pStatus) {
return
;
return
;
}
}
TSDB_FSET_SET_CLOSED
(
&
(
pStatus
->
mf
));
pStatus
->
pmf
=
NULL
;
pStatus
->
pmf
=
NULL
;
taosArrayClear
(
pStatus
->
df
);
taosArrayClear
(
pStatus
->
df
);
}
}
...
@@ -162,6 +166,7 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
...
@@ -162,6 +166,7 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
}
}
// ================== STsdbFS
// ================== STsdbFS
// TODO
STsdbFS
*
tsdbNewFS
(
int
keep
,
int
days
)
{
STsdbFS
*
tsdbNewFS
(
int
keep
,
int
days
)
{
int
maxFSet
=
TSDB_MAX_FSETS
(
keep
,
days
);
int
maxFSet
=
TSDB_MAX_FSETS
(
keep
,
days
);
STsdbFS
*
pfs
;
STsdbFS
*
pfs
;
...
@@ -201,6 +206,7 @@ STsdbFS *tsdbNewFS(int keep, int days) {
...
@@ -201,6 +206,7 @@ STsdbFS *tsdbNewFS(int keep, int days) {
return
pfs
;
return
pfs
;
}
}
// TODO
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
)
{
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
)
{
if
(
pfs
)
{
if
(
pfs
)
{
pfs
->
nstatus
=
tsdbFreeFSStatus
(
pfs
->
nstatus
);
pfs
->
nstatus
=
tsdbFreeFSStatus
(
pfs
->
nstatus
);
...
@@ -213,33 +219,37 @@ void *tsdbFreeFS(STsdbFS *pfs) {
...
@@ -213,33 +219,37 @@ void *tsdbFreeFS(STsdbFS *pfs) {
return
NULL
;
return
NULL
;
}
}
// TODO
int
tsdbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
)
{
int
tsdbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
)
{
// TODO
// TODO
return
0
;
return
0
;
}
}
// TODO
void
tsdbCloseFS
(
STsdbFS
*
pFs
)
{
void
tsdbCloseFS
(
STsdbFS
*
pFs
)
{
// TODO
// TODO
}
}
// Start a new transaction to modify the file system
// Start a new transaction to modify the file system
int
tsdbStart
Txn
(
STsdbFS
*
pfs
)
{
uint32_t
tsdbStartFS
Txn
(
STsdbFS
*
pfs
)
{
ASSERT
(
pfs
->
intxn
==
false
);
ASSERT
(
pfs
->
intxn
==
false
);
pfs
->
intxn
=
true
;
pfs
->
intxn
=
true
;
tsdbResetFSStatus
(
pfs
->
nstatus
);
tsdbResetFSStatus
(
pfs
->
nstatus
);
return
0
;
return
pfs
->
cstatus
->
meta
.
version
+
1
;
}
}
int
tsdbEndTxn
(
STsdbFS
*
pfs
)
{
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
)
{
pfs
->
nstatus
->
meta
=
*
pMeta
;
}
int
tsdbEndFSTxn
(
STsdbFS
*
pfs
)
{
ASSERT
(
FS_IN_TXN
(
pfs
));
ASSERT
(
FS_IN_TXN
(
pfs
));
SFSStatus
*
pStatus
;
SFSStatus
*
pStatus
;
// Write current file system snapshot
// Write current file system snapshot
if
(
tsdb
UpdateFS
(
pfs
)
<
0
)
{
if
(
tsdb
ApplyFSTxn
(
pfs
)
<
0
)
{
tsdbEndTxnWithError
(
pfs
);
tsdbEnd
FS
TxnWithError
(
pfs
);
return
-
1
;
return
-
1
;
}
}
...
@@ -251,13 +261,13 @@ int tsdbEndTxn(STsdbFS *pfs) {
...
@@ -251,13 +261,13 @@ int tsdbEndTxn(STsdbFS *pfs) {
tsdbUnLockFS
(
pfs
);
tsdbUnLockFS
(
pfs
);
// Apply actual change to each file and SDFileSet
// Apply actual change to each file and SDFileSet
tsdbApplyFS
ChangeOnDisk
(
pf
s
);
tsdbApplyFS
TxnOnDisk
(
pfs
->
nstatus
,
pfs
->
cstatu
s
);
pfs
->
intxn
=
false
;
pfs
->
intxn
=
false
;
return
0
;
return
0
;
}
}
int
tsdbEndTxnWithError
(
STsdbFS
*
pfs
)
{
int
tsdbEnd
FS
TxnWithError
(
STsdbFS
*
pfs
)
{
// TODO
// TODO
pfs
->
intxn
=
false
;
pfs
->
intxn
=
false
;
return
0
;
return
0
;
...
@@ -267,7 +277,7 @@ void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile) { tsdbSetStatusMFile(pf
...
@@ -267,7 +277,7 @@ void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile) { tsdbSetStatusMFile(pf
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
)
{
return
tsdbAddDFileSetToStatus
(
pfs
->
nstatus
,
pSet
);
}
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
)
{
return
tsdbAddDFileSetToStatus
(
pfs
->
nstatus
,
pSet
);
}
static
int
tsdb
UpdateFS
(
STsdbFS
*
pfs
)
{
static
int
tsdb
ApplyFSTxn
(
STsdbFS
*
pfs
)
{
ASSERT
(
FS_IN_TXN
(
pfs
));
ASSERT
(
FS_IN_TXN
(
pfs
));
SFSHeader
fsheader
;
SFSHeader
fsheader
;
void
*
pBuf
=
NULL
;
void
*
pBuf
=
NULL
;
...
@@ -339,7 +349,7 @@ static int tsdbUpdateFS(STsdbFS *pfs) {
...
@@ -339,7 +349,7 @@ static int tsdbUpdateFS(STsdbFS *pfs) {
return
0
;
return
0
;
}
}
static
void
tsdbApplyFS
Change
OnDisk
(
SFSStatus
*
pFrom
,
SFSStatus
*
pTo
)
{
static
void
tsdbApplyFS
Txn
OnDisk
(
SFSStatus
*
pFrom
,
SFSStatus
*
pTo
)
{
int
ifrom
=
0
;
int
ifrom
=
0
;
int
ito
=
0
;
int
ito
=
0
;
size_t
sizeFrom
,
sizeTo
;
size_t
sizeFrom
,
sizeTo
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录