Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3e222bf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
c3e222bf
编写于
1月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact tfs module
上级
ec66739d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
31 addition
and
25 deletion
+31
-25
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+2
-1
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+12
-11
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+2
-1
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+1
-0
source/libs/tfs/inc/tfsInt.h
source/libs/tfs/inc/tfsInt.h
+6
-6
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+6
-5
source/libs/tfs/src/tfsDisk.c
source/libs/tfs/src/tfsDisk.c
+1
-1
source/libs/tfs/src/tfsTier.c
source/libs/tfs/src/tfsTier.c
+1
-0
未找到文件。
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
c3e222bf
...
...
@@ -381,7 +381,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
pMgmt
->
openVnodes
,
pMgmt
->
totalVnodes
);
dndReportStartup
(
pDnode
,
"open-vnodes"
,
stepDesc
);
SVnodeCfg
cfg
=
{.
pDnode
=
pDnode
,
.
vgId
=
pCfg
->
vgId
};
SVnodeCfg
cfg
=
{.
pDnode
=
pDnode
,
.
pTfs
=
pDnode
->
pTfs
,
.
vgId
=
pCfg
->
vgId
};
SVnode
*
pImpl
=
vnodeOpen
(
pCfg
->
path
,
&
cfg
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode by thread:%d"
,
pCfg
->
vgId
,
pThread
->
threadIndex
);
...
...
@@ -587,6 +587,7 @@ int32_t dndProcessCreateVnodeReq(SDnode *pDnode, SRpcMsg *pReq) {
}
vnodeCfg
.
pDnode
=
pDnode
;
vnodeCfg
.
pTfs
=
pDnode
->
pTfs
;
SVnode
*
pImpl
=
vnodeOpen
(
wrapperCfg
.
path
,
&
vnodeCfg
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to create vnode since %s"
,
pCreate
->
vgId
,
terrstr
());
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
c3e222bf
...
...
@@ -23,9 +23,9 @@ static const char *tsdbTxnFname[] = {"current.t", "current"};
static
int
tsdbComparFidFSet
(
const
void
*
arg1
,
const
void
*
arg2
);
static
void
tsdbResetFSStatus
(
SFSStatus
*
pStatus
);
static
int
tsdbSaveFSStatus
(
ST
fs
*
pTfs
,
SFSStatus
*
pStatus
,
int
vid
);
static
int
tsdbSaveFSStatus
(
ST
sdb
*
pRepo
,
SFSStatus
*
pStatus
);
static
void
tsdbApplyFSTxnOnDisk
(
SFSStatus
*
pFrom
,
SFSStatus
*
pTo
);
static
void
tsdbGetTxnFname
(
ST
fs
*
pTfs
,
int
repoid
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[]);
static
void
tsdbGetTxnFname
(
ST
sdb
*
pRepo
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[]);
static
int
tsdbOpenFSFromCurrent
(
STsdb
*
pRepo
);
static
int
tsdbScanAndTryFixFS
(
STsdb
*
pRepo
);
static
int
tsdbScanRootDir
(
STsdb
*
pRepo
);
...
...
@@ -311,7 +311,7 @@ int tsdbOpenFS(STsdb *pRepo) {
ASSERT
(
pfs
!=
NULL
);
tsdbGetTxnFname
(
pRepo
->
pTfs
,
REPO_ID
(
pRepo
)
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
if
(
access
(
current
,
F_OK
)
==
0
)
{
...
...
@@ -375,7 +375,7 @@ int tsdbEndFSTxn(STsdb *pRepo) {
SFSStatus
*
pStatus
;
// Write current file system snapshot
if
(
tsdbSaveFSStatus
(
pRepo
->
pTfs
,
pfs
->
nstatus
,
REPO_ID
(
pRepo
)
)
<
0
)
{
if
(
tsdbSaveFSStatus
(
pRepo
,
pfs
->
nstatus
)
<
0
)
{
tsdbEndFSTxnWithError
(
pfs
);
return
-
1
;
}
...
...
@@ -405,7 +405,7 @@ int tsdbEndFSTxnWithError(STsdbFS *pfs) {
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
)
{
return
tsdbAddDFileSetToStatus
(
pfs
->
nstatus
,
pSet
);
}
static
int
tsdbSaveFSStatus
(
ST
fs
*
pTfs
,
SFSStatus
*
pStatus
,
int
vid
)
{
static
int
tsdbSaveFSStatus
(
ST
sdb
*
pRepo
,
SFSStatus
*
pStatus
)
{
SFSHeader
fsheader
;
void
*
pBuf
=
NULL
;
void
*
ptr
;
...
...
@@ -413,8 +413,8 @@ static int tsdbSaveFSStatus(STfs *pTfs, SFSStatus *pStatus, int vid) {
char
tfname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
char
cfname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
tsdbGetTxnFname
(
p
Tfs
,
vid
,
TSDB_TXN_TEMP_FILE
,
tfname
);
tsdbGetTxnFname
(
p
Tfs
,
vid
,
TSDB_TXN_CURR_FILE
,
cfname
);
tsdbGetTxnFname
(
p
Repo
,
TSDB_TXN_TEMP_FILE
,
tfname
);
tsdbGetTxnFname
(
p
Repo
,
TSDB_TXN_CURR_FILE
,
cfname
);
int
fd
=
open
(
tfname
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_BINARY
,
0755
);
if
(
fd
<
0
)
{
...
...
@@ -645,8 +645,9 @@ static int tsdbComparFidFSet(const void *arg1, const void *arg2) {
}
}
static
void
tsdbGetTxnFname
(
STfs
*
pTfs
,
int
repoid
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[])
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s/vnode/vnode%d/tsdb/%s"
,
tfsGetPrimaryPath
(
pTfs
),
repoid
,
tsdbTxnFname
[
ftype
]);
static
void
tsdbGetTxnFname
(
STsdb
*
pRepo
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[])
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s/vnode/vnode%d/tsdb/%s"
,
tfsGetPrimaryPath
(
pRepo
->
pTfs
),
pRepo
->
vgId
,
tsdbTxnFname
[
ftype
]);
}
static
int
tsdbOpenFSFromCurrent
(
STsdb
*
pRepo
)
{
...
...
@@ -657,7 +658,7 @@ static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
char
current
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
void
*
ptr
;
tsdbGetTxnFname
(
pRepo
->
pTfs
,
REPO_ID
(
pRepo
)
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
// current file exists, try to recover
fd
=
open
(
current
,
O_RDONLY
|
O_BINARY
);
...
...
@@ -1287,7 +1288,7 @@ static int tsdbRestoreCurrent(STsdb *pRepo) {
return
-
1
;
}
if
(
tsdbSaveFSStatus
(
pRepo
->
pTfs
,
pRepo
->
fs
->
cstatus
,
REPO_ID
(
pRepo
)
)
<
0
)
{
if
(
tsdbSaveFSStatus
(
pRepo
,
pRepo
->
fs
->
cstatus
)
<
0
)
{
tsdbError
(
"vgId:%d failed to restore corrent since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbMain.c
浏览文件 @
c3e222bf
...
...
@@ -21,7 +21,8 @@ static void tsdbFree(STsdb *pTsdb);
static
int
tsdbOpenImpl
(
STsdb
*
pTsdb
);
static
void
tsdbCloseImpl
(
STsdb
*
pTsdb
);
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
)
{
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
)
{
STsdb
*
pTsdb
=
NULL
;
// Set default TSDB Options
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
c3e222bf
...
...
@@ -28,6 +28,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
if
(
pVnodeCfg
!=
NULL
)
{
cfg
.
vgId
=
pVnodeCfg
->
vgId
;
cfg
.
pDnode
=
pVnodeCfg
->
pDnode
;
cfg
.
pTfs
=
pVnodeCfg
->
pTfs
;
}
// Validate options
...
...
source/libs/tfs/inc/tfsInt.h
浏览文件 @
c3e222bf
...
...
@@ -58,12 +58,12 @@ typedef struct {
}
SDiskIter
;
typedef
struct
STfsDir
{
SDiskIter
*
iter
;
SDiskID
did
;
char
dirname
[
TSDB_FILENAME_LEN
];
STfsFile
tfile
;
DIR
*
dir
;
STfs
*
pTfs
;
SDiskIter
iter
;
SDiskID
did
;
char
dirname
[
TSDB_FILENAME_LEN
];
STfsFile
tfile
;
DIR
*
dir
;
STfs
*
pTfs
;
}
STfsDir
;
typedef
struct
STfs
{
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
c3e222bf
...
...
@@ -152,7 +152,6 @@ void tfsInitFile(STfs *pTfs, STfsFile *pFile, SDiskID diskId, const char *rname)
}
bool
tfsIsSameFile
(
const
STfsFile
*
pFile1
,
const
STfsFile
*
pFile2
)
{
ASSERT
(
pFile1
!=
NULL
||
pFile2
!=
NULL
);
if
(
pFile1
==
NULL
||
pFile2
==
NULL
||
pFile1
->
pTfs
!=
pFile2
->
pTfs
)
return
false
;
if
(
pFile1
->
did
.
level
!=
pFile2
->
did
.
level
)
return
false
;
if
(
pFile1
->
did
.
id
!=
pFile2
->
did
.
id
)
return
false
;
...
...
@@ -308,7 +307,7 @@ STfsDir *tfsOpendir(STfs *pTfs, const char *rname) {
}
SDiskID
diskId
=
{.
id
=
0
,
.
level
=
0
};
pDir
->
iter
->
pDisk
=
TFS_DISK_AT
(
pTfs
,
diskId
);
pDir
->
iter
.
pDisk
=
TFS_DISK_AT
(
pTfs
,
diskId
);
pDir
->
pTfs
=
pTfs
;
tstrncpy
(
pDir
->
dirname
,
rname
,
TSDB_FILENAME_LEN
);
...
...
@@ -331,7 +330,7 @@ const STfsFile *tfsReaddir(STfsDir *pDir) {
// Skip . and ..
if
(
strcmp
(
dp
->
d_name
,
"."
)
==
0
||
strcmp
(
dp
->
d_name
,
".."
)
==
0
)
continue
;
snprintf
(
bname
,
TMPNAME_LEN
*
2
,
"%s
/%s"
,
pDir
->
dirname
,
dp
->
d_name
);
snprintf
(
bname
,
TMPNAME_LEN
*
2
,
"%s
%s%s"
,
pDir
->
dirname
,
TD_DIRSEP
,
dp
->
d_name
);
tfsInitFile
(
pDir
->
pTfs
,
&
pDir
->
tfile
,
pDir
->
did
,
bname
);
return
&
pDir
->
tfile
;
}
...
...
@@ -496,7 +495,7 @@ static int32_t tfsOpendirImpl(STfs *pTfs, STfsDir *pDir) {
}
while
(
true
)
{
pDisk
=
tfsNextDisk
(
pTfs
,
pDir
->
iter
);
pDisk
=
tfsNextDisk
(
pTfs
,
&
pDir
->
iter
);
if
(
pDisk
==
NULL
)
return
0
;
pDir
->
did
.
level
=
pDisk
->
level
;
...
...
@@ -514,7 +513,9 @@ static STfsDisk *tfsNextDisk(STfs *pTfs, SDiskIter *pIter) {
if
(
pIter
==
NULL
)
return
NULL
;
STfsDisk
*
pDisk
=
pIter
->
pDisk
;
SDiskID
did
=
{.
level
=
pDisk
->
level
,
.
id
=
pDisk
->
id
+
1
};
if
(
pDisk
==
NULL
)
return
NULL
;
SDiskID
did
=
{.
level
=
pDisk
->
level
,
.
id
=
pDisk
->
id
+
1
};
if
(
did
.
id
<
TFS_TIER_AT
(
pTfs
,
did
.
level
)
->
ndisk
)
{
pIter
->
pDisk
=
TFS_DISK_AT
(
pTfs
,
did
);
...
...
source/libs/tfs/src/tfsDisk.c
浏览文件 @
c3e222bf
...
...
@@ -46,7 +46,7 @@ STfsDisk *tfsFreeDisk(STfsDisk *pDisk) {
}
int32_t
tfsUpdateDiskSize
(
STfsDisk
*
pDisk
)
{
if
(
taosGetDiskSize
(
pDisk
->
path
,
&
pDisk
->
size
)
!=
0
)
{
if
(
taosGetDiskSize
(
pDisk
->
path
,
&
pDisk
->
size
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
fError
(
"failed to get disk:%s size, level:%d id:%d since %s"
,
pDisk
->
path
,
pDisk
->
level
,
pDisk
->
id
,
terrstr
());
return
-
1
;
...
...
source/libs/tfs/src/tfsTier.c
浏览文件 @
c3e222bf
...
...
@@ -82,6 +82,7 @@ void tfsUpdateTierSize(STfsTier *pTier) {
for
(
int32_t
id
=
0
;
id
<
pTier
->
ndisk
;
id
++
)
{
STfsDisk
*
pDisk
=
pTier
->
disks
[
id
];
if
(
pDisk
==
NULL
)
continue
;
if
(
tfsUpdateDiskSize
(
pDisk
)
<
0
)
continue
;
size
.
total
+=
pDisk
->
size
.
total
;
size
.
used
+=
pDisk
->
size
.
used
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录