diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 05c9d2be28adacb5439392ae9266929d32a2214a..5907adc199dd1f3b5e6064d8b4a7c9240ad2e4d9 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -186,11 +186,11 @@ static int32_t dnodeInitStorage() { dError("failed to init TFS since %s", tstrerror(terrno)); return -1; } - snprintf(tsDataDir, TFS_PRIMARY_PATH(), TSDB_FILENAME_LEN); + strncpy(tsDataDir, TFS_PRIMARY_PATH(), TSDB_FILENAME_LEN); sprintf(tsMnodeDir, "%s/mnode", tsDataDir); sprintf(tsVnodeDir, "%s/vnode", tsDataDir); sprintf(tsDnodeDir, "%s/dnode", tsDataDir); - sprintf(tsVnodeBakDir, "%s/vnode_bak", tsDataDir); + // sprintf(tsVnodeBakDir, "%s/vnode_bak", tsDataDir); //TODO(dengyihao): no need to init here if (dnodeCreateDir(tsMnodeDir) < 0) { diff --git a/src/inc/tfs.h b/src/inc/tfs.h index 4c91c6fc652fa2a5b7473b4ad54f37cabab88e64..d7ed51b560950af631d27b5b572c4eae47c3b0c7 100644 --- a/src/inc/tfs.h +++ b/src/inc/tfs.h @@ -33,12 +33,13 @@ typedef struct { #define TFS_PRIMARY_ID 0 // FS APIs ==================================== -int tfsInit(SDiskCfg *pDiskCfg, int ndisk); -void tfsDestroy(); -void tfsUpdateInfo(); -void tfsIncDiskFile(int level, int id, int num); -void tfsDecDiskFile(int level, int id, int num); - +int tfsInit(SDiskCfg *pDiskCfg, int ndisk); +void tfsDestroy(); +void tfsUpdateInfo(); +int64_t tfsTotalSize(); +int64_t tfsAvailSize(); +void tfsIncDiskFile(int level, int id, int num); +void tfsDecDiskFile(int level, int id, int num); const char *TFS_PRIMARY_PATH(); const char *TFS_DISK_PATH(int level, int id); diff --git a/src/tfs/src/tfs.c b/src/tfs/src/tfs.c index e53a7329a42581d32ccd8f9d16842c9fd51923cb..d05d441d02eda73c0402f616b9c95440d9aca170 100644 --- a/src/tfs/src/tfs.c +++ b/src/tfs/src/tfs.c @@ -139,6 +139,10 @@ void tfsUpdateInfo() { tfsUnLock(); } +int64_t tfsTotalSize() { return pfs->meta.tsize; } + +int64_t tfsAvailSize() { return pfs->meta.avail; } + void tfsIncDiskFile(int level, int id, int num) { tfsLock(); TFS_DISK_AT(level, id)->dmeta.nfiles += num; @@ -572,4 +576,26 @@ static int tfsAssignDisk(int level) { return id; } +// OTHER FUNCTIONS =================================== +void taosGetDisk() { + const double unit = 1024 * 1024 * 1024; + SysDiskSize diskSize; + + if (tscEmbedded) { + tfsUpdateInfo(); + tsTotalDataDirGB = (float)tfsTotalSize() / unit; + tsAvailDataDirGB = (float)tfsAvailSize() / unit; + } + + if (taosGetDiskSize(tsLogDir, &diskSize)) { + tsTotalLogDirGB = (float)diskSize.tsize / unit; + tsAvailLogDirGB = (float)diskSize.avail / unit; + } + + if (taosGetDiskSize("/tmp", &diskSize)) { + tsTotalTmpDirGB = (float)diskSize.tsize / unit; + tsAvailTmpDirectorySpace = (float)diskSize.avail / unit; + } +} + #pragma GCC diagnostic pop \ No newline at end of file diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 0f51e2ed3b9e22823560c3b117f802189706ecf0..201fed13f838e8fdf04f11a5edf8363630557842 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -113,7 +113,7 @@ int32_t vnodeCreate(SCreateVnodeMsg *pVnodeCfg) { char vnodeDir[TSDB_FILENAME_LEN] = "\0"; snprintf(vnodeDir, TSDB_FILENAME_LEN, "vnode%d", pVnodeCfg->cfg.vgId); if (tfsMkdir(vnodeDir) < 0) { - vError("vgId:%d, failed to create vnode %d dir, reason:%s", pVnodeCfg->cfg.vgId, strerror(errno)); + vError("vgId:%d, failed to create vnode dir %s, reason:%s", pVnodeCfg->cfg.vgId, vnodeDir, strerror(errno)); return terrno; }