more code
This commit is contained in:
parent
eb5950b6d6
commit
7e6021bc6a
|
@ -99,7 +99,10 @@ int tdUpdateTiersInfo(SDnodeTier *pDnodeTier) {
|
|||
|
||||
for (int j = 0; j < pTier->nDisks; j++) {
|
||||
SDisk *pDisk = pTier->disks[j];
|
||||
if (tdUpdateDiskMeta(pDisk) < 0) return -1;
|
||||
if (tdUpdateDiskMeta(pDisk) < 0) {
|
||||
tdUnLockTiers(pDnodeTier);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pDnodeTier->meta.tsize += pDisk->dmeta.size;
|
||||
pDnodeTier->meta.avail += pDisk->dmeta.free;
|
||||
|
|
|
@ -34,6 +34,7 @@ int taosFSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t
|
|||
#define taosTRead(fd, buf, count) taosTReadImp(fd, buf, count)
|
||||
#define taosTWrite(fd, buf, count) taosTWriteImp(fd, buf, count)
|
||||
#define taosLSeek(fd, offset, whence) lseek(fd, offset, whence)
|
||||
ssize_t taosTCopy(char *from, char *to);
|
||||
|
||||
#ifdef TAOS_RANDOM_FILE_FAIL
|
||||
void taosSetRandomFileFailFactor(int factor);
|
||||
|
|
|
@ -108,6 +108,39 @@ ssize_t taosTWriteImp(int fd, void *buf, size_t n) {
|
|||
return (ssize_t)n;
|
||||
}
|
||||
|
||||
ssize_t taosTCopy(char *from, char *to) {
|
||||
char buffer[4096];
|
||||
int fidto = -1, fidfrom = -1;
|
||||
ssize_t size = 0;
|
||||
ssize_t bytes;
|
||||
|
||||
fidfrom = open(from, O_RDONLY);
|
||||
if (fidfrom < 0) goto _err;
|
||||
|
||||
fidto = open(to, O_WRONLY | O_CREAT, 0755);
|
||||
if (fidto < 0) goto _err;
|
||||
|
||||
while (true) {
|
||||
bytes = taosTRead(fidfrom, buffer, sizeof(buffer));
|
||||
if (bytes < 0) goto _err;
|
||||
if (bytes == 0) break;
|
||||
|
||||
size += bytes;
|
||||
|
||||
if (taosTWrite(fidto, (void *)buffer, bytes) < bytes) goto _err;
|
||||
if (bytes < sizeof(buffer)) break;
|
||||
}
|
||||
|
||||
close(fidfrom);
|
||||
close(fidto);
|
||||
return size;
|
||||
|
||||
_err:
|
||||
if (fidfrom >= 0) close(fidfrom);
|
||||
if (fidto >= 0) close(fidto);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
|
||||
ssize_t taosTSendFileImp(int dfd, int sfd, off_t *offset, size_t size) {
|
||||
size_t leftbytes = size;
|
||||
|
|
|
@ -471,11 +471,14 @@ int tsdbApplyRetention(STsdbRepo *pRepo, SFidGroup *pFidGroup) {
|
|||
nFileGroup.level = level;
|
||||
nFileGroup.did = pDisk->did;
|
||||
|
||||
char tsdbRootDir[TSDB_FILENAME_LEN];
|
||||
tdGetTsdbRootDir(pDisk->dir, REPO_ID(pRepo), tsdbRootDir);
|
||||
for (int type = 0; type < TSDB_FILE_TYPE_MAX; type++) {
|
||||
// TODO fileGroup.files[type].fname
|
||||
tsdbGetDataFileName(tsdbRootDir, REPO_ID(pRepo), pGroup->fileId, type, nFileGroup.files[type].fname);
|
||||
}
|
||||
|
||||
for (int type = 0; type < TSDB_FILE_TYPE_MAX; type++) {
|
||||
if (taosTCopy(oFileGroup.files[type].fname, nFileGroup.files[type].fname) < 0) return -1;
|
||||
}
|
||||
|
||||
pthread_rwlock_wrlock(&(pFileH->fhlock));
|
||||
|
|
Loading…
Reference in New Issue