fix: prepare vnode dir recursively in vnodeCreate
This commit is contained in:
parent
6b6b7d8d8f
commit
5624ecc8df
|
@ -130,6 +130,15 @@ int32_t tfsMkdir(STfs *pTfs, const char *rname);
|
|||
*/
|
||||
int32_t tfsMkdirAt(STfs *pTfs, const char *rname, SDiskID diskId);
|
||||
|
||||
/**
|
||||
* @brief Recursive make directory at all levels in tfs.
|
||||
*
|
||||
* @param pTfs The fs object.
|
||||
* @param rname The rel name of directory.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t tfsMkdirRecur(STfs *pTfs, const char *rname);
|
||||
|
||||
/**
|
||||
* @brief Recursive create directories in tfs.
|
||||
*
|
||||
|
|
|
@ -27,6 +27,14 @@ int32_t vnodeGetPrimaryDir(const char *relPath, int32_t diskPrimary, STfs *pTfs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeMkDir(STfs *pTfs, const char *path) {
|
||||
if (pTfs) {
|
||||
return tfsMkdirRecur(pTfs, path);
|
||||
} else {
|
||||
return taosMkDir(path);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs *pTfs) {
|
||||
SVnodeInfo info = {0};
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
|
@ -38,8 +46,8 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
|
|||
}
|
||||
|
||||
// create vnode env
|
||||
if ((pTfs) ? tfsMkdir(pTfs, path) : taosMkDir(path)) {
|
||||
vError("vgId:%d, failed to mkdir since %s, dir: %s", pCfg->vgId, strerror(errno), path);
|
||||
if (vnodeMkDir(pTfs, path)) {
|
||||
vError("vgId:%d, failed to prepare vnode dir since %s, path: %s", pCfg->vgId, strerror(errno), path);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
|
|
@ -281,7 +281,7 @@ int32_t tfsMkdirRecurAt(STfs *pTfs, const char *rname, SDiskID diskId) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tfsMkdir(STfs *pTfs, const char *rname) {
|
||||
int32_t tfsMkdirRecur(STfs *pTfs, const char *rname) {
|
||||
for (int32_t level = 0; level < pTfs->nlevel; level++) {
|
||||
STfsTier *pTier = TFS_TIER_AT(pTfs, level);
|
||||
for (int32_t id = 0; id < pTier->ndisk; id++) {
|
||||
|
@ -295,6 +295,20 @@ int32_t tfsMkdir(STfs *pTfs, const char *rname) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tfsMkdir(STfs *pTfs, const char *rname) {
|
||||
for (int32_t level = 0; level < pTfs->nlevel; level++) {
|
||||
STfsTier *pTier = TFS_TIER_AT(pTfs, level);
|
||||
for (int32_t id = 0; id < pTier->ndisk; id++) {
|
||||
SDiskID did = {.id = id, .level = level};
|
||||
if (tfsMkdirAt(pTfs, rname, did) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tfsDirExistAt(STfs *pTfs, const char *rname, SDiskID diskId) {
|
||||
STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId);
|
||||
char aname[TMPNAME_LEN];
|
||||
|
|
Loading…
Reference in New Issue