diff --git a/src/inc/tfs.h b/src/inc/tfs.h index 8c57c09b83e3019f4d7fffa095faaaf2daae4241..e0a86fa062a92d456a4b3dcbf4ef8cdf04c4c0ce 100644 --- a/src/inc/tfs.h +++ b/src/inc/tfs.h @@ -50,7 +50,7 @@ const char *tfsRelName(TFSFILE *pfile); void tfsDirName(TFSFILE *pfile, char dest[]); void tfsBaseName(TFSFILE *pfile, char dest[]); -int tfsopen(TFSFILE *pfile); +int tfsopen(TFSFILE *pfile, int flags); int tfsclose(int fd); TFSFILE *tfsCreateFiles(int level, int nfile, ...); diff --git a/src/tfs/inc/tfsint.h b/src/tfs/inc/tfsint.h index 25b5467fef0b8a9456debc0f97cd5460d92b28da..1a92868a5d7a455035896c22a4385ba6146cf6fa 100644 --- a/src/tfs/inc/tfsint.h +++ b/src/tfs/inc/tfsint.h @@ -16,10 +16,15 @@ #ifndef TD_TFSINT_H #define TD_TFSINT_H +#include "tlog.h" +#include "tglobal.h" + #ifdef __cplusplus extern "C" { #endif +extern int fsDebugFlag; + // For debug purpose #define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("TFS FATAL ", 255, __VA_ARGS__); }} #define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("TFS ERROR ", 255, __VA_ARGS__); }} diff --git a/src/tfs/src/tdisk.c b/src/tfs/src/tdisk.c index 5a611d45d98cbaf0fd4d72a5b009f48a102d8adc..b73f33caabae495dbcd7d9f8b9920f261a0b48fa 100644 --- a/src/tfs/src/tdisk.c +++ b/src/tfs/src/tdisk.c @@ -47,7 +47,7 @@ SDisk *tfsNewDisk(int level, int id, char *dir) { void tfsFreeDisk(SDisk *pDisk) { if (pDisk) { - free(pDisk) + free(pDisk); } } diff --git a/src/tfs/src/tfcntl.c b/src/tfs/src/tfcntl.c index ee85ed4dc87bac6094cc72e8a2126feacc04652e..3b3da8e2751833f442f3fab8cb8470fc03197ba0 100644 --- a/src/tfs/src/tfcntl.c +++ b/src/tfs/src/tfcntl.c @@ -15,8 +15,8 @@ #include "os.h" #include "taoserror.h" -#include "tdisk.h" #include "tfs.h" +#include "tfsint.h" struct TFSFILE { int level; @@ -33,6 +33,10 @@ struct TFSDIR { DIR * dir; }; +static int tfsOpenDirImpl(TFSDIR *tdir); +static void tfsInitFile(TFSFILE *pfile, int level, int id, char *rname); +static TFSFILE *tfsNewFile(int level, int id, char *rname); + // PUBLIC ========================================== TFSDIR *tfsOpenDir(char *dir) { TFSDIR *tdir = (TFSDIR *)calloc(1, sizeof(*tdir)); @@ -123,7 +127,7 @@ int tfsclose(int fd) { return -1; } - return 0 + return 0; } TFSFILE *tfsCreateFiles(int level, int nfile, ...) { diff --git a/src/tfs/src/tfs.c b/src/tfs/src/tfs.c index 41335646f41df40404c96cf8c032e0e45ffebcd9..f3abb26241ec3436e9d5cdcfd4ed17e74855c9ac 100644 --- a/src/tfs/src/tfs.c +++ b/src/tfs/src/tfs.c @@ -41,6 +41,12 @@ static SFS *pfs = &tdFileSystem; #define TIER_AT(level) (pfs->tiers + (level)) #define DISK_AT(level, id) DISK_AT_TIER(TIER_AT(level), id) +static int tfsMount(SDiskCfg *pCfg); +static int tfsCheckAndFormatCfg(SDiskCfg *pCfg); +static int tfsFormatDir(char *idir, char *odir); +static int tfsCheck(); +static tfsGetDiskByName(char *dirName); + // public: int tfsInit(SDiskCfg *pDiskCfg, int ndisk) { ASSERT(ndisk > 0); @@ -84,7 +90,7 @@ void tfsDestroy() { pthread_mutex_destroy(&(pfs->lock)); for (int level = 0; level < TSDB_MAX_TIER; level++) { - tdDestroyTier(TIER_AT(level)); + tfsDestroyTier(TIER_AT(level)); } } @@ -92,7 +98,7 @@ int tfsUpdateInfo() { tfsLock(); for (int level = 0; level < pfs->nlevel; level++) { - if (tdUpdateTierInfo(TIER_AT(level)) < 0) { + if (tfsUpdateTierInfo(TIER_AT(level)) < 0) { // TODO: deal with the error here } } diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index bc6b3a2517a2e69702f8789a730b72e632989e95..7a2ad7760a800a15853fafe46c87d6fb31598b0f 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -196,7 +196,7 @@ typedef struct { typedef struct { int fileId; - int state; // 0 for health, 1 for problem + int state; // 0 for health, 1 for problem SFile files[TSDB_FILE_TYPE_MAX]; } SFileGroup; @@ -518,7 +518,7 @@ void tsdbSeekFileGroupIter(SFileGroupIter* pIter, int fid); SFileGroup* tsdbGetFileGroupNext(SFileGroupIter* pIter); int tsdbOpenFile(SFile* pFile, int oflag); void tsdbCloseFile(SFile* pFile); -int tsdbCreateFile(SFile* pFile, STsdbRepo* pRepo, int fid, int type, SDisk* pDisk); +int tsdbCreateFile(SFile* pFile, STsdbRepo* pRepo, int fid, int type); SFileGroup* tsdbSearchFGroup(STsdbFileH* pFileH, int fid, int flags); void tsdbRemoveFilesBeyondRetention(STsdbRepo* pRepo, SFidGroup* pFidGroup); int tsdbUpdateFileHeader(SFile* pFile); diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index 922d0d93ed6706b5e5ea70d816e8566bd5c7e5bb..ba50a5526ddaa4fb8efd67888c5ef5ed038935a9 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -262,7 +262,7 @@ void tsdbCloseFile(SFile *pFile) { } } -int tsdbCreateFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type, SDisk *pDisk) { +int tsdbCreateFile(SFile *pFile, STsdbRepo *pRepo, int fid, int type) { memset((void *)pFile, 0, sizeof(SFile)); pFile->fd = -1;