add more description for config item: reserved_storage_space
parent
bd79b4d35b
commit
f1ab599f16
|
|
@ -100,7 +100,12 @@ download_server = 0
|
||||||
### M or m for megabyte(MB)
|
### M or m for megabyte(MB)
|
||||||
### K or k for kilobyte(KB)
|
### K or k for kilobyte(KB)
|
||||||
### no unit for byte(B)
|
### no unit for byte(B)
|
||||||
|
#
|
||||||
### XX.XX% as ratio such as: reserved_storage_space = 10%
|
### XX.XX% as ratio such as: reserved_storage_space = 10%
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
## the absolute reserved space is the sum of all store paths in the storage server
|
||||||
|
## the reserved space ratio is for each store path
|
||||||
reserved_storage_space = 20%
|
reserved_storage_space = 20%
|
||||||
|
|
||||||
#standard log level as syslog, case insensitive, value list:
|
#standard log level as syslog, case insensitive, value list:
|
||||||
|
|
|
||||||
|
|
@ -203,19 +203,19 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
||||||
char *pReservedSpaceStr;
|
char *pReservedSpaceStr;
|
||||||
int64_t storage_reserved;
|
int64_t storage_reserved;
|
||||||
|
|
||||||
pReservedSpaceStr = iniGetStrValue(NULL, \
|
pReservedSpaceStr = iniGetStrValue(NULL,
|
||||||
"reserved_storage_space", pIniContext);
|
"reserved_storage_space", pIniContext);
|
||||||
if (pReservedSpaceStr == NULL)
|
if (pReservedSpaceStr == NULL)
|
||||||
{
|
{
|
||||||
pStorageReservedSpace->flag = \
|
pStorageReservedSpace->flag =
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB;
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB;
|
||||||
pStorageReservedSpace->rs.mb = FDFS_DEF_STORAGE_RESERVED_MB;
|
pStorageReservedSpace->rs.mb = FDFS_DEF_STORAGE_RESERVED_MB;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*pReservedSpaceStr == '\0')
|
if (*pReservedSpaceStr == '\0')
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"item \"reserved_storage_space\" is empty!", \
|
"item \"reserved_storage_space\" is empty!",
|
||||||
__LINE__);
|
__LINE__);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -227,24 +227,22 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
||||||
pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO;
|
pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO;
|
||||||
endptr = NULL;
|
endptr = NULL;
|
||||||
*(pReservedSpaceStr + len - 1) = '\0';
|
*(pReservedSpaceStr + len - 1) = '\0';
|
||||||
pStorageReservedSpace->rs.ratio = \
|
pStorageReservedSpace->rs.ratio =
|
||||||
strtod(pReservedSpaceStr, &endptr);
|
strtod(pReservedSpaceStr, &endptr);
|
||||||
if (endptr != NULL && *endptr != '\0')
|
if (endptr != NULL && *endptr != '\0')
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"item \"reserved_storage_space\": %s%%"\
|
"item \"reserved_storage_space\": %s%%"
|
||||||
" is invalid!", __LINE__, \
|
" is invalid!", __LINE__, pReservedSpaceStr);
|
||||||
pReservedSpaceStr);
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStorageReservedSpace->rs.ratio <= 0.00 || \
|
if (pStorageReservedSpace->rs.ratio <= 0.00 ||
|
||||||
pStorageReservedSpace->rs.ratio >= 100.00)
|
pStorageReservedSpace->rs.ratio >= 100.00)
|
||||||
{
|
{
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, "
|
||||||
"item \"reserved_storage_space\": %s%%"\
|
"item \"reserved_storage_space\": %s%%"
|
||||||
" is invalid!", __LINE__, \
|
" is invalid!", __LINE__, pReservedSpaceStr);
|
||||||
pReservedSpaceStr);
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,7 +310,7 @@ int64_t fdfs_get_storage_reserved_space_mb(const int64_t total_mb,
|
||||||
bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag == \
|
if (pStorageReservedSpace->flag ==
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return pGroup->free_mb > pStorageReservedSpace->rs.mb;
|
return pGroup->free_mb > pStorageReservedSpace->rs.mb;
|
||||||
|
|
@ -330,7 +328,7 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
pStorageReservedSpace->rs.ratio);
|
pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)pGroup->free_mb / (double)pGroup->total_mb) > \
|
return ((double)pGroup->free_mb / (double)pGroup->total_mb) >
|
||||||
pStorageReservedSpace->rs.ratio;
|
pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -338,12 +336,12 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
||||||
bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag == \
|
if (pStorageReservedSpace->flag ==
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return (pGroup->free_mb + pGroup->trunk_free_mb >
|
return (pGroup->free_mb + pGroup->trunk_free_mb >
|
||||||
pStorageReservedSpace->rs.mb);
|
pStorageReservedSpace->rs.mb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pGroup->total_mb == 0)
|
if (pGroup->total_mb == 0)
|
||||||
|
|
@ -353,20 +351,20 @@ bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("storage trunk=%.4f, rs.ratio=%.4f",
|
logInfo("storage trunk=%.4f, rs.ratio=%.4f",
|
||||||
((double)(pGroup->free_mb + pGroup->trunk_free_mb) / \
|
((double)(pGroup->free_mb + pGroup->trunk_free_mb) /
|
||||||
(double)pGroup->total_mb), pStorageReservedSpace->rs.ratio);
|
(double)pGroup->total_mb), pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)(pGroup->free_mb + pGroup->trunk_free_mb) / \
|
return ((double)(pGroup->free_mb + pGroup->trunk_free_mb) /
|
||||||
(double)pGroup->total_mb) > pStorageReservedSpace->rs.ratio;
|
(double)pGroup->total_mb) > pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fdfs_check_reserved_space_path(const int64_t total_mb, \
|
bool fdfs_check_reserved_space_path(const int64_t total_mb,
|
||||||
const int64_t free_mb, const int64_t avg_mb, \
|
const int64_t free_mb, const int64_t avg_mb,
|
||||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||||
{
|
{
|
||||||
if (pStorageReservedSpace->flag == \
|
if (pStorageReservedSpace->flag ==
|
||||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||||
{
|
{
|
||||||
return free_mb > avg_mb;
|
return free_mb > avg_mb;
|
||||||
|
|
@ -379,14 +377,14 @@ bool fdfs_check_reserved_space_path(const int64_t total_mb, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
logInfo("storage path, free_mb=%"PRId64 \
|
logInfo("storage path, free_mb=%"PRId64
|
||||||
", total_mb=%"PRId64", " \
|
", total_mb=%"PRId64", "
|
||||||
"real ratio=%.4f, rs.ratio=%.4f", \
|
"real ratio=%.4f, rs.ratio=%.4f",
|
||||||
free_mb, total_mb, ((double)free_mb / total_mb), \
|
free_mb, total_mb, ((double)free_mb / total_mb),
|
||||||
pStorageReservedSpace->rs.ratio);
|
pStorageReservedSpace->rs.ratio);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return ((double)free_mb / (double)total_mb) > \
|
return ((double)free_mb / (double)total_mb) >
|
||||||
pStorageReservedSpace->rs.ratio;
|
pStorageReservedSpace->rs.ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2551,9 +2551,9 @@ static int tracker_deal_service_query_storage( \
|
||||||
if (pStoreGroup == NULL)
|
if (pStoreGroup == NULL)
|
||||||
{
|
{
|
||||||
FDFSGroupInfo **ppGroupEnd;
|
FDFSGroupInfo **ppGroupEnd;
|
||||||
ppGroupEnd = g_groups.sorted_groups + \
|
ppGroupEnd = g_groups.sorted_groups +
|
||||||
g_groups.count;
|
g_groups.count;
|
||||||
for (ppGroup=ppFoundGroup+1; \
|
for (ppGroup=ppFoundGroup+1;
|
||||||
ppGroup<ppGroupEnd; ppGroup++)
|
ppGroup<ppGroupEnd; ppGroup++)
|
||||||
{
|
{
|
||||||
if ((*ppGroup)->active_count == 0)
|
if ((*ppGroup)->active_count == 0)
|
||||||
|
|
@ -2565,7 +2565,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
if (tracker_check_reserved_space(*ppGroup))
|
if (tracker_check_reserved_space(*ppGroup))
|
||||||
{
|
{
|
||||||
pStoreGroup = *ppGroup;
|
pStoreGroup = *ppGroup;
|
||||||
g_groups.current_write_group = \
|
g_groups.current_write_group =
|
||||||
ppGroup-g_groups.sorted_groups;
|
ppGroup-g_groups.sorted_groups;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2573,7 +2573,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
|
|
||||||
if (pStoreGroup == NULL)
|
if (pStoreGroup == NULL)
|
||||||
{
|
{
|
||||||
for (ppGroup=g_groups.sorted_groups; \
|
for (ppGroup=g_groups.sorted_groups;
|
||||||
ppGroup<ppFoundGroup; ppGroup++)
|
ppGroup<ppFoundGroup; ppGroup++)
|
||||||
{
|
{
|
||||||
if ((*ppGroup)->active_count == 0)
|
if ((*ppGroup)->active_count == 0)
|
||||||
|
|
@ -2585,7 +2585,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
if (tracker_check_reserved_space(*ppGroup))
|
if (tracker_check_reserved_space(*ppGroup))
|
||||||
{
|
{
|
||||||
pStoreGroup = *ppGroup;
|
pStoreGroup = *ppGroup;
|
||||||
g_groups.current_write_group = \
|
g_groups.current_write_group =
|
||||||
ppGroup-g_groups.sorted_groups;
|
ppGroup-g_groups.sorted_groups;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2606,7 +2606,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ppGroup=g_groups.sorted_groups; \
|
for (ppGroup=g_groups.sorted_groups;
|
||||||
ppGroup<ppGroupEnd; ppGroup++)
|
ppGroup<ppGroupEnd; ppGroup++)
|
||||||
{
|
{
|
||||||
if ((*ppGroup)->active_count == 0)
|
if ((*ppGroup)->active_count == 0)
|
||||||
|
|
@ -2616,7 +2616,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
if (tracker_check_reserved_space_trunk(*ppGroup))
|
if (tracker_check_reserved_space_trunk(*ppGroup))
|
||||||
{
|
{
|
||||||
pStoreGroup = *ppGroup;
|
pStoreGroup = *ppGroup;
|
||||||
g_groups.current_write_group = \
|
g_groups.current_write_group =
|
||||||
ppGroup-g_groups.sorted_groups;
|
ppGroup-g_groups.sorted_groups;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2641,7 +2641,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
}
|
}
|
||||||
else if (g_groups.store_lookup == FDFS_STORE_LOOKUP_SPEC_GROUP)
|
else if (g_groups.store_lookup == FDFS_STORE_LOOKUP_SPEC_GROUP)
|
||||||
{
|
{
|
||||||
if (g_groups.pStoreGroup == NULL || \
|
if (g_groups.pStoreGroup == NULL ||
|
||||||
g_groups.pStoreGroup->active_count == 0)
|
g_groups.pStoreGroup->active_count == 0)
|
||||||
{
|
{
|
||||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||||
|
|
@ -2650,8 +2650,8 @@ static int tracker_deal_service_query_storage( \
|
||||||
|
|
||||||
if (!tracker_check_reserved_space(g_groups.pStoreGroup))
|
if (!tracker_check_reserved_space(g_groups.pStoreGroup))
|
||||||
{
|
{
|
||||||
if (!(g_if_use_trunk_file && \
|
if (!(g_if_use_trunk_file &&
|
||||||
tracker_check_reserved_space_trunk( \
|
tracker_check_reserved_space_trunk(
|
||||||
g_groups.pStoreGroup)))
|
g_groups.pStoreGroup)))
|
||||||
{
|
{
|
||||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||||
|
|
@ -2755,7 +2755,7 @@ static int tracker_deal_service_query_storage( \
|
||||||
if (g_groups.store_path == FDFS_STORE_PATH_ROUND_ROBIN)
|
if (g_groups.store_path == FDFS_STORE_PATH_ROUND_ROBIN)
|
||||||
{
|
{
|
||||||
pStorageServer->current_write_path++;
|
pStorageServer->current_write_path++;
|
||||||
if (pStorageServer->current_write_path >= \
|
if (pStorageServer->current_write_path >=
|
||||||
pStoreGroup->store_path_count)
|
pStoreGroup->store_path_count)
|
||||||
{
|
{
|
||||||
pStorageServer->current_write_path = 0;
|
pStorageServer->current_write_path = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue