diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e4e4e6cc8b..6f703afaec 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1759,6 +1759,7 @@ typedef struct { int64_t walSize; int64_t metaSize; int64_t rawDataSize; + int64_t s3Size; } SDbSizeStatisInfo; typedef struct { diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index c1123db7a3..b2f89aa6b4 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -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) { \ diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 0072fd5e7f..d3fc1d7e59 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -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; +} diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index e7c35c4ed9..6ca5803c19 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -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) {