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)
|
||||
### K or k for kilobyte(KB)
|
||||
### no unit for byte(B)
|
||||
#
|
||||
### 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%
|
||||
|
||||
#standard log level as syslog, case insensitive, value list:
|
||||
|
|
|
|||
|
|
@ -203,19 +203,19 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
|||
char *pReservedSpaceStr;
|
||||
int64_t storage_reserved;
|
||||
|
||||
pReservedSpaceStr = iniGetStrValue(NULL, \
|
||||
pReservedSpaceStr = iniGetStrValue(NULL,
|
||||
"reserved_storage_space", pIniContext);
|
||||
if (pReservedSpaceStr == NULL)
|
||||
{
|
||||
pStorageReservedSpace->flag = \
|
||||
pStorageReservedSpace->flag =
|
||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB;
|
||||
pStorageReservedSpace->rs.mb = FDFS_DEF_STORAGE_RESERVED_MB;
|
||||
return 0;
|
||||
}
|
||||
if (*pReservedSpaceStr == '\0')
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"reserved_storage_space\" is empty!", \
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"item \"reserved_storage_space\" is empty!",
|
||||
__LINE__);
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
@ -227,24 +227,22 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext,
|
|||
pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO;
|
||||
endptr = NULL;
|
||||
*(pReservedSpaceStr + len - 1) = '\0';
|
||||
pStorageReservedSpace->rs.ratio = \
|
||||
pStorageReservedSpace->rs.ratio =
|
||||
strtod(pReservedSpaceStr, &endptr);
|
||||
if (endptr != NULL && *endptr != '\0')
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"reserved_storage_space\": %s%%"\
|
||||
" is invalid!", __LINE__, \
|
||||
pReservedSpaceStr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"item \"reserved_storage_space\": %s%%"
|
||||
" is invalid!", __LINE__, pReservedSpaceStr);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (pStorageReservedSpace->rs.ratio <= 0.00 || \
|
||||
if (pStorageReservedSpace->rs.ratio <= 0.00 ||
|
||||
pStorageReservedSpace->rs.ratio >= 100.00)
|
||||
{
|
||||
logError("file: "__FILE__", line: %d, " \
|
||||
"item \"reserved_storage_space\": %s%%"\
|
||||
" is invalid!", __LINE__, \
|
||||
pReservedSpaceStr);
|
||||
logError("file: "__FILE__", line: %d, "
|
||||
"item \"reserved_storage_space\": %s%%"
|
||||
" is invalid!", __LINE__, pReservedSpaceStr);
|
||||
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, \
|
||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||
{
|
||||
if (pStorageReservedSpace->flag == \
|
||||
if (pStorageReservedSpace->flag ==
|
||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||
{
|
||||
return pGroup->free_mb > pStorageReservedSpace->rs.mb;
|
||||
|
|
@ -330,7 +328,7 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
|||
pStorageReservedSpace->rs.ratio);
|
||||
*/
|
||||
|
||||
return ((double)pGroup->free_mb / (double)pGroup->total_mb) > \
|
||||
return ((double)pGroup->free_mb / (double)pGroup->total_mb) >
|
||||
pStorageReservedSpace->rs.ratio;
|
||||
}
|
||||
}
|
||||
|
|
@ -338,7 +336,7 @@ bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \
|
|||
bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||
{
|
||||
if (pStorageReservedSpace->flag == \
|
||||
if (pStorageReservedSpace->flag ==
|
||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB)
|
||||
{
|
||||
return (pGroup->free_mb + pGroup->trunk_free_mb >
|
||||
|
|
@ -353,20 +351,20 @@ bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \
|
|||
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
bool fdfs_check_reserved_space_path(const int64_t total_mb, \
|
||||
const int64_t free_mb, const int64_t avg_mb, \
|
||||
bool fdfs_check_reserved_space_path(const int64_t total_mb,
|
||||
const int64_t free_mb, const int64_t avg_mb,
|
||||
FDFSStorageReservedSpace *pStorageReservedSpace)
|
||||
{
|
||||
if (pStorageReservedSpace->flag == \
|
||||
if (pStorageReservedSpace->flag ==
|
||||
TRACKER_STORAGE_RESERVED_SPACE_FLAG_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 \
|
||||
", total_mb=%"PRId64", " \
|
||||
"real ratio=%.4f, rs.ratio=%.4f", \
|
||||
free_mb, total_mb, ((double)free_mb / total_mb), \
|
||||
logInfo("storage path, free_mb=%"PRId64
|
||||
", total_mb=%"PRId64", "
|
||||
"real ratio=%.4f, rs.ratio=%.4f",
|
||||
free_mb, total_mb, ((double)free_mb / total_mb),
|
||||
pStorageReservedSpace->rs.ratio);
|
||||
*/
|
||||
|
||||
return ((double)free_mb / (double)total_mb) > \
|
||||
return ((double)free_mb / (double)total_mb) >
|
||||
pStorageReservedSpace->rs.ratio;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2551,9 +2551,9 @@ static int tracker_deal_service_query_storage( \
|
|||
if (pStoreGroup == NULL)
|
||||
{
|
||||
FDFSGroupInfo **ppGroupEnd;
|
||||
ppGroupEnd = g_groups.sorted_groups + \
|
||||
ppGroupEnd = g_groups.sorted_groups +
|
||||
g_groups.count;
|
||||
for (ppGroup=ppFoundGroup+1; \
|
||||
for (ppGroup=ppFoundGroup+1;
|
||||
ppGroup<ppGroupEnd; ppGroup++)
|
||||
{
|
||||
if ((*ppGroup)->active_count == 0)
|
||||
|
|
@ -2565,7 +2565,7 @@ static int tracker_deal_service_query_storage( \
|
|||
if (tracker_check_reserved_space(*ppGroup))
|
||||
{
|
||||
pStoreGroup = *ppGroup;
|
||||
g_groups.current_write_group = \
|
||||
g_groups.current_write_group =
|
||||
ppGroup-g_groups.sorted_groups;
|
||||
break;
|
||||
}
|
||||
|
|
@ -2573,7 +2573,7 @@ static int tracker_deal_service_query_storage( \
|
|||
|
||||
if (pStoreGroup == NULL)
|
||||
{
|
||||
for (ppGroup=g_groups.sorted_groups; \
|
||||
for (ppGroup=g_groups.sorted_groups;
|
||||
ppGroup<ppFoundGroup; ppGroup++)
|
||||
{
|
||||
if ((*ppGroup)->active_count == 0)
|
||||
|
|
@ -2585,7 +2585,7 @@ static int tracker_deal_service_query_storage( \
|
|||
if (tracker_check_reserved_space(*ppGroup))
|
||||
{
|
||||
pStoreGroup = *ppGroup;
|
||||
g_groups.current_write_group = \
|
||||
g_groups.current_write_group =
|
||||
ppGroup-g_groups.sorted_groups;
|
||||
break;
|
||||
}
|
||||
|
|
@ -2606,7 +2606,7 @@ static int tracker_deal_service_query_storage( \
|
|||
return ENOSPC;
|
||||
}
|
||||
|
||||
for (ppGroup=g_groups.sorted_groups; \
|
||||
for (ppGroup=g_groups.sorted_groups;
|
||||
ppGroup<ppGroupEnd; ppGroup++)
|
||||
{
|
||||
if ((*ppGroup)->active_count == 0)
|
||||
|
|
@ -2616,7 +2616,7 @@ static int tracker_deal_service_query_storage( \
|
|||
if (tracker_check_reserved_space_trunk(*ppGroup))
|
||||
{
|
||||
pStoreGroup = *ppGroup;
|
||||
g_groups.current_write_group = \
|
||||
g_groups.current_write_group =
|
||||
ppGroup-g_groups.sorted_groups;
|
||||
break;
|
||||
}
|
||||
|
|
@ -2641,7 +2641,7 @@ static int tracker_deal_service_query_storage( \
|
|||
}
|
||||
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)
|
||||
{
|
||||
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 (!(g_if_use_trunk_file && \
|
||||
tracker_check_reserved_space_trunk( \
|
||||
if (!(g_if_use_trunk_file &&
|
||||
tracker_check_reserved_space_trunk(
|
||||
g_groups.pStoreGroup)))
|
||||
{
|
||||
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)
|
||||
{
|
||||
pStorageServer->current_write_path++;
|
||||
if (pStorageServer->current_write_path >= \
|
||||
if (pStorageServer->current_write_path >=
|
||||
pStoreGroup->store_path_count)
|
||||
{
|
||||
pStorageServer->current_write_path = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue