提交 3e31cdbe 编写于 作者: H Hongze Cheng

refact

上级 a76580bc
......@@ -51,6 +51,7 @@ typedef struct {
#define FS_CURRENT_STATUS(pfs) ((pfs)->cstatus)
#define FS_NEW_STATUS(pfs) ((pfs)->nstatus)
#define FS_IN_TXN(pfs) (pfs)->intxn
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
typedef struct {
......
......@@ -159,27 +159,24 @@ static void tsdbResetFSStatus(SFSStatus *pStatus) {
}
static void tsdbSetStatusMFile(SFSStatus *pStatus, const SMFile *pMFile) {
ASSERT(pStatus->pmf == NULL && TSDB_FILE_CLOSED(pMFile));
ASSERT(pStatus->pmf == NULL);
pStatus->pmf = &(pStatus->mf);
*(pStatus->pmf) = *pMFile;
tsdbInitMFileEx(pStatus->pmf, pMFile);
}
static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
ASSERT(TSDB_FILE_CLOSED(&(pSet->files[0])));
ASSERT(TSDB_FILE_CLOSED(&(pSet->files[1])));
ASSERT(TSDB_FILE_CLOSED(&(pSet->files[2])));
if (taosArrayPush(pStatus->df, (void *)pSet) == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1;
}
TSDB_FSET_SET_CLOSED(((SDFileSet *)taosArrayGetLast(pStatus->df)));
return 0;
}
// ================== STsdbFS
// TODO
STsdbFS *tsdbNewFS(STsdbCfg *pCfg) {
int keep = pCfg->keep;
int days = pCfg->daysPerFile;
......@@ -221,7 +218,6 @@ STsdbFS *tsdbNewFS(STsdbCfg *pCfg) {
return pfs;
}
// TODO
void *tsdbFreeFS(STsdbFS *pfs) {
if (pfs) {
pfs->nstatus = tsdbFreeFSStatus(pfs->nstatus);
......@@ -235,7 +231,7 @@ void *tsdbFreeFS(STsdbFS *pfs) {
}
int tsdbOpenFS(STsdbRepo *pRepo) {
STsdbFS * pfs = REPO_FS(pRepo);
STsdbFS *pfs = REPO_FS(pRepo);
char current[TSDB_FILENAME_LEN] = "\0";
ASSERT(pfs != NULL);
......@@ -254,6 +250,11 @@ int tsdbOpenFS(STsdbRepo *pRepo) {
}
}
if (tsdbScanAndTryFixFS(pRepo) < 0) {
tsdbError("vgId:%d failed to scan and fix FS since %s", REPO_ID(pRepo), tstrerror(terrno));
return -1;
}
// Load meta cache if has meta file
if ((!(pRepo->state & TSDB_STATE_BAD_META)) && tsdbLoadMetaCache(pRepo, true) < 0) {
tsdbError("vgId:%d failed to open FS while loading meta cache since %s", REPO_ID(pRepo), tstrerror(terrno));
......@@ -264,7 +265,7 @@ int tsdbOpenFS(STsdbRepo *pRepo) {
}
void tsdbCloseFS(STsdbRepo *pRepo) {
// TODO
// Do nothing
}
// Start a new transaction to modify the file system
......@@ -651,10 +652,6 @@ static int tsdbOpenFSFromCurrent(STsdbRepo *pRepo) {
taosTZfree(buffer);
close(fd);
if (tsdbScanAndTryFixFS(pRepo) < 0) {
return -1;
}
return 0;
_err:
......@@ -965,6 +962,7 @@ static int tsdbRestoreMeta(STsdbRepo *pRepo) {
if (tsdbLoadMFileHeader(pfs->cstatus->pmf, &(pfs->cstatus->pmf->info)) < 0) {
tsdbError("vgId:%d failed to restore meta since %s", REPO_ID(pRepo), tstrerror(terrno));
tsdbCloseMFile(pfs->cstatus->pmf);
tfsClosedir(tdir);
regfree(&regex);
return -1;
......
......@@ -581,6 +581,7 @@ void *tsdbDecodeDFileSet(void *buf, SDFileSet *pSet) {
int32_t fid;
buf = taosDecodeFixedI32(buf, &(fid));
pSet->state = 0;
pSet->fid = fid;
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
buf = tsdbDecodeSDFile(buf, TSDB_DFILE_IN_SET(pSet, ftype));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册