提交 68349429 编写于 作者: H Hongze Cheng

refactor

上级 dde48699
......@@ -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, ...);
......
......@@ -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__); }}
......
......@@ -47,7 +47,7 @@ SDisk *tfsNewDisk(int level, int id, char *dir) {
void tfsFreeDisk(SDisk *pDisk) {
if (pDisk) {
free(pDisk)
free(pDisk);
}
}
......
......@@ -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, ...) {
......
......@@ -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
}
}
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册