osfile
This commit is contained in:
parent
a12e96d2c3
commit
aa5683cfd9
|
@ -397,7 +397,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosLSeekFile(pFile, 0, SEEK_END) < 0) {
|
if (taosLSeekFile(pFile, 0, SEEK_END) < 0) {
|
||||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
tscError("failed to seek file:%p code: %d", pFile, terrno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (taosWriteFile(pFile, slowLogData->data, strlen(slowLogData->data) + 1) < 0) {
|
if (taosWriteFile(pFile, slowLogData->data, strlen(slowLogData->data) + 1) < 0) {
|
||||||
|
@ -409,7 +409,7 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
|
||||||
static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
||||||
tscDebug("[monitor] readFile slow begin pFile:%p, offset:%" PRId64 ", size:%" PRId64, pFile, *offset, size);
|
tscDebug("[monitor] readFile slow begin pFile:%p, offset:%" PRId64 ", size:%" PRId64, pFile, *offset, size);
|
||||||
if (taosLSeekFile(pFile, *offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(pFile, *offset, SEEK_SET) < 0) {
|
||||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
tscError("failed to seek file:%p code: %d", pFile, terrno);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ int32_t s3CheckCfg() {
|
||||||
}
|
}
|
||||||
if (taosWriteFile(fp, testdata, strlen(testdata)) < 0) {
|
if (taosWriteFile(fp, testdata, strlen(testdata)) < 0) {
|
||||||
(void)fprintf(stderr, "failed to write test file: %s.\n", path);
|
(void)fprintf(stderr, "failed to write test file: %s.\n", path);
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _next);
|
TAOS_CHECK_GOTO(terrno, &lino, _next);
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(fp) < 0) {
|
if (taosFsyncFile(fp) < 0) {
|
||||||
(void)fprintf(stderr, "failed to fsync test file: %s.\n", path);
|
(void)fprintf(stderr, "failed to fsync test file: %s.\n", path);
|
||||||
|
@ -872,7 +872,7 @@ upload:
|
||||||
|
|
||||||
if (i > 0 && cp.parts[i - 1].completed) {
|
if (i > 0 && cp.parts[i - 1].completed) {
|
||||||
if (taosLSeekFile(data->infileFD, cp.parts[i].offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(data->infileFD, cp.parts[i].offset, SEEK_SET) < 0) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,7 +1076,7 @@ static int32_t s3PutObjectFromFileOffsetByEp(const char *file, const char *objec
|
||||||
}
|
}
|
||||||
if (taosLSeekFile(data.infileFD, offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(data.infileFD, offset, SEEK_SET) < 0) {
|
||||||
(void)taosCloseFile(&data.infileFD);
|
(void)taosCloseFile(&data.infileFD);
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
data.totalContentLength = data.totalOriginalContentLength = data.contentLength = data.originalContentLength =
|
||||||
|
|
|
@ -210,10 +210,10 @@ static int32_t cos_cp_save_json(cJSON const* json, SCheckpoint* checkpoint) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
||||||
}
|
}
|
||||||
if (taosLSeekFile(fp, 0, SEEK_SET) < 0) {
|
if (taosLSeekFile(fp, 0, SEEK_SET) < 0) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||||
}
|
}
|
||||||
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _exit);
|
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFsyncFile(fp) < 0) {
|
if (taosFsyncFile(fp) < 0) {
|
||||||
|
|
|
@ -90,10 +90,10 @@ static int32_t generateConfigFile(char* confDir) {
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
uDebug("[rsync] conf:%s", confContent);
|
uDebug("[rsync] conf:%s", confContent);
|
||||||
if (taosWriteFile(pFile, confContent, strlen(confContent)) <= 0) {
|
if (taosWriteFile(pFile, confContent, strlen(confContent)) != TSDB_CODE_SUCCESS) {
|
||||||
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ int32_t mmReadFile(const char *path, SMnodeOpt *pOption) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption) {
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
|
|
@ -120,8 +120,8 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
dError("failed to fstat mnode file:%s since %s", file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
|
|
@ -209,8 +209,8 @@ int32_t dmReadEps(SDnodeData *pData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ int32_t dmWriteEps(SDnodeData *pData) {
|
||||||
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(terrno, NULL, _OVER);
|
||||||
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER);
|
||||||
|
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
|
@ -612,8 +612,8 @@ static int32_t dmReadDnodePairs(SDnodeData *pData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
dError("failed to fstat dnode file:%s since %s", file, terrstr());
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ int32_t dmReadFile(const char *path, const char *name, bool *pDeployed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat file:%s since %s", file, tstrerror(code));
|
dError("failed to fstat file:%s since %s", file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ int32_t dmWriteFile(const char *path, const char *name, bool deployed) {
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
@ -244,7 +244,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, opts.result, len) <= 0) {
|
if (taosWriteFile(pFile, opts.result, len) <= 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ static int32_t dmWriteEncryptCodeFile(char *file, char *realfile, char *encryptC
|
||||||
|
|
||||||
int32_t len = strlen(encryptCode);
|
int32_t len = strlen(encryptCode);
|
||||||
if (taosWriteFile(pFile, encryptCode, len) <= 0) {
|
if (taosWriteFile(pFile, encryptCode, len) <= 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
@ -320,8 +320,8 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
encryptError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
encryptError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
@ -461,8 +461,8 @@ static int32_t dmReadEncryptCodeFile(char *file, char **output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
dError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
dError("failed to fstat dnode file:%s since %s", file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,26 +168,21 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
int32_t code = 0;
|
|
||||||
int64_t sver = SDB_FILE_VER;
|
int64_t sver = SDB_FILE_VER;
|
||||||
if (taosWriteFile(pFile, &sver, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &sver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &pSdb->applyIndex, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, &pSdb->applyTerm, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &pSdb->applyTerm, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, &pSdb->applyConfig, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &pSdb->applyConfig, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||||
|
@ -196,8 +191,7 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
maxId = pSdb->maxId[i];
|
maxId = pSdb->maxId[i];
|
||||||
}
|
}
|
||||||
if (taosWriteFile(pFile, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &maxId, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,15 +201,13 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
ver = pSdb->tableVer[i];
|
ver = pSdb->tableVer[i];
|
||||||
}
|
}
|
||||||
if (taosWriteFile(pFile, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
if (taosWriteFile(pFile, &ver, sizeof(int64_t)) != sizeof(int64_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char reserve[SDB_RESERVE_SIZE] = {0};
|
char reserve[SDB_RESERVE_SIZE] = {0};
|
||||||
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
if (taosWriteFile(pFile, reserve, sizeof(reserve)) != sizeof(reserve)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
TAOS_RETURN(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -440,7 +432,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
pRaw->status = pRow->status;
|
pRaw->status = pRow->status;
|
||||||
|
|
||||||
if (taosWriteFile(pFile, pRaw, sizeof(SSdbRaw)) != sizeof(SSdbRaw)) {
|
if (taosWriteFile(pFile, pRaw, sizeof(SSdbRaw)) != sizeof(SSdbRaw)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
taosHashCancelIterate(hash, ppRow);
|
taosHashCancelIterate(hash, ppRow);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
break;
|
break;
|
||||||
|
@ -472,7 +464,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, newData, newDataLen) != newDataLen) {
|
if (taosWriteFile(pFile, newData, newDataLen) != newDataLen) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
taosHashCancelIterate(hash, ppRow);
|
taosHashCancelIterate(hash, ppRow);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
break;
|
break;
|
||||||
|
@ -484,7 +476,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
||||||
|
|
||||||
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
int32_t cksum = taosCalcChecksum(0, (const uint8_t *)pRaw, sizeof(SSdbRaw) + pRaw->dataLen);
|
||||||
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
if (taosWriteFile(pFile, &cksum, sizeof(int32_t)) != sizeof(int32_t)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = errno;
|
||||||
taosHashCancelIterate(hash, ppRow);
|
taosHashCancelIterate(hash, ppRow);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
break;
|
break;
|
||||||
|
@ -784,7 +776,7 @@ int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t writelen = taosWriteFile(pIter->file, pBuf, len);
|
int32_t writelen = taosWriteFile(pIter->file, pBuf, len);
|
||||||
if (writelen != len) {
|
if (writelen != len) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
mError("failed to write len:%d since %s, total:%" PRId64, len, tstrerror(code), pIter->total);
|
mError("failed to write len:%d since %s, total:%" PRId64, len, tstrerror(code), pIter->total);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) {
|
||||||
|
|
||||||
int64_t n = taosWriteFile(pFD, pData, size);
|
int64_t n = taosWriteFile(pFD, pData, size);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFsyncFile(pFD) < 0) {
|
if (taosFsyncFile(pFD) < 0) {
|
||||||
|
@ -296,8 +296,8 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size;
|
int64_t size;
|
||||||
if (taosFStatFile(pFD, &size, NULL) < 0) {
|
code = taosFStatFile(pFD, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
(void)taosCloseFile(&pFD);
|
(void)taosCloseFile(&pFD);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ static int32_t save_json(const cJSON *json, const char *fname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
if (taosWriteFile(fp, data, strlen(data)) < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFsyncFile(fp) < 0) {
|
if (taosFsyncFile(fp) < 0) {
|
||||||
|
@ -120,8 +120,9 @@ static int32_t load_json(const char *fname, cJSON **json) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size;
|
int64_t size;
|
||||||
if (taosFStatFile(fp, &size, NULL) < 0) {
|
code = taosFStatFile(fp, &size, NULL);
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(code), lino, _exit);
|
if (code != 0) {
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
data = taosMemoryMalloc(size + 1);
|
data = taosMemoryMalloc(size + 1);
|
||||||
|
|
|
@ -154,7 +154,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
||||||
|
|
||||||
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
(void)taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
|
||||||
|
@ -183,7 +183,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
|
||||||
|
|
||||||
n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFD->szFile < pFD->pgno) {
|
if (pFD->szFile < pFD->pgno) {
|
||||||
|
@ -220,7 +220,7 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
|
||||||
// seek
|
// seek
|
||||||
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read
|
// read
|
||||||
|
@ -373,7 +373,7 @@ static int32_t tsdbReadFileBlock(STsdbFD *pFD, int64_t offset, int64_t size, boo
|
||||||
// read last chunk
|
// read last chunk
|
||||||
int64_t ret = taosLSeekFile(pFD->pFD, chunksize * (chunkno - pFD->lcn) + cOffset, SEEK_SET);
|
int64_t ret = taosLSeekFile(pFD->pFD, chunksize * (chunkno - pFD->lcn) + cOffset, SEEK_SET);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = taosReadFile(pFD->pFD, buf + n, nRead);
|
ret = taosReadFile(pFD->pFD, buf + n, nRead);
|
||||||
|
|
|
@ -185,7 +185,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
if (taosWriteFile(pFile, data, strlen(data)) < 0) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = terrno, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
@ -236,9 +236,8 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
|
||||||
|
|
||||||
pData = taosMemoryMalloc(size + 1);
|
pData = taosMemoryMalloc(size + 1);
|
||||||
if (pData == NULL) {
|
if (pData == NULL) {
|
||||||
|
|
|
@ -272,9 +272,10 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size;
|
int64_t size;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
|
if (code != 0) {
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
|
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
|
||||||
|
|
|
@ -315,16 +315,16 @@ static int32_t saveBlocksToDisk(SGroupCacheOperatorInfo* pGCache, SGcDownstreamC
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = taosLSeekFile(pFd->fd, pHead->basic.offset, SEEK_SET);
|
int32_t ret = taosLSeekFile(pFd->fd, pHead->basic.offset, SEEK_SET);
|
||||||
if (ret == -1) {
|
if (ret < 0) {
|
||||||
releaseFdToFileCtx(pFd);
|
releaseFdToFileCtx(pFd);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (int32_t)taosWriteFile(pFd->fd, pHead->pBuf, pHead->basic.bufSize);
|
ret = (int32_t)taosWriteFile(pFd->fd, pHead->pBuf, pHead->basic.bufSize);
|
||||||
if (ret != pHead->basic.bufSize) {
|
if (ret != pHead->basic.bufSize) {
|
||||||
releaseFdToFileCtx(pFd);
|
releaseFdToFileCtx(pFd);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,8 +548,8 @@ static int32_t readBlockFromDisk(SGroupCacheOperatorInfo* pGCache, SGroupCacheDa
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = taosLSeekFile(pFileFd->fd, pBasic->offset, SEEK_SET);
|
int32_t ret = taosLSeekFile(pFileFd->fd, pBasic->offset, SEEK_SET);
|
||||||
if (ret == -1) {
|
if (ret < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1669,7 +1669,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nBytes != taosWriteFile(pFile, buf, nBytes)) {
|
if (nBytes != taosWriteFile(pFile, buf, nBytes)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
stError("failed to write file to add extra info, file:%s, reason:%s", pDst, tstrerror(code));
|
stError("failed to write file to add extra info, file:%s, reason:%s", pDst, tstrerror(code));
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
@ -4970,7 +4970,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
||||||
|
|
||||||
nBytes = taosWriteFile(pFile, content, strlen(content));
|
nBytes = taosWriteFile(pFile, content, strlen(content));
|
||||||
if (nBytes != strlen(content)) {
|
if (nBytes != strlen(content)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
|
|
|
@ -156,7 +156,7 @@ int32_t syncWriteCfgFile(SSyncNode *pNode) {
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
if (taosWriteFile(pFile, buffer, len) <= 0) {
|
||||||
TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno));
|
TAOS_CHECK_EXIT(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosFsyncFile(pFile) < 0) {
|
if (taosFsyncFile(pFile) < 0) {
|
||||||
|
@ -265,8 +265,8 @@ int32_t syncReadCfgFile(SSyncNode *pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
if (code != 0) {
|
||||||
sError("vgId:%d, failed to fstat sync cfg file:%s since %s", pNode->vgId, file, tstrerror(code));
|
sError("vgId:%d, failed to fstat sync cfg file:%s since %s", pNode->vgId, file, tstrerror(code));
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,10 +58,10 @@ int32_t raftStoreReadFile(SSyncNode *pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
code = taosFStatFile(pFile, &size, NULL);
|
||||||
|
if (code != 0) {
|
||||||
sError("vgId:%d, failed to fstat raft store file:%s since %s", pNode->vgId, file, terrstr());
|
sError("vgId:%d, failed to fstat raft store file:%s since %s", pNode->vgId, file, terrstr());
|
||||||
|
TAOS_CHECK_GOTO(code, &lino, _OVER);
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pData = taosMemoryMalloc(size + 1);
|
pData = taosMemoryMalloc(size + 1);
|
||||||
|
@ -130,7 +130,7 @@ int32_t raftStoreWriteFile(SSyncNode *pNode) {
|
||||||
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
if (pFile == NULL) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
||||||
|
|
||||||
int32_t len = strlen(buffer);
|
int32_t len = strlen(buffer);
|
||||||
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(terrno, &lino, _OVER);
|
||||||
|
|
||||||
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER);
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in
|
||||||
int64_t ret = taosLSeekFile(pFile, offset, SEEK_SET);
|
int64_t ret = taosLSeekFile(pFile, offset, SEEK_SET);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wError("vgId:%d, failed to lseek file due to %s. offset:%" PRId64 "", pWal->cfg.vgId, strerror(errno), offset);
|
wError("vgId:%d, failed to lseek file due to %s. offset:%" PRId64 "", pWal->cfg.vgId, strerror(errno), offset);
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readSize != taosReadFile(pFile, buf, readSize)) {
|
if (readSize != taosReadFile(pFile, buf, readSize)) {
|
||||||
|
@ -169,9 +169,9 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in
|
||||||
}
|
}
|
||||||
int64_t ret = taosLSeekFile(pFile, offset + readSize, SEEK_SET);
|
int64_t ret = taosLSeekFile(pFile, offset + readSize, SEEK_SET);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wError("vgId:%d, failed to lseek file due to %s. offset:%" PRId64 "", pWal->cfg.vgId, strerror(errno),
|
wError("vgId:%d, failed to lseek file due to %s. offset:%" PRId64 "", pWal->cfg.vgId, strerror(terrno),
|
||||||
offset);
|
offset);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (extraSize != taosReadFile(pFile, buf + readSize, extraSize)) {
|
if (extraSize != taosReadFile(pFile, buf + readSize, extraSize)) {
|
||||||
|
@ -518,7 +518,7 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
|
||||||
|
|
||||||
static int32_t walReadLogHead(TdFilePtr pLogFile, int64_t offset, SWalCkHead* pCkHead) {
|
static int32_t walReadLogHead(TdFilePtr pLogFile, int64_t offset, SWalCkHead* pCkHead) {
|
||||||
if (taosLSeekFile(pLogFile, offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(pLogFile, offset, SEEK_SET) < 0) {
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosReadFile(pLogFile, pCkHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
if (taosReadFile(pLogFile, pCkHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
||||||
|
@ -578,14 +578,14 @@ static int32_t walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
// determine the last valid entry end, i.e. offset
|
// determine the last valid entry end, i.e. offset
|
||||||
while ((offset -= sizeof(SWalIdxEntry)) >= 0) {
|
while ((offset -= sizeof(SWalIdxEntry)) >= 0) {
|
||||||
if (taosLSeekFile(pIdxFile, offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(pIdxFile, offset, SEEK_SET) < 0) {
|
||||||
wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
|
wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(terrno),
|
||||||
offset, fnameStr);
|
offset, fnameStr);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosReadFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) {
|
if (taosReadFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) {
|
||||||
wError("vgId:%d, failed to read file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno),
|
wError("vgId:%d, failed to read file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(terrno),
|
||||||
offset, fnameStr);
|
offset, fnameStr);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
|
@ -628,7 +628,7 @@ static int32_t walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
wError("vgId:%d, failed to seek file since %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, terrstr(), offset,
|
wError("vgId:%d, failed to seek file since %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, terrstr(), offset,
|
||||||
fnameStr);
|
fnameStr);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t count = 0;
|
int64_t count = 0;
|
||||||
|
@ -654,7 +654,7 @@ static int32_t walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
|
if (pWal->cfg.level != TAOS_WAL_SKIP && taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) {
|
||||||
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
|
wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -950,7 +950,7 @@ int32_t walSaveMeta(SWal* pWal) {
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && len != taosWriteFile(pMetaFile, serialized, len)) {
|
if (pWal->cfg.level != TAOS_WAL_SKIP && len != taosWriteFile(pMetaFile, serialized, len)) {
|
||||||
wError("vgId:%d, failed to write file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), tmpFnameStr);
|
wError("vgId:%d, failed to write file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), tmpFnameStr);
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _err);
|
TAOS_CHECK_GOTO(terrno, &lino, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && taosFsyncFile(pMetaFile) < 0) {
|
if (pWal->cfg.level != TAOS_WAL_SKIP && taosFsyncFile(pMetaFile) < 0) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ static int32_t walReadSeekFilePos(SWalReader *pReader, int64_t fileFirstVer, int
|
||||||
wError("vgId:%d, failed to seek idx file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pReader->pWal->cfg.vgId,
|
wError("vgId:%d, failed to seek idx file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pReader->pWal->cfg.vgId,
|
||||||
ver, offset, terrstr());
|
ver, offset, terrstr());
|
||||||
|
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
SWalIdxEntry entry = {0};
|
SWalIdxEntry entry = {0};
|
||||||
if ((ret = taosReadFile(pIdxTFile, &entry, sizeof(SWalIdxEntry))) != sizeof(SWalIdxEntry)) {
|
if ((ret = taosReadFile(pIdxTFile, &entry, sizeof(SWalIdxEntry))) != sizeof(SWalIdxEntry)) {
|
||||||
|
@ -158,7 +158,7 @@ static int32_t walReadSeekFilePos(SWalReader *pReader, int64_t fileFirstVer, int
|
||||||
wError("vgId:%d, failed to seek log file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pReader->pWal->cfg.vgId,
|
wError("vgId:%d, failed to seek log file, index:%" PRId64 ", pos:%" PRId64 ", since %s", pReader->pWal->cfg.vgId,
|
||||||
ver, entry.offset, terrstr());
|
ver, entry.offset, terrstr());
|
||||||
|
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
|
@ -303,7 +303,7 @@ int32_t walSkipFetchBody(SWalReader *pRead) {
|
||||||
}
|
}
|
||||||
int64_t code = taosLSeekFile(pRead->pLogFile, cryptedBodyLen, SEEK_CUR);
|
int64_t code = taosLSeekFile(pRead->pLogFile, cryptedBodyLen, SEEK_CUR);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRead->curVersion++;
|
pRead->curVersion++;
|
||||||
|
|
|
@ -207,7 +207,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||||
|
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
// read idx file and get log file pos
|
// read idx file and get log file pos
|
||||||
SWalIdxEntry entry;
|
SWalIdxEntry entry;
|
||||||
|
@ -232,7 +232,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
|
||||||
// TODO
|
// TODO
|
||||||
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
TAOS_UNUSED(taosThreadMutexUnlock(&pWal->mutex));
|
||||||
|
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
// validate offset
|
// validate offset
|
||||||
SWalCkHead head;
|
SWalCkHead head;
|
||||||
|
@ -536,13 +536,13 @@ static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) {
|
||||||
pWal->stopDnode();
|
pWal->stopDnode();
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check alignment of idx entries
|
// check alignment of idx entries
|
||||||
int64_t endOffset = taosLSeekFile(pWal->pIdxFile, 0, SEEK_END);
|
int64_t endOffset = taosLSeekFile(pWal->pIdxFile, 0, SEEK_END);
|
||||||
if (endOffset < 0) {
|
if (endOffset < 0) {
|
||||||
wFatal("vgId:%d, failed to seek end of WAL idxfile due to %s. ver:%" PRId64 "", pWal->cfg.vgId, strerror(errno),
|
wFatal("vgId:%d, failed to seek end of WAL idxfile due to %s. ver:%" PRId64 "", pWal->cfg.vgId, strerror(terrno),
|
||||||
ver);
|
ver);
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -578,7 +578,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
|
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP &&
|
if (pWal->cfg.level != TAOS_WAL_SKIP &&
|
||||||
taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWal->cfg.level != TAOS_WAL_SKIP && taosWriteFile(pWal->pLogFile, (char *)buf, cyptedBodyLen) != cyptedBodyLen) {
|
if (pWal->cfg.level != TAOS_WAL_SKIP && taosWriteFile(pWal->pLogFile, (char *)buf, cyptedBodyLen) != cyptedBodyLen) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
|
|
|
@ -437,19 +437,22 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||||
|
|
||||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
|
||||||
if (pFile == NULL || pFile->hFile == NULL) {
|
if (pFile == NULL || pFile->hFile == NULL) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
taosThreadRwlockWrlock(&(pFile->rwlock));
|
(void)taosThreadRwlockWrlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DWORD bytesWritten;
|
DWORD bytesWritten;
|
||||||
if (!WriteFile(pFile->hFile, buf, count, &bytesWritten, NULL)) {
|
if (!WriteFile(pFile->hFile, buf, count, &bytesWritten, NULL)) {
|
||||||
|
errno = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errno);
|
||||||
bytesWritten = -1;
|
bytesWritten = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
(void)taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||||
#endif
|
#endif
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
}
|
}
|
||||||
|
@ -490,6 +493,7 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
|
||||||
|
|
||||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
if (pFile == NULL || pFile->hFile == NULL) {
|
if (pFile == NULL || pFile->hFile == NULL) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
|
@ -499,11 +503,15 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
LARGE_INTEGER liOffset;
|
LARGE_INTEGER liOffset;
|
||||||
liOffset.QuadPart = offset;
|
liOffset.QuadPart = offset;
|
||||||
if (!SetFilePointerEx(pFile->hFile, liOffset, NULL, whence)) {
|
if (!SetFilePointerEx(pFile->hFile, liOffset, NULL, whence)) {
|
||||||
|
errno = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
liOffset.QuadPart = 0;
|
liOffset.QuadPart = 0;
|
||||||
if (!SetFilePointerEx(pFile->hFile, liOffset, &liOffset, FILE_CURRENT)) {
|
if (!SetFilePointerEx(pFile->hFile, liOffset, &liOffset, FILE_CURRENT)) {
|
||||||
|
errno = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
|
@ -514,13 +522,16 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
|
|
||||||
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
if (pFile == NULL || pFile->hFile == NULL) {
|
if (pFile == NULL || pFile->hFile == NULL) {
|
||||||
return 0;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size != NULL) {
|
if (size != NULL) {
|
||||||
LARGE_INTEGER fileSize;
|
LARGE_INTEGER fileSize;
|
||||||
if (!GetFileSizeEx(pFile->hFile, &fileSize)) {
|
if (!GetFileSizeEx(pFile->hFile, &fileSize)) {
|
||||||
return -1; // Error getting file size
|
errno = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errno);
|
||||||
|
return terrno; // Error getting file size
|
||||||
}
|
}
|
||||||
*size = fileSize.QuadPart;
|
*size = fileSize.QuadPart;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +539,9 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
if (mtime != NULL) {
|
if (mtime != NULL) {
|
||||||
FILETIME creationTime, lastAccessTime, lastWriteTime;
|
FILETIME creationTime, lastAccessTime, lastWriteTime;
|
||||||
if (!GetFileTime(pFile->hFile, &creationTime, &lastAccessTime, &lastWriteTime)) {
|
if (!GetFileTime(pFile->hFile, &creationTime, &lastAccessTime, &lastWriteTime)) {
|
||||||
return -1; // Error getting file time
|
errno = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_WINAPI_ERROR(errno);
|
||||||
|
return terrno; // Error getting file time
|
||||||
}
|
}
|
||||||
// Convert the FILETIME structure to a time_t value
|
// Convert the FILETIME structure to a time_t value
|
||||||
ULARGE_INTEGER ull;
|
ULARGE_INTEGER ull;
|
||||||
|
@ -854,7 +867,7 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
|
||||||
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
if (pFile == NULL || pFile->fd < 0) {
|
if (pFile == NULL || pFile->fd < 0) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return -1;
|
||||||
}
|
}
|
||||||
#if FILE_WITH_LOCK
|
#if FILE_WITH_LOCK
|
||||||
(void)taosThreadRwlockRdlock(&(pFile->rwlock));
|
(void)taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||||
|
@ -873,7 +886,7 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return terrno;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -890,16 +903,11 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
|
||||||
struct __stat64 fileStat;
|
|
||||||
int32_t code = _fstat64(pFile->fd, &fileStat);
|
|
||||||
#else
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int32_t code = fstat(pFile->fd, &fileStat);
|
int32_t code = fstat(pFile->fd, &fileStat);
|
||||||
#endif
|
|
||||||
if (-1 == code) {
|
if (-1 == code) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return code;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size != NULL) {
|
if (size != NULL) {
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ int32_t taosWinSocketInit() {
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
wVersionRequested = MAKEWORD(1, 1);
|
wVersionRequested = MAKEWORD(1, 1);
|
||||||
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
|
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
|
||||||
atomic_store_8(&flag, 0)
|
atomic_store_8(&flag, 0);
|
||||||
int errorCode = WSAGetLastError();
|
int errorCode = WSAGetLastError();
|
||||||
return terrno = TAOS_SYSTEM_WINSOCKET_ERROR(errorCode);
|
return terrno = TAOS_SYSTEM_WINSOCKET_ERROR(errorCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1255,11 +1255,16 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno));
|
TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno));
|
||||||
}
|
}
|
||||||
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
|
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
|
||||||
|
if(fileSize <= 0) {
|
||||||
|
(void)taosCloseFile(&pFile);
|
||||||
|
(void)printf("load json file error: %s\n", filepath);
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
char *buf = taosMemoryMalloc(fileSize + 1);
|
char *buf = taosMemoryMalloc(fileSize + 1);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
(void)printf("load json file error: %s, failed to alloc memory\n", filepath);
|
(void)printf("load json file error: %s, failed to alloc memory\n", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[fileSize] = 0;
|
buf[fileSize] = 0;
|
||||||
|
|
|
@ -545,9 +545,9 @@ static int32_t taosInitNormalLog(const char *logName, int32_t maxFileNum) {
|
||||||
|
|
||||||
// only an estimate for number of lines
|
// only an estimate for number of lines
|
||||||
int64_t filesize = 0;
|
int64_t filesize = 0;
|
||||||
if (taosFStatFile(tsLogObj.logHandle->pFile, &filesize, NULL) < 0) {
|
if (taosFStatFile(tsLogObj.logHandle->pFile, &filesize, NULL) != 0) {
|
||||||
(void)printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
|
(void)printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
}
|
}
|
||||||
tsLogObj.lines = (int32_t)(filesize / 60);
|
tsLogObj.lines = (int32_t)(filesize / 60);
|
||||||
|
|
||||||
|
@ -1003,7 +1003,6 @@ _return:
|
||||||
|
|
||||||
if (pFile) (void)taosCloseFile(&pFile);
|
if (pFile) (void)taosCloseFile(&pFile);
|
||||||
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
taosPrintLog(flags, level, dflag, "crash signal is %d", signum);
|
taosPrintLog(flags, level, dflag, "crash signal is %d", signum);
|
||||||
|
|
||||||
#ifdef _TD_DARWIN_64
|
#ifdef _TD_DARWIN_64
|
||||||
|
|
|
@ -136,13 +136,12 @@ static FORCE_INLINE size_t getAllocPageSize(int32_t pageSize) { return pageSize
|
||||||
static int32_t doFlushBufPageImpl(SDiskbasedBuf* pBuf, int64_t offset, const char* pData, int32_t size) {
|
static int32_t doFlushBufPageImpl(SDiskbasedBuf* pBuf, int64_t offset, const char* pData, int32_t size) {
|
||||||
int32_t ret = taosLSeekFile(pBuf->pFile, offset, SEEK_SET);
|
int32_t ret = taosLSeekFile(pBuf->pFile, offset, SEEK_SET);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = terrno;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (int32_t)taosWriteFile(pBuf->pFile, pData, size);
|
ret = (int32_t)taosWriteFile(pBuf->pFile, pData, size);
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +248,7 @@ static int32_t loadPageFromDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) {
|
||||||
|
|
||||||
int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET);
|
int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ret = TAOS_SYSTEM_ERROR(errno);
|
ret = terrno;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue