more code
This commit is contained in:
parent
fcbff54e59
commit
dfc91a38b0
|
@ -35,7 +35,11 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
*ppMeta = NULL;
|
*ppMeta = NULL;
|
||||||
|
|
||||||
// create handle
|
// create handle
|
||||||
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
if (pVnode->pTfs) {
|
||||||
|
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
||||||
|
} else {
|
||||||
|
slen = strlen(pVnode->path) + strlen(VNODE_META_DIR) + 2;
|
||||||
|
}
|
||||||
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
|
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -43,8 +47,12 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
|
|
||||||
metaInitLock(pMeta);
|
metaInitLock(pMeta);
|
||||||
pMeta->path = (char *)&pMeta[1];
|
pMeta->path = (char *)&pMeta[1];
|
||||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
if (pVnode->pTfs) {
|
||||||
VNODE_META_DIR);
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
|
VNODE_META_DIR);
|
||||||
|
} else {
|
||||||
|
sprintf(pMeta->path, "%s%s%s", pVnode->path, TD_DIRSEP, VNODE_META_DIR);
|
||||||
|
}
|
||||||
taosRealPath(pMeta->path, NULL, slen);
|
taosRealPath(pMeta->path, NULL, slen);
|
||||||
pMeta->pVnode = pVnode;
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,7 @@ _err:
|
||||||
// EXPOSED APIS ====================================================================================
|
// EXPOSED APIS ====================================================================================
|
||||||
int32_t tsdbFSOpen(STsdb *pTsdb) {
|
int32_t tsdbFSOpen(STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
SVnode *pVnode = pTsdb->pVnode;
|
||||||
|
|
||||||
// open handle
|
// open handle
|
||||||
pTsdb->fs.pDelFile = NULL;
|
pTsdb->fs.pDelFile = NULL;
|
||||||
|
@ -429,8 +430,12 @@ int32_t tsdbFSOpen(STsdb *pTsdb) {
|
||||||
// load fs or keep empty
|
// load fs or keep empty
|
||||||
char fname[TSDB_FILENAME_LEN];
|
char fname[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP,
|
if (pVnode->pTfs) {
|
||||||
pTsdb->path, TD_DIRSEP);
|
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP,
|
||||||
|
pTsdb->path, TD_DIRSEP);
|
||||||
|
} else {
|
||||||
|
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%sCURRENT", pTsdb->path, TD_DIRSEP);
|
||||||
|
}
|
||||||
|
|
||||||
if (!taosCheckExistFile(fname)) {
|
if (!taosCheckExistFile(fname)) {
|
||||||
// empty one
|
// empty one
|
||||||
|
|
|
@ -57,10 +57,13 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
||||||
} else {
|
} else {
|
||||||
memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg));
|
memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg));
|
||||||
}
|
}
|
||||||
// pTsdb->fs = tsdbNewFS(REPO_KEEP_CFG(pTsdb));
|
|
||||||
|
|
||||||
// create dir
|
// create dir
|
||||||
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
if (pVnode->pTfs) {
|
||||||
|
tfsMkdir(pVnode->pTfs, pTsdb->path);
|
||||||
|
} else {
|
||||||
|
taosMkDir(pTsdb->path);
|
||||||
|
}
|
||||||
|
|
||||||
// open tsdb
|
// open tsdb
|
||||||
if (tsdbFSOpen(pTsdb) < 0) {
|
if (tsdbFSOpen(pTsdb) < 0) {
|
||||||
|
|
Loading…
Reference in New Issue