multi path round robin more gracefully
parent
a90e6c681d
commit
219e6e5a1d
|
|
@ -1666,7 +1666,10 @@ void storage_service_destroy()
|
|||
|
||||
int storage_get_storage_path_index(int *store_path_index)
|
||||
{
|
||||
int i, t;
|
||||
int i;
|
||||
int start;
|
||||
int end;
|
||||
int index;
|
||||
|
||||
*store_path_index = g_store_path_index;
|
||||
if (g_store_path_mode == FDFS_STORE_PATH_LOAD_BALANCE)
|
||||
|
|
@ -1688,27 +1691,25 @@ int storage_get_storage_path_index(int *store_path_index)
|
|||
[*store_path_index].total_mb, g_fdfs_store_paths.paths \
|
||||
[*store_path_index].free_mb, g_avg_storage_reserved_mb))
|
||||
{
|
||||
t = g_store_path_index + 1;
|
||||
if (t >= g_fdfs_store_paths.count)
|
||||
{
|
||||
t = 0;
|
||||
}
|
||||
for (i=t; i<g_fdfs_store_paths.count; i++)
|
||||
{
|
||||
if (storage_check_reserved_space_path( \
|
||||
g_fdfs_store_paths.paths[i].total_mb, \
|
||||
g_fdfs_store_paths.paths[i].free_mb, \
|
||||
g_avg_storage_reserved_mb))
|
||||
{
|
||||
*store_path_index = i;
|
||||
g_store_path_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
start = (*store_path_index + 1) % g_fdfs_store_paths.count;
|
||||
end = start + g_fdfs_store_paths.count - 1;
|
||||
for (i=start; i<end; i++)
|
||||
{
|
||||
index = i % g_fdfs_store_paths.count;
|
||||
if (storage_check_reserved_space_path(
|
||||
g_fdfs_store_paths.paths[index].total_mb,
|
||||
g_fdfs_store_paths.paths[index].free_mb,
|
||||
g_avg_storage_reserved_mb))
|
||||
{
|
||||
*store_path_index = index;
|
||||
g_store_path_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == g_fdfs_store_paths.count)
|
||||
if (i == end)
|
||||
{
|
||||
return ENOSPC;
|
||||
return ENOSPC;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2677,32 +2677,34 @@ static int tracker_deal_service_query_storage( \
|
|||
write_path_index = 0;
|
||||
}
|
||||
|
||||
avg_reserved_mb = g_storage_reserved_space.rs.mb / \
|
||||
avg_reserved_mb = g_storage_reserved_space.rs.mb /
|
||||
pStoreGroup->store_path_count;
|
||||
if (!tracker_check_reserved_space_path(pStorageServer-> \
|
||||
path_total_mbs[write_path_index], pStorageServer-> \
|
||||
if (!tracker_check_reserved_space_path(pStorageServer->
|
||||
path_total_mbs[write_path_index], pStorageServer->
|
||||
path_free_mbs[write_path_index], avg_reserved_mb))
|
||||
{
|
||||
int i, t;
|
||||
t = write_path_index + 1;
|
||||
if (t >= pStoreGroup->store_path_count)
|
||||
{
|
||||
t = 0;
|
||||
}
|
||||
for (i=t; i<pStoreGroup->store_path_count; i++)
|
||||
{
|
||||
if (tracker_check_reserved_space_path( \
|
||||
pStorageServer->path_total_mbs[i], \
|
||||
pStorageServer->path_free_mbs[i], \
|
||||
avg_reserved_mb))
|
||||
{
|
||||
pStorageServer->current_write_path = i;
|
||||
write_path_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int i;
|
||||
int start;
|
||||
int end;
|
||||
int index;
|
||||
|
||||
if (i == pStoreGroup->store_path_count)
|
||||
start = (write_path_index + 1) % pStoreGroup->store_path_count;
|
||||
end = start + pStoreGroup->store_path_count - 1;
|
||||
for (i=start; i<end; i++)
|
||||
{
|
||||
index = i % pStoreGroup->store_path_count;
|
||||
if (tracker_check_reserved_space_path(
|
||||
pStorageServer->path_total_mbs[index],
|
||||
pStorageServer->path_free_mbs[index],
|
||||
avg_reserved_mb))
|
||||
{
|
||||
pStorageServer->current_write_path = index;
|
||||
write_path_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == end)
|
||||
{
|
||||
if (!g_if_use_trunk_file)
|
||||
{
|
||||
|
|
@ -2710,43 +2712,27 @@ static int tracker_deal_service_query_storage( \
|
|||
return ENOSPC;
|
||||
}
|
||||
|
||||
for (i=write_path_index; i<pStoreGroup-> \
|
||||
store_path_count; i++)
|
||||
start = write_path_index % pStoreGroup->store_path_count;
|
||||
end = start + pStoreGroup->store_path_count;
|
||||
for (i=start; i<end; i++)
|
||||
{
|
||||
if (tracker_check_reserved_space_path( \
|
||||
pStorageServer->path_total_mbs[i], \
|
||||
pStorageServer->path_free_mbs[i] + \
|
||||
pStoreGroup->trunk_free_mb, \
|
||||
avg_reserved_mb))
|
||||
{
|
||||
pStorageServer->current_write_path = i;
|
||||
write_path_index = i;
|
||||
index = i % pStoreGroup->store_path_count;
|
||||
if (tracker_check_reserved_space_path(
|
||||
pStorageServer->path_total_mbs[index],
|
||||
pStorageServer->path_free_mbs[index] +
|
||||
pStoreGroup->trunk_free_mb, avg_reserved_mb))
|
||||
{
|
||||
pStorageServer->current_write_path = index;
|
||||
write_path_index = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == pStoreGroup->store_path_count)
|
||||
{
|
||||
for (i=0; i<write_path_index; i++)
|
||||
{
|
||||
if (tracker_check_reserved_space_path( \
|
||||
pStorageServer->path_total_mbs[i], \
|
||||
pStorageServer->path_free_mbs[i] + \
|
||||
pStoreGroup->trunk_free_mb, \
|
||||
avg_reserved_mb))
|
||||
{
|
||||
pStorageServer->current_write_path = i;
|
||||
write_path_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == write_path_index)
|
||||
{
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return ENOSPC;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == end)
|
||||
{
|
||||
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||
return ENOSPC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_groups.store_path == FDFS_STORE_PATH_ROUND_ROBIN)
|
||||
|
|
|
|||
Loading…
Reference in New Issue