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 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;
|
*store_path_index = g_store_path_index;
|
||||||
if (g_store_path_mode == FDFS_STORE_PATH_LOAD_BALANCE)
|
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].total_mb, g_fdfs_store_paths.paths \
|
||||||
[*store_path_index].free_mb, g_avg_storage_reserved_mb))
|
[*store_path_index].free_mb, g_avg_storage_reserved_mb))
|
||||||
{
|
{
|
||||||
t = g_store_path_index + 1;
|
start = (*store_path_index + 1) % g_fdfs_store_paths.count;
|
||||||
if (t >= g_fdfs_store_paths.count)
|
end = start + g_fdfs_store_paths.count - 1;
|
||||||
{
|
for (i=start; i<end; i++)
|
||||||
t = 0;
|
{
|
||||||
}
|
index = i % g_fdfs_store_paths.count;
|
||||||
for (i=t; i<g_fdfs_store_paths.count; i++)
|
if (storage_check_reserved_space_path(
|
||||||
{
|
g_fdfs_store_paths.paths[index].total_mb,
|
||||||
if (storage_check_reserved_space_path( \
|
g_fdfs_store_paths.paths[index].free_mb,
|
||||||
g_fdfs_store_paths.paths[i].total_mb, \
|
g_avg_storage_reserved_mb))
|
||||||
g_fdfs_store_paths.paths[i].free_mb, \
|
{
|
||||||
g_avg_storage_reserved_mb))
|
*store_path_index = index;
|
||||||
{
|
g_store_path_index = index;
|
||||||
*store_path_index = i;
|
break;
|
||||||
g_store_path_index = i;
|
}
|
||||||
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;
|
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;
|
pStoreGroup->store_path_count;
|
||||||
if (!tracker_check_reserved_space_path(pStorageServer-> \
|
if (!tracker_check_reserved_space_path(pStorageServer->
|
||||||
path_total_mbs[write_path_index], pStorageServer-> \
|
path_total_mbs[write_path_index], pStorageServer->
|
||||||
path_free_mbs[write_path_index], avg_reserved_mb))
|
path_free_mbs[write_path_index], avg_reserved_mb))
|
||||||
{
|
{
|
||||||
int i, t;
|
int i;
|
||||||
t = write_path_index + 1;
|
int start;
|
||||||
if (t >= pStoreGroup->store_path_count)
|
int end;
|
||||||
{
|
int index;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
if (!g_if_use_trunk_file)
|
||||||
{
|
{
|
||||||
|
|
@ -2710,43 +2712,27 @@ static int tracker_deal_service_query_storage( \
|
||||||
return ENOSPC;
|
return ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=write_path_index; i<pStoreGroup-> \
|
start = write_path_index % pStoreGroup->store_path_count;
|
||||||
store_path_count; i++)
|
end = start + pStoreGroup->store_path_count;
|
||||||
|
for (i=start; i<end; i++)
|
||||||
{
|
{
|
||||||
if (tracker_check_reserved_space_path( \
|
index = i % pStoreGroup->store_path_count;
|
||||||
pStorageServer->path_total_mbs[i], \
|
if (tracker_check_reserved_space_path(
|
||||||
pStorageServer->path_free_mbs[i] + \
|
pStorageServer->path_total_mbs[index],
|
||||||
pStoreGroup->trunk_free_mb, \
|
pStorageServer->path_free_mbs[index] +
|
||||||
avg_reserved_mb))
|
pStoreGroup->trunk_free_mb, avg_reserved_mb))
|
||||||
{
|
{
|
||||||
pStorageServer->current_write_path = i;
|
pStorageServer->current_write_path = index;
|
||||||
write_path_index = i;
|
write_path_index = index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( i == pStoreGroup->store_path_count)
|
if (i == end)
|
||||||
{
|
{
|
||||||
for (i=0; i<write_path_index; i++)
|
pTask->send.ptr->length = sizeof(TrackerHeader);
|
||||||
{
|
return ENOSPC;
|
||||||
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 (g_groups.store_path == FDFS_STORE_PATH_ROUND_ROBIN)
|
if (g_groups.store_path == FDFS_STORE_PATH_ROUND_ROBIN)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue