more code
This commit is contained in:
parent
708fa269b5
commit
f2dafd9362
|
@ -92,9 +92,9 @@ int32_t tfsGetLevel(STfs *pTfs);
|
|||
* @param pDiskId The disk ID after allocation.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, SDiskID *pDiskId);
|
||||
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, const char *label, SDiskID *pDiskId);
|
||||
|
||||
int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, SDiskID *pDiskId);
|
||||
int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, const char *label, SDiskID *pDiskId);
|
||||
|
||||
/**
|
||||
* @brief Get the primary path.
|
||||
|
|
|
@ -1811,7 +1811,7 @@ int32_t tsdbAllocateDisk(STsdb *tsdb, int32_t fid, const char *label, SDiskID *d
|
|||
STfs *tfs = tsdb->pVnode->pTfs;
|
||||
|
||||
int32_t expectedLevel = tsdbFidLevel(fid, &tsdb->keepCfg, taosGetTimestampSec());
|
||||
code = tfsAllocDisk(tfs, expectedLevel, &did);
|
||||
code = tfsAllocDisk(tfs, expectedLevel, label, &did);
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
return code;
|
||||
|
@ -1834,11 +1834,15 @@ int32_t tsdbAllocateDiskAtLevel(STsdb *tsdb, int32_t fid, int32_t level, const c
|
|||
};
|
||||
STfs *tfs = tsdb->pVnode->pTfs;
|
||||
|
||||
code = tfsAllocDiskAtLevel(tfs, level, &did);
|
||||
code = tfsAllocDiskAtLevel(tfs, level, label, &did);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (tfsMkdirRecurAt(tfs, tsdb->path, did) != 0) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
|
||||
}
|
||||
|
||||
if (diskId) {
|
||||
*diskId = did;
|
||||
}
|
||||
|
|
|
@ -152,18 +152,10 @@ int32_t tfsGetDisksAtLevel(STfs *pTfs, int32_t level) {
|
|||
|
||||
int32_t tfsGetLevel(STfs *pTfs) { return pTfs->nlevel; }
|
||||
|
||||
int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, SDiskID *pDiskId) {
|
||||
int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, const char *label, SDiskID *pDiskId) {
|
||||
pDiskId->level = level;
|
||||
pDiskId->id = -1;
|
||||
|
||||
if (pDiskId->level >= pTfs->nlevel) {
|
||||
pDiskId->level = pTfs->nlevel - 1;
|
||||
}
|
||||
|
||||
if (pDiskId->level < 0) {
|
||||
pDiskId->level = 0;
|
||||
}
|
||||
|
||||
pDiskId->id = tfsAllocDiskOnTier(&pTfs->tiers[pDiskId->level]);
|
||||
if (pDiskId->id < 0) {
|
||||
TAOS_RETURN(TSDB_CODE_FS_NO_VALID_DISK);
|
||||
|
@ -172,26 +164,17 @@ int32_t tfsAllocDiskAtLevel(STfs *pTfs, int32_t level, SDiskID *pDiskId) {
|
|||
TAOS_RETURN(0);
|
||||
}
|
||||
|
||||
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, SDiskID *pDiskId) {
|
||||
pDiskId->level = expLevel;
|
||||
pDiskId->id = -1;
|
||||
|
||||
if (pDiskId->level >= pTfs->nlevel) {
|
||||
pDiskId->level = pTfs->nlevel - 1;
|
||||
int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, const char *label, SDiskID *pDiskId) {
|
||||
if (expLevel >= pTfs->nlevel) {
|
||||
expLevel = pTfs->nlevel - 1;
|
||||
} else if (expLevel < 0) {
|
||||
expLevel = 0;
|
||||
}
|
||||
|
||||
if (pDiskId->level < 0) {
|
||||
pDiskId->level = 0;
|
||||
}
|
||||
|
||||
while (pDiskId->level >= 0) {
|
||||
pDiskId->id = tfsAllocDiskOnTier(&pTfs->tiers[pDiskId->level]);
|
||||
if (pDiskId->id < 0) {
|
||||
pDiskId->level--;
|
||||
continue;
|
||||
for (; expLevel >= 0; expLevel--) {
|
||||
if (tfsAllocDiskAtLevel(pTfs, expLevel, label, pDiskId) == 0) {
|
||||
TAOS_RETURN(0);
|
||||
}
|
||||
|
||||
TAOS_RETURN(0);
|
||||
}
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_FS_NO_VALID_DISK);
|
||||
|
|
Loading…
Reference in New Issue