Skip to contentSkip to conversation

block: use 'unsigned' for in_flight field on driver state

PATCH Applied Denis V. Lunev 4 participants 6 messages May 30, 2022 – Jun 14, 2022 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: use 'unsigned' for in_flight field on driver state

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Eric Blake <[email protected]>
---
 block/mirror.c | 2 +-
 block/nbd.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
block/mirror.c +1 -1
index d8ecb9efa2..3c4ab1159d 100644
@@ -73,7 +73,7 @@ typedef struct MirrorBlockJob {
 
     uint64_t last_pause_ns;
     unsigned long *in_flight_bitmap;
-    int in_flight;
+    unsigned in_flight;
     int64_t bytes_in_flight;
     QTAILQ_HEAD(, MirrorOp) ops_in_flight;
     int ret;
block/nbd.c +1 -1
index 6085ab1d2c..512a53bf73 100644
@@ -77,7 +77,7 @@ typedef struct BDRVNBDState {
     QemuMutex requests_lock;
     NBDClientState state;
     CoQueue free_sema;
-    int in_flight;
+    unsigned in_flight;
     NBDClientRequest requests[MAX_NBD_REQUESTS];
     QEMUTimer *reconnect_delay_timer;
 
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Denis V. Lunev

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow<[email protected]>
CC Vladimir Sementsov-Ogievskiy<[email protected]>
CC Kevin Wolf<[email protected]>
CC Hanna Reitz<[email protected]>
CC Eric Blake<[email protected]>
Signature · 2 lines
Best regards,
Vladimir
#2 lore raw
In reply to Denis V. Lunev
Quoted 10 lines · Denis V. Lunev

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Eric Blake <[email protected]>
Quoted 4 lines
---
  block/mirror.c | 2 +-
  block/nbd.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

FWIW there is another occurrence in qemu-img.c.

#3 lore raw
In reply to Denis V. Lunev
Quoted 33 lines · Denis V. Lunev

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Eric Blake <[email protected]>
---
  block/mirror.c | 2 +-
  block/nbd.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
block/mirror.c +1 -1
index d8ecb9efa2..3c4ab1159d 100644
@@ -73,7 +73,7 @@ typedef struct MirrorBlockJob {
 
      uint64_t last_pause_ns;
      unsigned long *in_flight_bitmap;
-    int in_flight;
+    unsigned in_flight;
      int64_t bytes_in_flight;
      QTAILQ_HEAD(, MirrorOp) ops_in_flight;
      int ret;
block/nbd.c +0 -0
index 6085ab1d2c..512a53bf73 100644

block/nbd.c typedef struct BDRVNBDState { · line 83

Quoted 8 lines
block/nbd.c +1 -1
@@ -77,7 +77,7 @@ typedef struct BDRVNBDState {
      QemuMutex requests_lock;
      NBDClientState state;
      CoQueue free_sema;
-    int in_flight;
+    unsigned in_flight;
      NBDClientRequest requests[MAX_NBD_REQUESTS];
      QEMUTimer *reconnect_delay_timer;
 

ping

#4 lore raw
In reply to Denis V. Lunev
Quoted 33 lines · Denis V. Lunev

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Eric Blake <[email protected]>
---
  block/mirror.c | 2 +-
  block/nbd.c    | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
block/mirror.c +1 -1
index d8ecb9efa2..3c4ab1159d 100644
@@ -73,7 +73,7 @@ typedef struct MirrorBlockJob {
 
      uint64_t last_pause_ns;
      unsigned long *in_flight_bitmap;
-    int in_flight;
+    unsigned in_flight;
      int64_t bytes_in_flight;
      QTAILQ_HEAD(, MirrorOp) ops_in_flight;
      int ret;
block/nbd.c +0 -0
index 6085ab1d2c..512a53bf73 100644

block/nbd.c typedef struct BDRVNBDState { · line 83

Quoted 8 lines
block/nbd.c +1 -1
@@ -77,7 +77,7 @@ typedef struct BDRVNBDState {
      QemuMutex requests_lock;
      NBDClientState state;
      CoQueue free_sema;
-    int in_flight;
+    unsigned in_flight;
      NBDClientRequest requests[MAX_NBD_REQUESTS];
      QEMUTimer *reconnect_delay_timer;
 

ping v2

#5 lore raw
In reply to Denis V. Lunev
Quoted 10 lines · Denis V. Lunev

This patch makes in_flight field 'unsigned' for BDRVNBDState and MirrorBlockJob. This matches the definition of this field on BDS and is generically correct - we should never get negative value here.

CC John Snow<[email protected]>
CC Vladimir Sementsov-Ogievskiy<[email protected]>
CC Kevin Wolf<[email protected]>
CC Hanna Reitz<[email protected]>
CC Eric Blake<[email protected]>

Thanks, applied to my block branch at https://gitlab.com/vsementsov/qemu/-/commits/block

Signature · 2 lines
Best regards,
Vladimir