tfsint.h 2.2 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

H
refact  
Hongze Cheng 已提交
16 17
#ifndef TD_TFSINT_H
#define TD_TFSINT_H
H
refact  
Hongze Cheng 已提交
18

H
Hongze Cheng 已提交
19 20 21
#include "tlog.h"
#include "tglobal.h"

H
refact  
Hongze Cheng 已提交
22 23 24 25
#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
26 27
extern int fsDebugFlag;

H
refact  
Hongze Cheng 已提交
28
// For debug purpose
H
Hongze Cheng 已提交
29 30 31 32 33 34
#define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("TFS FATAL ", 255, __VA_ARGS__); }}
#define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("TFS ERROR ", 255, __VA_ARGS__); }}
#define fWarn(...)  { if (fsDebugFlag & DEBUG_WARN)  { taosPrintLog("TFS WARN ", 255, __VA_ARGS__); }}
#define fInfo(...)  { if (fsDebugFlag & DEBUG_INFO)  { taosPrintLog("TFS ", 255, __VA_ARGS__); }}
#define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("TFS ", cqDebugFlag, __VA_ARGS__); }}
#define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("TFS ", cqDebugFlag, __VA_ARGS__); }}
H
refact  
Hongze Cheng 已提交
35

H
refact  
Hongze Cheng 已提交
36 37 38 39 40 41 42
// tdisk.c
typedef struct SDisk SDisk;

SDisk *tfsNewDisk(int level, int id, char *dir);
void   tfsFreeDisk(SDisk *pDisk);
int    tfsUpdateDiskInfo(SDisk *pDisk);

H
Hongze Cheng 已提交
43 44
const char *tfsDiskDir(SDisk *pDisk);

H
refact  
Hongze Cheng 已提交
45
// ttier.c
H
Hongze Cheng 已提交
46 47 48 49 50 51 52
#define TSDB_MAX_DISK_PER_TIER 16

typedef struct STier {
  int    level;
  int    ndisk;
  SDisk *disks[TSDB_MAX_DISK_PER_TIER];
} STier;
H
refact  
Hongze Cheng 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66

#define DISK_AT_TIER(pTier, id) ((pTier)->disks[id])

void   tfsInitTier(STier *pTier, int level);
void   tfsDestroyTier(STier *pTier);
SDisk *tfsMountDiskToTier(STier *pTier, SDiskCfg *pCfg);
int    tfsUpdateTierInfo(STier *pTier);

// tfs.c
void tfsIncFileAt(int level, int id);
void tfsDecFileAt(int level, int id);
int  tfsLock();
int  tfsUnLock();
bool tfsIsLocked();
H
Hongze Cheng 已提交
67
int  tfsLevels();
H
refact  
Hongze Cheng 已提交
68 69 70

// tfcntl.c

H
refact  
Hongze Cheng 已提交
71 72 73 74 75
#ifdef __cplusplus
}
#endif

#endif