mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
block: move ThrottleGroup membership to ThrottleGroupMember
This commit eliminates the 1:1 relationship between BlockBackend and throttle group state. Users will be able to create multiple throttle nodes, each with its own throttle group state, in the future. The throttle group state cannot be per-BlockBackend anymore, it must be per-throttle node. This is done by gathering ThrottleGroup membership details from BlockBackendPublic into ThrottleGroupMember and refactoring existing code to use the structure. Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
64182a6b8b
commit
022cdc9f40
7 changed files with 252 additions and 226 deletions
|
@ -669,6 +669,7 @@ static void test_groups(void)
|
|||
ThrottleConfig cfg1, cfg2;
|
||||
BlockBackend *blk1, *blk2, *blk3;
|
||||
BlockBackendPublic *blkp1, *blkp2, *blkp3;
|
||||
ThrottleGroupMember *tgm1, *tgm2, *tgm3;
|
||||
|
||||
/* No actual I/O is performed on these devices */
|
||||
blk1 = blk_new(0, BLK_PERM_ALL);
|
||||
|
@ -679,21 +680,25 @@ static void test_groups(void)
|
|||
blkp2 = blk_get_public(blk2);
|
||||
blkp3 = blk_get_public(blk3);
|
||||
|
||||
g_assert(blkp1->throttle_state == NULL);
|
||||
g_assert(blkp2->throttle_state == NULL);
|
||||
g_assert(blkp3->throttle_state == NULL);
|
||||
tgm1 = &blkp1->throttle_group_member;
|
||||
tgm2 = &blkp2->throttle_group_member;
|
||||
tgm3 = &blkp3->throttle_group_member;
|
||||
|
||||
throttle_group_register_blk(blk1, "bar");
|
||||
throttle_group_register_blk(blk2, "foo");
|
||||
throttle_group_register_blk(blk3, "bar");
|
||||
g_assert(tgm1->throttle_state == NULL);
|
||||
g_assert(tgm2->throttle_state == NULL);
|
||||
g_assert(tgm3->throttle_state == NULL);
|
||||
|
||||
g_assert(blkp1->throttle_state != NULL);
|
||||
g_assert(blkp2->throttle_state != NULL);
|
||||
g_assert(blkp3->throttle_state != NULL);
|
||||
throttle_group_register_tgm(tgm1, "bar");
|
||||
throttle_group_register_tgm(tgm2, "foo");
|
||||
throttle_group_register_tgm(tgm3, "bar");
|
||||
|
||||
g_assert(!strcmp(throttle_group_get_name(blk1), "bar"));
|
||||
g_assert(!strcmp(throttle_group_get_name(blk2), "foo"));
|
||||
g_assert(blkp1->throttle_state == blkp3->throttle_state);
|
||||
g_assert(tgm1->throttle_state != NULL);
|
||||
g_assert(tgm2->throttle_state != NULL);
|
||||
g_assert(tgm3->throttle_state != NULL);
|
||||
|
||||
g_assert(!strcmp(throttle_group_get_name(tgm1), "bar"));
|
||||
g_assert(!strcmp(throttle_group_get_name(tgm2), "foo"));
|
||||
g_assert(tgm1->throttle_state == tgm3->throttle_state);
|
||||
|
||||
/* Setting the config of a group member affects the whole group */
|
||||
throttle_config_init(&cfg1);
|
||||
|
@ -701,29 +706,29 @@ static void test_groups(void)
|
|||
cfg1.buckets[THROTTLE_BPS_WRITE].avg = 285000;
|
||||
cfg1.buckets[THROTTLE_OPS_READ].avg = 20000;
|
||||
cfg1.buckets[THROTTLE_OPS_WRITE].avg = 12000;
|
||||
throttle_group_config(blk1, &cfg1);
|
||||
throttle_group_config(tgm1, &cfg1);
|
||||
|
||||
throttle_group_get_config(blk1, &cfg1);
|
||||
throttle_group_get_config(blk3, &cfg2);
|
||||
throttle_group_get_config(tgm1, &cfg1);
|
||||
throttle_group_get_config(tgm3, &cfg2);
|
||||
g_assert(!memcmp(&cfg1, &cfg2, sizeof(cfg1)));
|
||||
|
||||
cfg2.buckets[THROTTLE_BPS_READ].avg = 4547;
|
||||
cfg2.buckets[THROTTLE_BPS_WRITE].avg = 1349;
|
||||
cfg2.buckets[THROTTLE_OPS_READ].avg = 123;
|
||||
cfg2.buckets[THROTTLE_OPS_WRITE].avg = 86;
|
||||
throttle_group_config(blk3, &cfg1);
|
||||
throttle_group_config(tgm3, &cfg1);
|
||||
|
||||
throttle_group_get_config(blk1, &cfg1);
|
||||
throttle_group_get_config(blk3, &cfg2);
|
||||
throttle_group_get_config(tgm1, &cfg1);
|
||||
throttle_group_get_config(tgm3, &cfg2);
|
||||
g_assert(!memcmp(&cfg1, &cfg2, sizeof(cfg1)));
|
||||
|
||||
throttle_group_unregister_blk(blk1);
|
||||
throttle_group_unregister_blk(blk2);
|
||||
throttle_group_unregister_blk(blk3);
|
||||
throttle_group_unregister_tgm(tgm1);
|
||||
throttle_group_unregister_tgm(tgm2);
|
||||
throttle_group_unregister_tgm(tgm3);
|
||||
|
||||
g_assert(blkp1->throttle_state == NULL);
|
||||
g_assert(blkp2->throttle_state == NULL);
|
||||
g_assert(blkp3->throttle_state == NULL);
|
||||
g_assert(tgm1->throttle_state == NULL);
|
||||
g_assert(tgm2->throttle_state == NULL);
|
||||
g_assert(tgm3->throttle_state == NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue