block-backend: fix double inc/dec inflight requests number
RFC 1/1 block-backend: fix double inc/dec inflight requests number
blk_co_preadv and blk_co_pwritev calls bdrv_inc_in_flight and bdrv_dec_in_flight. But they calls correspondingly bdrv_co_preadv and bdrv_co_pwritev, which inc/dec in-flight count by themselves. Counting in-flight requests in blk_ layer is redundant, drop it.
---
Hi all!
Is it a bug or a feature? Why do we call inc/dec twice for read/write? We don't do this for flush and discard..
(patch is called RFC, but it may be applied as is, if it is OK)
block/block-backend.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
block/block-backend.c +2 -9
@@ -1094,17 +1094,13 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,return ret; } -bdrv_inc_in_flight (bs); -/* throttling disk I/O */ if (blk->public.throttle_group_member.throttle_state) {throttle_group_co_io_limits_intercept (&blk->public.throttle_group_member, bytes, false); } - ret =bdrv_co_preadv (blk->root, offset, bytes, qiov, flags); -bdrv_dec_in_flight (bs); -return ret; +return bdrv_co_preadv (blk->root, offset, bytes, qiov, flags); } int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
@@ -1121,7 +1117,6 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,return ret; } -bdrv_inc_in_flight (bs);/* throttling disk I/O */ if (blk->public.throttle_group_member.throttle_state) { throttle_group_co_io_limits_intercept(&blk->public.throttle_group_member,
@@ -1132,9 +1127,7 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, flags |=BDRV_REQ_FUA ; } - ret =bdrv_co_pwritev (blk->root, offset, bytes, qiov, flags); -bdrv_dec_in_flight (bs); -return ret; +return bdrv_co_pwritev (blk->root, offset, bytes, qiov, flags); } typedef struct BlkRwCo {
Signature · 1 line
2.11.1
Quoted 2 lines · Vladimir Sementsov-Ogievskiy
Is it a bug or a feature? Why do we call inc/dec twice for read/write? We don't do this for flush and discard..
It's non-obvious and I asked Paolo the same question previously.
block/block-backend.c int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, · line 1101
Quoted 7 lines
block/block-backend.c +0
-2-bdrv_inc_in_flight (bs); -/* throttling disk I/O */ if (blk->public.throttle_group_member.throttle_state) {throttle_group_co_io_limits_intercept (&blk->public.throttle_group_member, bytes, false); }
^^^ HINT HINT HINT ^^^
block/block-backend.c int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, · line 1103
Quoted 5 lines
block/block-backend.c +1
-3- ret =bdrv_co_preadv (blk->root, offset, bytes, qiov, flags); -bdrv_dec_in_flight (bs); -return ret; +return bdrv_co_preadv (blk->root, offset, bytes, qiov, flags);
The problem is what happens if the request is throttled?
Even throttled requests must be counted so that bdrv_drain() and friends work.
It may be possible to eliminate this now that throttling is a BDS node. It used to be implemented as a completely separate API outside the BDS node graph. Now there is a throttling node in the graph, so maybe we can stop taking the extra reference but some refactoring may be necessary.
Stefan
Am 25.01.2018 um 12:37 hat Stefan Hajnoczi geschrieben:
Quoted 24 lines · Vladimir Sementsov-Ogievskiy
Quoted 2 lines
Is it a bug or a feature? Why do we call inc/dec twice for read/write? We don't do this for flush and discard..
It's non-obvious and I asked Paolo the same question previously.
block/block-backend.c int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, · line 1101
Quoted 7 lines
block/block-backend.c +0
-2-bdrv_inc_in_flight (bs); -/* throttling disk I/O */ if (blk->public.throttle_group_member.throttle_state) {throttle_group_co_io_limits_intercept (&blk->public.throttle_group_member, bytes, false); }^^^ HINT HINT HINT ^^^
block/block-backend.c int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, · line 1103
Quoted 5 lines
block/block-backend.c +1
-3- ret =bdrv_co_preadv (blk->root, offset, bytes, qiov, flags); -bdrv_dec_in_flight (bs); -return ret; +return bdrv_co_preadv (blk->root, offset, bytes, qiov, flags);The problem is what happens if the request is throttled?
Quoted 8 lines
Even throttled requests must be counted so that
bdrv_drain()and friends work.It may be possible to eliminate this now that throttling is a BDS node. It used to be implemented as a completely separate API outside the BDS node graph. Now there is a throttling node in the graph, so maybe we can stop taking the extra reference but some refactoring may be necessary.
The patches to use a throttling node even when the legacy options are used have not been merged yet.
Kevin