[PATCH 2/2] block/aio_task: assert `max_busy_tasks` is greater than 0

Stefano Garzarella posted 2 patches 4 years, 4 months ago
Maintainers: John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, Hanna Reitz <hreitz@redhat.com>
[PATCH 2/2] block/aio_task: assert `max_busy_tasks` is greater than 0
Posted by Stefano Garzarella 4 years, 4 months ago
All code in block/aio_task.c expects `max_busy_tasks` to always
be greater than 0.

Assert this condition during the AioTaskPool creation where
`max_busy_tasks` is set.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 block/aio_task.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/aio_task.c b/block/aio_task.c
index 88989fa248..9bd17ea2c1 100644
--- a/block/aio_task.c
+++ b/block/aio_task.c
@@ -98,6 +98,8 @@ AioTaskPool *coroutine_fn aio_task_pool_new(int max_busy_tasks)
 {
     AioTaskPool *pool = g_new0(AioTaskPool, 1);
 
+    assert(max_busy_tasks > 0);
+
     pool->main_co = qemu_coroutine_self();
     pool->max_busy_tasks = max_busy_tasks;
 
-- 
2.31.1


Re: [PATCH 2/2] block/aio_task: assert `max_busy_tasks` is greater than 0
Posted by Vladimir Sementsov-Ogievskiy 4 years, 4 months ago
10/5/21 19:11, Stefano Garzarella wrote:
> All code in block/aio_task.c expects `max_busy_tasks` to always
> be greater than 0.
> 
> Assert this condition during the AioTaskPool creation where
> `max_busy_tasks` is set.
> 
> Signed-off-by: Stefano Garzarella<sgarzare@redhat.com>


Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

-- 
Best regards,
Vladimir