Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
24fed511
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
24fed511
编写于
7月 18, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: tfsRename dir on primary disk at last
上级
5624ecc8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
32 addition
and
14 deletion
+32
-14
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+1
-1
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+2
-2
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+26
-8
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+3
-3
未找到文件。
include/libs/tfs/tfs.h
浏览文件 @
24fed511
...
...
@@ -176,7 +176,7 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname);
* @param nrname The rel name of new file.
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
tfsRename
(
STfs
*
pTfs
,
const
char
*
orname
,
const
char
*
nrname
);
int32_t
tfsRename
(
STfs
*
pTfs
,
int32_t
diskPrimary
,
const
char
*
orname
,
const
char
*
nrname
);
/**
* @brief Search fname in level of tfs
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
24fed511
...
...
@@ -176,7 +176,7 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
snprintf
(
newRname
,
TSDB_FILENAME_LEN
,
"%s%d%s"
,
oldRname
,
dstVgId
,
tsdbFileSurfixPos
);
vInfo
(
"vgId:%d, rename file from %s to %s"
,
dstVgId
,
tsdbFile
->
rname
,
newRname
);
ret
=
tfsRename
(
pTfs
,
tsdbFile
->
rname
,
newRname
);
ret
=
tfsRename
(
pTfs
,
diskPrimary
,
tsdbFile
->
rname
,
newRname
);
if
(
ret
!=
0
)
{
vError
(
"vgId:%d, failed to rename file from %s to %s since %s"
,
dstVgId
,
tsdbFile
->
rname
,
newRname
,
terrstr
());
tfsClosedir
(
tsdbDir
);
...
...
@@ -188,7 +188,7 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
tfsClosedir
(
tsdbDir
);
vInfo
(
"vgId:%d, rename dir from %s to %s"
,
dstVgId
,
srcPath
,
dstPath
);
ret
=
tfsRename
(
pTfs
,
srcPath
,
dstPath
);
ret
=
tfsRename
(
pTfs
,
diskPrimary
,
srcPath
,
dstPath
);
if
(
ret
!=
0
)
{
vError
(
"vgId:%d, failed to rename dir from %s to %s since %s"
,
dstVgId
,
srcPath
,
dstPath
,
terrstr
());
}
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
24fed511
...
...
@@ -337,25 +337,43 @@ int32_t tfsRmdir(STfs *pTfs, const char *rname) {
return
0
;
}
int32_t
tfsRename
(
STfs
*
pTfs
,
const
char
*
orname
,
const
char
*
nrname
)
{
static
int32_t
tfsRenameAt
(
STfs
*
pTfs
,
SDiskID
diskId
,
const
char
*
orname
,
const
char
*
nrname
)
{
char
oaname
[
TMPNAME_LEN
]
=
"
\0
"
;
char
naname
[
TMPNAME_LEN
]
=
"
\0
"
;
for
(
int32_t
level
=
pTfs
->
nlevel
-
1
;
level
>=
0
;
level
--
)
{
int32_t
level
=
diskId
.
level
;
int32_t
id
=
diskId
.
id
;
STfsTier
*
pTier
=
TFS_TIER_AT
(
pTfs
,
level
);
for
(
int32_t
id
=
pTier
->
ndisk
-
1
;
id
>=
0
;
id
--
)
{
STfsDisk
*
pDisk
=
pTier
->
disks
[
id
];
snprintf
(
oaname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
orname
);
snprintf
(
naname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
nrname
);
if
(
taosRenameFile
(
oaname
,
naname
)
!=
0
&&
errno
!=
ENOENT
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
fError
(
"failed to rename %s to %s since %s"
,
oaname
,
naname
,
terrstr
());
return
-
1
;
}
return
0
;
}
int32_t
tfsRename
(
STfs
*
pTfs
,
int32_t
diskPrimary
,
const
char
*
orname
,
const
char
*
nrname
)
{
for
(
int32_t
level
=
pTfs
->
nlevel
-
1
;
level
>=
0
;
level
--
)
{
STfsTier
*
pTier
=
TFS_TIER_AT
(
pTfs
,
level
);
for
(
int32_t
id
=
pTier
->
ndisk
-
1
;
id
>=
0
;
id
--
)
{
if
(
level
==
0
&&
id
==
diskPrimary
)
{
continue
;
}
SDiskID
diskId
=
{.
level
=
level
,
.
id
=
id
};
if
(
tfsRenameAt
(
pTfs
,
diskId
,
orname
,
nrname
))
{
return
-
1
;
}
}
}
return
0
;
SDiskID
diskId
=
{.
level
=
0
,
.
id
=
diskPrimary
};
return
tfsRenameAt
(
pTfs
,
diskId
,
orname
,
nrname
);
}
int32_t
tfsSearch
(
STfs
*
pTfs
,
int32_t
level
,
const
char
*
fname
)
{
...
...
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
24fed511
...
...
@@ -156,7 +156,7 @@ TEST_F(TfsTest, 03_Dir) {
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap4
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
0
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
ap4
),
1
);
...
...
@@ -609,7 +609,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
1
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
0
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录