From 708fa269b590abc78c8f348c62daf047bf39619d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sat, 8 Feb 2025 11:10:17 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/inc/tsdb.h | 3 +++ source/dnode/vnode/src/tsdb/tsdbDataFileRAW.h | 5 ++--- source/dnode/vnode/src/tsdb/tsdbDataFileRW.c | 2 -- source/dnode/vnode/src/tsdb/tsdbFSetRAW.c | 7 +++++-- source/dnode/vnode/src/tsdb/tsdbFSetRAW.h | 5 ++--- source/dnode/vnode/src/tsdb/tsdbRetention.c | 2 -- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 10 ---------- source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c | 10 ---------- source/dnode/vnode/src/tsdb/tsdbSttFileRW.c | 2 -- 9 files changed, 12 insertions(+), 34 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 47890e9b4b..7ecec41667 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -1083,6 +1083,9 @@ void tsdbRemoveFile(const char *path); } \ } while (0) +int32_t tsdbAllocateDisk(STsdb *tsdb, int32_t fid, const char *label, SDiskID *diskId); +int32_t tsdbAllocateDiskAtLevel(STsdb *tsdb, int32_t fid, int32_t level, const char *label, SDiskID *diskId); + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.h b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.h index c493c66460..5db09950df 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.h +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.h @@ -79,7 +79,6 @@ typedef struct SDataFileRAWWriterConfig { STsdb *tsdb; int32_t szPage; - SDiskID did; int64_t fid; int64_t cid; int32_t level; @@ -105,8 +104,8 @@ int32_t tsdbDataFileRAWWriterOpen(const SDataFileRAWWriterConfig *config, SDataF int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFileOpArray *opArr); int32_t tsdbDataFileRAWWriterDoOpen(SDataFileRAWWriter *writer); -int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr, - int32_t encryptAlgorithm, char* encryptKey); +int32_t tsdbDataFileRAWWriteBlockData(SDataFileRAWWriter *writer, const STsdbDataRAWBlockHeader *bHdr, + int32_t encryptAlgorithm, char *encryptKey); int32_t tsdbDataFileRAWFlush(SDataFileRAWWriter *writer); #ifdef __cplusplus diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c index 92931cc114..0365a18e74 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -733,8 +733,6 @@ _exit: return code; } -extern int32_t tsdbAllocateDisk(STsdb *tsdb, int32_t fid, const char *label, SDiskID *diskId); - static int32_t tsdbDataFileWriterDoOpen(SDataFileWriter *writer) { int32_t code = 0; int32_t lino = 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbFSetRAW.c b/source/dnode/vnode/src/tsdb/tsdbFSetRAW.c index c446dfc68a..0ec252b5b5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSetRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSetRAW.c @@ -74,11 +74,14 @@ static int32_t tsdbFSetRAWWriteFileDataBegin(SFSetRAWWriter *writer, STsdbDataRA int32_t code = 0; int32_t lino = 0; + SDiskID diskID = {0}; + code = tsdbAllocateDisk(writer->config->tsdb, bHdr->file.fid, tsdbFTypeLabel(bHdr->file.type), &diskID); + TSDB_CHECK_CODE(code, lino, _exit); + SDataFileRAWWriterConfig config = { .tsdb = writer->config->tsdb, .szPage = writer->config->szPage, .fid = bHdr->file.fid, - .did = writer->config->did, .cid = bHdr->file.cid, .level = writer->config->level, @@ -86,7 +89,7 @@ static int32_t tsdbFSetRAWWriteFileDataBegin(SFSetRAWWriter *writer, STsdbDataRA { .type = bHdr->file.type, .fid = bHdr->file.fid, - .did = writer->config->did, + .did = diskID, .cid = bHdr->file.cid, .size = bHdr->file.size, .minVer = bHdr->file.minVer, diff --git a/source/dnode/vnode/src/tsdb/tsdbFSetRAW.h b/source/dnode/vnode/src/tsdb/tsdbFSetRAW.h index 95e360b231..6a8229e573 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSetRAW.h +++ b/source/dnode/vnode/src/tsdb/tsdbFSetRAW.h @@ -26,7 +26,6 @@ typedef struct SFSetRAWWriterConfig { STsdb *tsdb; int32_t szPage; - SDiskID did; int64_t fid; int64_t cid; int32_t level; @@ -36,8 +35,8 @@ typedef struct SFSetRAWWriter SFSetRAWWriter; int32_t tsdbFSetRAWWriterOpen(SFSetRAWWriterConfig *config, SFSetRAWWriter **writer); int32_t tsdbFSetRAWWriterClose(SFSetRAWWriter **writer, bool abort, TFileOpArray *fopArr); -int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm, - char* encryptKey); +int32_t tsdbFSetRAWWriteBlockData(SFSetRAWWriter *writer, STsdbDataRAWBlockHeader *bHdr, int32_t encryptAlgorithm, + char *encryptKey); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 4da4677a2b..ce8d20a2c5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -240,8 +240,6 @@ _exit: return code; } -extern int32_t tsdbAllocateDiskAtLevel(STsdb *tsdb, int32_t fid, int32_t level, const char *label, SDiskID *diskId); - static int32_t tsdbRemoveOrMoveFileObject(SRTNer *rtner, STFileObj *fobj) { int32_t code = 0; int32_t lino = 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index d44dd4c907..17b0f0f692 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -544,7 +544,6 @@ struct STsdbSnapWriter { bool fsetWriteBegin; int32_t fid; STFileSet* fset; - SDiskID did; bool hasData; // if have time series data bool hasTomb; // if have tomb data @@ -826,15 +825,6 @@ static int32_t tsdbSnapWriteFileSetBegin(STsdbSnapWriter* writer, int32_t fid) { STFileSet** fsetPtr = TARRAY2_SEARCH(writer->fsetArr, &fset, tsdbTFileSetCmprFn, TD_EQ); writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr; - int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec()); - if (tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did)) { - code = TSDB_CODE_NO_AVAIL_DISK; - TSDB_CHECK_CODE(code, lino, _exit); - } - if (tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did) != 0) { - tsdbError("vgId:%d failed to create directory %s", TD_VID(writer->tsdb->pVnode), writer->tsdb->path); - } - writer->ctx->hasData = true; writer->ctx->hasTomb = true; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c index a41003d9ab..74e6d403f4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c @@ -319,7 +319,6 @@ struct STsdbSnapRAWWriter { bool fsetWriteBegin; int32_t fid; STFileSet* fset; - SDiskID did; int64_t cid; int64_t level; @@ -371,7 +370,6 @@ static int32_t tsdbSnapRAWWriteFileSetOpenWriter(STsdbSnapRAWWriter* writer) { .szPage = writer->szPage, .fid = writer->ctx->fid, .cid = writer->commitID, - .did = writer->ctx->did, .level = writer->ctx->level, }; @@ -399,17 +397,9 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t STFileSet** fsetPtr = TARRAY2_SEARCH(writer->fsetArr, &fset, tsdbTFileSetCmprFn, TD_EQ); writer->ctx->fset = (fsetPtr == NULL) ? NULL : *fsetPtr; - int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec()); - code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did); - TSDB_CHECK_CODE(code, lino, _exit); - - code = tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); - TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbSnapRAWWriteFileSetOpenWriter(writer); TSDB_CHECK_CODE(code, lino, _exit); - writer->ctx->level = level; writer->ctx->fsetWriteBegin = true; _exit: diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index 3ffdcb544a..7ee660f27e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -778,8 +778,6 @@ static int32_t tsdbSttFileDoWriteFooter(SSttFileWriter *writer) { return tsdbFileWriteSttFooter(writer->fd, writer->footer, &writer->file->size, encryptAlgorithm, encryptKey); } -extern int32_t tsdbAllocateDisk(STsdb *tsdb, int32_t fid, const char *label, SDiskID *diskId); - static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) { int32_t code = 0; int32_t lino = 0;