diff --git a/src/common/inc/tdisk.h b/src/common/inc/tdisk.h index cf68ccd6e1041a13507903ba917edbebb3a686e6..7ce924c63e4ab6146aef076e82bb9ec04fce1d07 100644 --- a/src/common/inc/tdisk.h +++ b/src/common/inc/tdisk.h @@ -26,8 +26,8 @@ extern "C" { #endif -int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk); -void tdDestroyTiers(); +int tdInitMount(SDiskCfg *pDiskCfg, int ndisk); +void tdDestroyMount(); int tdUpdateDiskInfos(); void tdGetPrimaryPath(char *dst); diff --git a/src/common/src/tdisk.c b/src/common/src/tdisk.c index 2478b4ddd992ef53d845e0263c69dce212b254ce..51d47e6601c13eab7835819f5e3ce172db29ffce 100644 --- a/src/common/src/tdisk.c +++ b/src/common/src/tdisk.c @@ -62,7 +62,7 @@ typedef struct STiers { static struct STiers tdTiers; static struct STiers *pTiers = &tdTiers; -int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk) { +int tdInitMount(SDiskCfg *pDiskCfg, int ndisk) { ASSERT(ndisk > 0); memset((void *)pTiers, 0, sizeof(*pTiers)); @@ -77,26 +77,26 @@ int tdInitTiers(SDiskCfg *pDiskCfg, int ndisk) { taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (pTiers->map == NULL) { terrno = TSDB_CODE_COM_OUT_OF_MEMORY; - tdDestroyTiers(); + tdDestroyMount(); return -1; } for (int idisk = 0; idisk < ndisk; idisk++) { if (tdAddDisk(pDiskCfg + idisk) < 0) { - tdDestroyTiers(); + tdDestroyMount(); return -1; } } if (tdCheckTiers() < 0) { - tdDestroyTiers(); + tdDestroyMount(); return -1; } return 0; } -void tdDestroyTiers() { +void tdDestroyMount() { taosHashCleanup(pTiers->map); pTiers->map = NULL; @@ -144,13 +144,13 @@ static SDisk *tdGetPrimaryDisk() { return DISK_AT(0, 0); } static int tdCheckTiers() { ASSERT(pTiers->nLevel > 0); if (tdGetPrimaryDisk(pTiers) == NULL) { - terrno = TSDB_CODE_DND_LACK_PRIMARY_DISK; + terrno = TSDB_CODE_COM_LACK_PRIMARY_DISK; return -1; } for (int i = 0; i < pTiers->nLevel; i++) { if (pTiers->tiers[i].nDisks == 0) { - terrno = TSDB_CODE_DND_NO_DISK_AT_TIER; + terrno = TSDB_CODE_COM_NO_DISK_AT_TIER; return -1; } } @@ -179,7 +179,7 @@ static SDisk *tdAssignDisk(int level) { } if (pDisk == NULL) { - terrno = TSDB_CODE_DND_NO_DISK_SPACE; + terrno = TSDB_CODE_COM_NO_DISK_SPACE; tdUnLockTiers(pTiers); return NULL; } @@ -266,7 +266,7 @@ static int tdCheckDisk(char *dirName) { if (S_ISDIR(pstat.st_mode)) { return 0; } else { - terrno = TSDB_CODE_DND_DISK_NOT_DIRECTORY; + terrno = TSDB_CODE_COM_DISK_NOT_DIRECTORY; return -1; } } @@ -292,7 +292,7 @@ static int tdAddDisk(SDiskCfg *pCfg) { SDisk * pDisk = NULL; if (pCfg->level < 0 || pCfg->level >= TSDB_MAX_TIERS) { - terrno = TSDB_CODE_DND_INVALID_DISK_TIER; + terrno = TSDB_CODE_COM_INVALID_DISK_TIER; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } @@ -306,13 +306,13 @@ static int tdAddDisk(SDiskCfg *pCfg) { diskid.level = pCfg->level; if (pTier->nDisks >= TSDB_MAX_DISKS_PER_TIER) { - terrno = TSDB_CODE_DND_TOO_MANY_DISKS; + terrno = TSDB_CODE_COM_TOO_MANY_DISKS; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } if (tdGetDiskByName(dirName) != NULL) { - terrno = TSDB_CODE_DND_DISK_ALREADY_EXISTS; + terrno = TSDB_CODE_COM_DISK_ALREADY_EXISTS; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } @@ -324,13 +324,13 @@ static int tdAddDisk(SDiskCfg *pCfg) { if (pCfg->primary) { if (pCfg->level != 0) { - terrno = TSDB_CODE_DND_INVALID_DISK_TIER; + terrno = TSDB_CODE_COM_INVALID_DISK_TIER; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } if (tdGetPrimaryDisk() != NULL) { - terrno = TSDB_CODE_DND_DUPLICATE_PRIMARY_DISK; + terrno = TSDB_CODE_COM_DUPLICATE_PRIMARY_DISK; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } @@ -343,7 +343,7 @@ static int tdAddDisk(SDiskCfg *pCfg) { } else { diskid.did = pTier->nDisks + 1; if (diskid.did >= TSDB_MAX_DISKS_PER_TIER) { - terrno = TSDB_CODE_DND_TOO_MANY_DISKS; + terrno = TSDB_CODE_COM_TOO_MANY_DISKS; uError("failed to add disk %s to tier %d level since %s", pCfg->dir, pCfg->level, tstrerror(terrno)); return -1; } diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 5e4136bd8c3fc8f8294aee72eff1a3fbf73d471b..d96b0fe25cc319c9eba134b080ab5b6885091e93 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -183,7 +183,7 @@ static void dnodeCheckDataDirOpenned(char *dir) { } static int32_t dnodeInitStorage() { - if (tdInitTiers(tsDiskCfg, tsDiskCfgNum) < 0) { + if (tdInitMount(tsDiskCfg, tsDiskCfgNum) < 0) { dError("failed to add disks to dnode tier since %s", tstrerror(terrno)); return -1; } @@ -230,7 +230,7 @@ static int32_t dnodeInitStorage() { return 0; } -static void dnodeCleanupStorage() { tdDestroyTiers(); } +static void dnodeCleanupStorage() { tdDestroyMount(); } bool dnodeIsFirstDeploy() { return strcmp(tsFirst, tsLocalEp) == 0; diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 01bf0808051204a8e03d1c6d0529cbd975ebb530..3f88ec486ac89868cee33ede7ebfe7e8654a0b86 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -80,6 +80,14 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, 0, 0x0107, "Ref ID is TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, 0, 0x0108, "Invalid Ref ID") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, 0, 0x0109, "Ref is already there") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, 0, 0x010A, "Ref is not there") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_INVALID_DISK_TIER, 0, 0x010B, "Invalid disk tier setting") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_TOO_MANY_DISKS, 0, 0x010C, "Too many disks in one tier") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_DISK_ALREADY_EXISTS, 0, 0x010D, "Disk already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_DISK_NOT_DIRECTORY, 0, 0x010E, "Disk is not a directory") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_NO_DISK_SPACE, 0, 0x010F, "Dnode no disk space") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_DUPLICATE_PRIMARY_DISK, 0, 0x0110, "Duplicate primary disk") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_LACK_PRIMARY_DISK, 0, 0x0111, "Lack primary disk") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_NO_DISK_AT_TIER, 0, 0x0112, "No disk at tier") //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_SQL, 0, 0x0200, "Invalid SQL statement") @@ -188,14 +196,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message no TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "Dnode out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "No permission for disk files in dnode") TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "Invalid message length") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_DISK_TIER, 0, 0x0404, "Invalid disk tier setting") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_TOO_MANY_DISKS, 0, 0x0405, "Too many disks in one tier") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_ALREADY_EXISTS, 0, 0x0406, "Disk already exists") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_DISK_NOT_DIRECTORY, 0, 0x0407, "Disk is not a directory") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_SPACE, 0, 0x0408, "Dnode no disk space") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_DUPLICATE_PRIMARY_DISK, 0, 0x0409, "Duplicate primary disk") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_LACK_PRIMARY_DISK, 0, 0x040A, "Lack primary disk") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_DISK_AT_TIER, 0, 0x040B, "No disk at tier") // vnode TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress")