Skip to contentSkip to conversation

minor fixups in block code

PATCH Applied Denis V. Lunev 4 participants 8 messages Aug 17, 2022 – Sep 22, 2022 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minor fixups in block code

These 2 patches are just minor improvements to make code a bit better.

CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Ronnie Sahlberg <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Peter Lieven <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
#1 lore raw

PATCH 1/2 block: use bdrv_is_sg() helper instead of raw bs->sg reading

I believe that if the helper exists, it must be used always for reading of the value. It breaks expectations in the other case.

CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Ronnie Sahlberg <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Peter Lieven <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
---
 block/file-posix.c | 2 +-
 block/iscsi.c      | 2 +-
 block/raw-format.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
block/file-posix.c +1 -1
index 48cd096624..256de1f456 100644
@@ -1295,7 +1295,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
     }
 #endif
 
-    if (bs->sg || S_ISBLK(st.st_mode)) {
+    if (bdrv_is_sg(bs) || S_ISBLK(st.st_mode)) {
         int ret = hdev_get_max_hw_transfer(s->fd, &st);
 
         if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) {
block/iscsi.c +1 -1
index d707d0b354..612de127e5 100644
@@ -2065,7 +2065,7 @@ static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
     uint64_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;
     unsigned int block_size = MAX(BDRV_SECTOR_SIZE, iscsilun->block_size);
 
-    assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bs->sg);
+    assert(iscsilun->block_size >= BDRV_SECTOR_SIZE || bdrv_is_sg(bs));
 
     bs->bl.request_alignment = block_size;
 
block/raw-format.c +2 -2
index 69fd650eaf..c7278e348e 100644
@@ -463,7 +463,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
         return -EINVAL;
     }
 
-    bs->sg = bs->file->bs->sg;
+    bs->sg = bdrv_is_sg(bs->file->bs);
     bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
         (BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
     bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
@@ -489,7 +489,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
         return ret;
     }
 
-    if (bs->sg && (s->offset || s->has_size)) {
+    if (bdrv_is_sg(bs) && (s->offset || s->has_size)) {
         error_setg(errp, "Cannot use offset/size with SCSI generic devices");
         return -EINVAL;
     }
Signature · 1 line
2.32.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading

Quoted 12 lines · Denis V. Lunev

I believe that if the helper exists, it must be used always for reading of the value. It breaks expectations in the other case.

CC Kevin Wolf<[email protected]>
CC Hanna Reitz<[email protected]>
CC Stefan Hajnoczi<[email protected]>
CC Fam Zheng<[email protected]>
CC Ronnie Sahlberg<[email protected]>
CC Paolo Bonzini<[email protected]>
CC Peter Lieven<[email protected]>
CC Vladimir Sementsov-Ogievskiy<[email protected]>
Signature · 2 lines
Best regards,
Vladimir
#3 lore raw

PATCH 2/2 block: make serializing requests functions 'void'

In reply to Denis V. Lunev

Return codes of the following functions are never used in the code:
* bdrv_wait_serialising_requests_locked
* bdrv_wait_serialising_requests
* bdrv_make_request_serialising

CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Ronnie Sahlberg <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Peter Lieven <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
---
 block/io.c                   | 23 +++++++----------------
 include/block/block_int-io.h |  2 +-
 2 files changed, 8 insertions(+), 17 deletions(-)
block/io.c +7 -16
index 0a8cbefe86..51d8f943a4 100644
@@ -828,20 +828,16 @@ bdrv_find_conflicting_request(BdrvTrackedRequest *self)
 }
 
 /* Called with self->bs->reqs_lock held */
-static bool coroutine_fn
+static void coroutine_fn
 bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self)
 {
     BdrvTrackedRequest *req;
-    bool waited = false;
 
     while ((req = bdrv_find_conflicting_request(self))) {
         self->waiting_for = req;
         qemu_co_queue_wait(&req->wait_queue, &self->bs->reqs_lock);
         self->waiting_for = NULL;
-        waited = true;
     }
-
-    return waited;
 }
 
 /* Called with req->bs->reqs_lock held */
@@ -934,36 +930,31 @@ void bdrv_dec_in_flight(BlockDriverState *bs)
     bdrv_wakeup(bs);
 }
 
-static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self)
+static void coroutine_fn
+bdrv_wait_serialising_requests(BdrvTrackedRequest *self)
 {
     BlockDriverState *bs = self->bs;
-    bool waited = false;
 
     if (!qatomic_read(&bs->serialising_in_flight)) {
-        return false;
+        return;
     }
 
     qemu_co_mutex_lock(&bs->reqs_lock);
-    waited = bdrv_wait_serialising_requests_locked(self);
+    bdrv_wait_serialising_requests_locked(self);
     qemu_co_mutex_unlock(&bs->reqs_lock);
-
-    return waited;
 }
 
-bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
+void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
                                                 uint64_t align)
 {
-    bool waited;
     IO_CODE();
 
     qemu_co_mutex_lock(&req->bs->reqs_lock);
 
     tracked_request_set_serialising(req, align);
-    waited = bdrv_wait_serialising_requests_locked(req);
+    bdrv_wait_serialising_requests_locked(req);
 
     qemu_co_mutex_unlock(&req->bs->reqs_lock);
-
-    return waited;
 }
 
 int bdrv_check_qiov_request(int64_t offset, int64_t bytes,
include/block/block_int-io.h +1 -1
index 91cdd61692..4b0b3e17ef 100644
@@ -73,7 +73,7 @@ static inline int coroutine_fn bdrv_co_pwrite(BdrvChild *child,
     return bdrv_co_pwritev(child, offset, bytes, &qiov, flags);
 }
 
-bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
+void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
                                                 uint64_t align);
 BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs);
 
Signature · 1 line
2.32.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] block: make serializing requests functions 'void'

Quoted 5 lines · Denis V. Lunev

Return codes of the following functions are never used in the code:
* bdrv_wait_serialising_requests_locked
* bdrv_wait_serialising_requests
* bdrv_make_request_serialising

Quoted 9 lines
CC Kevin Wolf<[email protected]>
CC Hanna Reitz<[email protected]>
CC Stefan Hajnoczi<[email protected]>
CC Fam Zheng<[email protected]>
CC Ronnie Sahlberg<[email protected]>
CC Paolo Bonzini<[email protected]>
CC Peter Lieven<[email protected]>
CC Vladimir Sementsov-Ogievskiy<[email protected]>

Oh, good cleanup!

Signature · 2 lines
Best regards,
Vladimir
#5 lore raw
In reply to Denis V. Lunev
Quoted 13 lines · Denis V. Lunev

These 2 patches are just minor improvements to make code a bit better.

CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Ronnie Sahlberg <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Peter Lieven <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>

ping

#6 lore raw
In reply to Denis V. Lunev
Quoted 13 lines · Denis V. Lunev

These 2 patches are just minor improvements to make code a bit better.

CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Ronnie Sahlberg <[email protected]>
CC Paolo Bonzini <[email protected]>
CC Peter Lieven <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>

ping v2

Applied
#7 lore raw
In reply to Denis V. Lunev

Am 17.08.2022 um 10:37 hat Denis V. Lunev geschrieben:

Quoted 1 line

These 2 patches are just minor improvements to make code a bit better.

Thanks, applied to the block branch.

Kevin