support disk usage
This commit is contained in:
parent
12beff2a0a
commit
8c56a75f4f
|
@ -1759,6 +1759,7 @@ typedef struct {
|
|||
int64_t walSize;
|
||||
int64_t metaSize;
|
||||
int64_t rawDataSize;
|
||||
int64_t s3Size;
|
||||
} SDbSizeStatisInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -1073,6 +1073,8 @@ int32_t tsdbSnapPrepDescription(SVnode *pVnode, SSnapshot *pSnap);
|
|||
|
||||
void tsdbRemoveFile(const char *path);
|
||||
|
||||
int32_t tsdbGetS3Size(STsdb *tsdb, int64_t *size);
|
||||
k
|
||||
#define taosCloseFileWithLog(fd) \
|
||||
do { \
|
||||
if (taosCloseFile(fd) < 0) { \
|
||||
|
|
|
@ -733,3 +733,28 @@ int32_t tsdbAsyncS3Migrate(STsdb *tsdb, int64_t now) {
|
|||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t tsdbGetS3SizeImpl(STsdb *tsdb, int64_t *size) {
|
||||
int32_t code = 0;
|
||||
|
||||
SVnodeCfg *pCfg = &tsdb->pVnode->config;
|
||||
int64_t chunksize = (int64_t)pCfg->tsdbPageSize * pCfg->s3ChunkSize;
|
||||
|
||||
STFileSet *fset;
|
||||
TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) {
|
||||
STFileObj *fobj = fset->farr[TSDB_FTYPE_DATA];
|
||||
int32_t lcn = fobj->f->lcn;
|
||||
if (lcn > 1) {
|
||||
*size += ((lcn - 1) * chunksize);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
int32_t tsdbGetS3Size(STsdb *tsdb, int64_t *size) {
|
||||
int32_t code = 0;
|
||||
(void)taosThreadMutexLock(&tsdb->mutex);
|
||||
code = tsdbGetS3SizeImpl(tsdb, size);
|
||||
(void)taosThreadMutexUnlock(&tsdb->mutex);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -900,7 +900,9 @@ int32_t vnodeGetDBSize(void *pVnode, SDbSizeStatisInfo *pInfo) {
|
|||
pInfo->metaSize = dirSize[2];
|
||||
pInfo->cacheSize = dirSize[3];
|
||||
|
||||
return 0;
|
||||
code = tsdbGetS3Size(pVnodeObj->pTsdb, &pInfo->s3Size);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetStreamProgress(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
|
|
Loading…
Reference in New Issue