From 072d42e0fa518cdce3c65361f439ec6937ef2e65 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 23 Nov 2020 05:21:55 +0000 Subject: [PATCH] refactor --- src/inc/tfs.h | 33 +++++++++++++++------------------ src/tfs/inc/tfsint.h | 8 +++++++- src/tfs/src/ttier.c | 7 ------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/inc/tfs.h b/src/inc/tfs.h index e0a86fa062..cf9988653d 100644 --- a/src/inc/tfs.h +++ b/src/inc/tfs.h @@ -27,38 +27,35 @@ typedef struct { int id; } SDiskID; -// tfs.c +// tfs.c ==================================== int tfsInit(SDiskCfg *pDiskCfg, int ndisk); void tfsDestroy(); int tfsUpdateInfo(); -int tfsCreateDir(char *dirname); -int tfsRemoveDir(char *dirname); -int tfsRename(char *oldpath, char *newpath); +const char *tfsGetDiskName(int level, int id); const char *tfsPrimaryPath(); -// tfcntl.c +// tfcntl.c ==================================== typedef struct TFSFILE TFSFILE; -typedef struct TFSDIR TFSDIR; - -TFSDIR * tfsOpenDir(char *dir); -void tfsCloseDir(TFSDIR *tdir); -const TFSFILE *tfsReadDir(TFSDIR *tdir); const char *tfsAbsName(TFSFILE *pfile); const char *tfsRelName(TFSFILE *pfile); void tfsDirName(TFSFILE *pfile, char dest[]); void tfsBaseName(TFSFILE *pfile, char dest[]); +int tfsopen(TFSFILE *pfile, int flags); +int tfsclose(int fd); +TFSFILE * tfsCreateFiles(int level, int nfile, ...); +int tfsRemoveFiles(int nfile, ...); +SDiskID tfsFileID(TFSFILE *pfile); -int tfsopen(TFSFILE *pfile, int flags); -int tfsclose(int fd); - -TFSFILE *tfsCreateFiles(int level, int nfile, ...); -int tfsRemoveFiles(int nfile, ...); +typedef struct TFSDIR TFSDIR; -SDiskID tfsFileID(TFSFILE *pfile); - -const char *tfsGetDiskName(int level, int id); +int tfsCreateDir(char *dirname); +int tfsRemoveDir(char *dirname); +int tfsRename(char *oldpath, char *newpath); +TFSDIR * tfsOpenDir(char *dir); +void tfsCloseDir(TFSDIR *tdir); +const TFSFILE *tfsReadDir(TFSDIR *tdir); #ifdef __cplusplus } diff --git a/src/tfs/inc/tfsint.h b/src/tfs/inc/tfsint.h index 1a92868a5d..0ee1a92641 100644 --- a/src/tfs/inc/tfsint.h +++ b/src/tfs/inc/tfsint.h @@ -43,7 +43,13 @@ int tfsUpdateDiskInfo(SDisk *pDisk); const char *tfsDiskDir(SDisk *pDisk); // ttier.c -typedef struct STier STier; +#define TSDB_MAX_DISK_PER_TIER 16 + +typedef struct STier { + int level; + int ndisk; + SDisk *disks[TSDB_MAX_DISK_PER_TIER]; +} STier; #define DISK_AT_TIER(pTier, id) ((pTier)->disks[id]) diff --git a/src/tfs/src/ttier.c b/src/tfs/src/ttier.c index d7f45d0331..fbad4c9f3c 100644 --- a/src/tfs/src/ttier.c +++ b/src/tfs/src/ttier.c @@ -17,13 +17,6 @@ #include "tfsint.h" #include "taoserror.h" -#define TSDB_MAX_DISK_PER_TIER 16 -struct STier { - int level; - int ndisk; - SDisk *disks[TSDB_MAX_DISK_PER_TIER]; -}; - // PROTECTED ========================================== void tfsInitTier(STier *pTier, int level) { pTier->level = level; -- GitLab