Skip to contentSkip to conversation

bug introduced by "block: Move throttling fields from BDS to BB"

Qemu-devel Paolo Bonzini 3 participants 4 messages Oct 14, 2016 – Oct 17, 2016

lore
Share & tools
lore
#0 lore raw

Here is next_throttle_token:

- ThrottleGroup *tg = container_of(blk_bs(blk)->throttle_state,
- ThrottleGroup, ts);
+ BlockBackendPublic *blkp = blk_get_public(blk);

+    ThrottleGroup *tg = container_of(blkp->throttle_state, ThrottleGroup, ts);
     BlockBackend *token, *start;
 
     start = token = tg->tokens[is_write];
 
     /* get next bs round in round robin style */
     token = throttle_group_next_blk(token);
-    while (token != start && !blk_bs(token)->pending_reqs[is_write]) {
+    while (token != start && !blkp->pending_reqs[is_write]) {
         token = throttle_group_next_blk(token);
     }

blkp isn't updated every time token is updated.

The same bug occurs in schedule_next_request. This patch was only in 2.7.x.

Thanks,

Paolo

#1 lore raw
Quoted 16 lines · Paolo Bonzini
(quoted diff) +3 -3
-    ThrottleGroup *tg = container_of(blk_bs(blk)->throttle_state,
-                                     ThrottleGroup, ts);
+    BlockBackendPublic *blkp = blk_get_public(blk);
+    ThrottleGroup *tg = container_of(blkp->throttle_state, ThrottleGroup, ts);
     BlockBackend *token, *start;
 
     start = token = tg->tokens[is_write];
 
     /* get next bs round in round robin style */
     token = throttle_group_next_blk(token);
-    while (token != start && !blk_bs(token)->pending_reqs[is_write]) {
+    while (token != start && !blkp->pending_reqs[is_write]) {
         token = throttle_group_next_blk(token);
     }
Quoted 1 line

blkp isn't updated every time token is updated.

BTW, the simplest fix is probably to introduce a function

static inline bool blk_has_pending_reqs(BlockBackend *blk,
bool is_write)

Paolo

#2 lore raw
In reply to Paolo Bonzini
Quoted 18 lines · Paolo Bonzini

Here is next_throttle_token:

(quoted diff) +3 -3
-    ThrottleGroup *tg = container_of(blk_bs(blk)->throttle_state,
-                                     ThrottleGroup, ts);
+    BlockBackendPublic *blkp = blk_get_public(blk);
+    ThrottleGroup *tg = container_of(blkp->throttle_state, ThrottleGroup, ts);
     BlockBackend *token, *start;
 
     start = token = tg->tokens[is_write];
 
     /* get next bs round in round robin style */
     token = throttle_group_next_blk(token);
-    while (token != start && !blk_bs(token)->pending_reqs[is_write]) {
+    while (token != start && !blkp->pending_reqs[is_write]) {
         token = throttle_group_next_blk(token);
     }
Quoted 1 line

blkp isn't updated every time token is updated.

You're right, I'll write a patch. I'd also try to check why this was not detected by any iotest.

Thanks!

Berto

#3 lore raw

Am 17.10.2016 um 10:49 hat Alberto Garcia geschrieben:

Quoted 19 lines · Paolo Bonzini
Quoted 18 lines

Here is next_throttle_token:

(quoted diff) +3 -3
-    ThrottleGroup *tg = container_of(blk_bs(blk)->throttle_state,
-                                     ThrottleGroup, ts);
+    BlockBackendPublic *blkp = blk_get_public(blk);
+    ThrottleGroup *tg = container_of(blkp->throttle_state, ThrottleGroup, ts);
     BlockBackend *token, *start;
 
     start = token = tg->tokens[is_write];
 
     /* get next bs round in round robin style */
     token = throttle_group_next_blk(token);
-    while (token != start && !blk_bs(token)->pending_reqs[is_write]) {
+    while (token != start && !blkp->pending_reqs[is_write]) {
         token = throttle_group_next_blk(token);
     }
Quoted 6 lines
Quoted 1 line

blkp isn't updated every time token is updated.

You're right, I'll write a patch. I'd also try to check why this was not detected by any iotest.

Thanks!

Thanks a lot, Berto! (Both for fixing my bug and thinking of test cases)

Kevin