From 43edc0378f2f40541ca5c4d6756a5bcb4fb13257 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 29 Oct 2020 06:28:50 +0000 Subject: [PATCH] TD-1847 Modify the file names of wal module --- src/inc/twal.h | 27 ++++++++---------- src/wal/inc/walInt.h | 41 +++++++++++++++++++++++++++ src/wal/inc/walMgmt.h | 27 ++++++++++++++++++ src/wal/src/walMgmt.c | 21 ++++++++++++++ src/wal/src/{walMain.c => walWrite.c} | 16 ++--------- 5 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 src/wal/inc/walInt.h create mode 100644 src/wal/inc/walMgmt.h create mode 100644 src/wal/src/walMgmt.c rename src/wal/src/{walMain.c => walWrite.c} (95%) diff --git a/src/inc/twal.h b/src/inc/twal.h index 92204abd7d..1ce7b132b0 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -22,22 +22,22 @@ extern "C" { #define TAOS_WAL_NOLOG 0 #define TAOS_WAL_WRITE 1 #define TAOS_WAL_FSYNC 2 - + typedef struct { - int8_t msgType; - int8_t reserved[3]; - int32_t len; - uint64_t version; - uint32_t signature; - uint32_t cksum; - char cont[]; + int8_t msgType; + int8_t reserved[3]; + int32_t len; + uint64_t version; + uint32_t signature; + uint32_t cksum; + char cont[]; } SWalHead; typedef struct { - int8_t walLevel; // wal level - int32_t fsyncPeriod; // millisecond - int8_t wals; // number of WAL files; - int8_t keep; // keep the wal file when closed + int8_t walLevel; // wal level + int32_t fsyncPeriod; // millisecond + int8_t wals; // number of WAL files; + int8_t keep; // keep the wal file when closed } SWalCfg; typedef void* twalh; // WAL HANDLE @@ -53,9 +53,6 @@ int walRestore(twalh, void *pVnode, FWalWrite writeFp); int walGetWalFile(twalh, char *name, uint32_t *index); int64_t walGetVersion(twalh); -extern int wDebugFlag; - - #ifdef __cplusplus } #endif diff --git a/src/wal/inc/walInt.h b/src/wal/inc/walInt.h new file mode 100644 index 0000000000..593611589d --- /dev/null +++ b/src/wal/inc/walInt.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_WAL_INT_H +#define TDENGINE_WAL_INT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tlog.h" + +extern int32_t wDebugFlag; + +#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", 255, __VA_ARGS__); }} +#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", 255, __VA_ARGS__); }} +#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", 255, __VA_ARGS__); }} +#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", 255, __VA_ARGS__); }} +#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); }} +#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); }} + +#define walPrefix "wal" +#define walSignature (uint32_t)(0xFAFBFDFE) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/wal/inc/walMgmt.h b/src/wal/inc/walMgmt.h new file mode 100644 index 0000000000..a23c7f8ec3 --- /dev/null +++ b/src/wal/inc/walMgmt.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_WAL_MGMT_H +#define TDENGINE_WAL_MGMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/wal/src/walMgmt.c b/src/wal/src/walMgmt.c new file mode 100644 index 0000000000..2dd094d860 --- /dev/null +++ b/src/wal/src/walMgmt.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taoserror.h" +#include "twal.h" +#include "walInt.h" +#include "walMgmt.h" \ No newline at end of file diff --git a/src/wal/src/walMain.c b/src/wal/src/walWrite.c similarity index 95% rename from src/wal/src/walMain.c rename to src/wal/src/walWrite.c index 3492246a6f..95587caa14 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walWrite.c @@ -14,11 +14,10 @@ */ #define _DEFAULT_SOURCE - -#define TAOS_RANDOM_FILE_FAIL_TEST - #include "os.h" -#include "tlog.h" +#include "twal.h" +#include "walInt.h" +#include "walMgmt.h" #include "tchecksum.h" #include "tutil.h" #include "ttimer.h" @@ -26,14 +25,6 @@ #include "twal.h" #include "tqueue.h" -#define walPrefix "wal" - -#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", 255, __VA_ARGS__); }} -#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", 255, __VA_ARGS__); }} -#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", 255, __VA_ARGS__); }} -#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", 255, __VA_ARGS__); }} -#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); }} -#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); }} typedef struct { uint64_t version; @@ -54,7 +45,6 @@ typedef struct { static void *walTmrCtrl = NULL; static int tsWalNum = 0; static pthread_once_t walModuleInit = PTHREAD_ONCE_INIT; -static uint32_t walSignature = 0xFAFBFDFE; static int walHandleExistingFiles(const char *path); static int walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp); static int walRemoveWalFiles(const char *path); -- GitLab