2023-03-23 09:15:51 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-06-14 05:38:51 +00:00
|
|
|
#include "tsdbFSet2.h"
|
2023-05-08 02:27:55 +00:00
|
|
|
|
2023-03-23 09:15:51 +00:00
|
|
|
#ifndef _TSDB_FILE_SYSTEM_H
|
|
|
|
|
#define _TSDB_FILE_SYSTEM_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-04-06 08:26:41 +00:00
|
|
|
typedef enum {
|
2023-05-09 06:50:37 +00:00
|
|
|
TSDB_FEDIT_COMMIT = 1, //
|
|
|
|
|
TSDB_FEDIT_MERGE
|
|
|
|
|
} EFEditT;
|
2023-04-06 08:26:41 +00:00
|
|
|
|
2023-06-21 06:53:36 +00:00
|
|
|
typedef enum {
|
|
|
|
|
TSDB_FCURRENT = 1,
|
|
|
|
|
TSDB_FCURRENT_C, // for commit
|
|
|
|
|
TSDB_FCURRENT_M, // for merge
|
|
|
|
|
} EFCurrentT;
|
|
|
|
|
|
2023-03-23 09:15:51 +00:00
|
|
|
/* Exposed APIs */
|
2023-04-06 06:27:18 +00:00
|
|
|
// open/close
|
2023-05-15 09:14:45 +00:00
|
|
|
int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback);
|
|
|
|
|
int32_t tsdbCloseFS(STFileSystem **fs);
|
2023-05-31 02:59:47 +00:00
|
|
|
// snapshot
|
2023-05-31 07:57:51 +00:00
|
|
|
int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr);
|
|
|
|
|
int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr);
|
2023-06-15 06:10:35 +00:00
|
|
|
int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr);
|
2023-10-16 03:21:30 +00:00
|
|
|
int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fsetArr);
|
2023-09-18 06:46:26 +00:00
|
|
|
int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr);
|
2023-08-23 10:37:29 +00:00
|
|
|
|
2023-11-13 04:05:55 +00:00
|
|
|
int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pExclude, TFileSetArray **fsetArr,
|
2023-09-18 06:46:26 +00:00
|
|
|
TFileOpArray *fopArr);
|
2023-12-01 08:29:48 +00:00
|
|
|
int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr);
|
2023-11-13 04:05:55 +00:00
|
|
|
int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges,
|
|
|
|
|
TFileSetRangeArray **fsrArr);
|
|
|
|
|
int32_t tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr);
|
2023-12-01 08:05:14 +00:00
|
|
|
// txn
|
2023-06-01 07:08:45 +00:00
|
|
|
int64_t tsdbFSAllocEid(STFileSystem *fs);
|
2023-12-29 03:37:34 +00:00
|
|
|
void tsdbFSUpdateEid(STFileSystem *fs, int64_t cid);
|
2023-05-22 10:39:10 +00:00
|
|
|
int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT etype);
|
2023-05-31 07:57:51 +00:00
|
|
|
int32_t tsdbFSEditCommit(STFileSystem *fs);
|
|
|
|
|
int32_t tsdbFSEditAbort(STFileSystem *fs);
|
2023-05-11 10:16:55 +00:00
|
|
|
// other
|
2023-05-23 03:35:44 +00:00
|
|
|
int32_t tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset);
|
2023-10-27 09:48:19 +00:00
|
|
|
int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid);
|
2023-08-31 07:45:19 +00:00
|
|
|
// utils
|
|
|
|
|
int32_t save_fs(const TFileSetArray *arr, const char *fname);
|
|
|
|
|
int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype);
|
2023-03-23 09:15:51 +00:00
|
|
|
|
|
|
|
|
/* Exposed Structs */
|
2023-04-23 09:37:12 +00:00
|
|
|
struct STFileSystem {
|
2023-05-31 02:59:47 +00:00
|
|
|
STsdb *tsdb;
|
2023-05-19 05:35:32 +00:00
|
|
|
tsem_t canEdit;
|
2023-09-20 01:54:28 +00:00
|
|
|
int32_t fsstate;
|
2023-05-19 05:35:32 +00:00
|
|
|
int64_t neid;
|
|
|
|
|
EFEditT etype;
|
2023-05-31 07:57:51 +00:00
|
|
|
TFileSetArray fSetArr[1];
|
|
|
|
|
TFileSetArray fSetArrTmp[1];
|
2023-06-20 10:23:58 +00:00
|
|
|
|
|
|
|
|
// background task queue
|
2023-10-27 09:48:19 +00:00
|
|
|
bool stop;
|
|
|
|
|
int64_t taskid;
|
2023-04-23 09:37:12 +00:00
|
|
|
};
|
|
|
|
|
|
2023-03-23 09:15:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-07-17 00:50:54 +00:00
|
|
|
#endif /*_TSDB_FILE_SYSTEM_H*/
|