qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for 7.2] minor fixups in block code
@ 2022-08-17  8:37 Denis V. Lunev
  2022-08-17  8:37 ` [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading Denis V. Lunev
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Denis V. Lunev @ 2022-08-17  8:37 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Denis V . Lunev, Kevin Wolf, Hanna Reitz, Stefan Hajnoczi,
	Fam Zheng, Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

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

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Peter Lieven <pl@kamp.de>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading
  2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
@ 2022-08-17  8:37 ` Denis V. Lunev
  2022-08-19 15:51   ` Vladimir Sementsov-Ogievskiy
  2022-08-17  8:37 ` [PATCH 2/2] block: make serializing requests functions 'void' Denis V. Lunev
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Denis V. Lunev @ 2022-08-17  8:37 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Denis V. Lunev, Kevin Wolf, Hanna Reitz, Stefan Hajnoczi,
	Fam Zheng, Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

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

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Peter Lieven <pl@kamp.de>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 block/file-posix.c | 2 +-
 block/iscsi.c      | 2 +-
 block/raw-format.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 48cd096624..256de1f456 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -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) {
diff --git a/block/iscsi.c b/block/iscsi.c
index d707d0b354..612de127e5 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -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;
 
diff --git a/block/raw-format.c b/block/raw-format.c
index 69fd650eaf..c7278e348e 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -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;
     }
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] block: make serializing requests functions 'void'
  2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
  2022-08-17  8:37 ` [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading Denis V. Lunev
@ 2022-08-17  8:37 ` Denis V. Lunev
  2022-08-19 15:54   ` Vladimir Sementsov-Ogievskiy
  2022-08-29 10:09 ` [PATCH for 7.2] minor fixups in block code Denis V. Lunev
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Denis V. Lunev @ 2022-08-17  8:37 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Denis V. Lunev, Kevin Wolf, Hanna Reitz, Stefan Hajnoczi,
	Fam Zheng, Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

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

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Fam Zheng <fam@euphon.net>
CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Peter Lieven <pl@kamp.de>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 block/io.c                   | 23 +++++++----------------
 include/block/block_int-io.h |  2 +-
 2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/block/io.c b/block/io.c
index 0a8cbefe86..51d8f943a4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -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,
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 91cdd61692..4b0b3e17ef 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -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);
 
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading
  2022-08-17  8:37 ` [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading Denis V. Lunev
@ 2022-08-19 15:51   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2022-08-19 15:51 UTC (permalink / raw)
  To: Denis V. Lunev, qemu-block, qemu-devel
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Fam Zheng,
	Ronnie Sahlberg, Paolo Bonzini, Peter Lieven

On 8/17/22 11:37, Denis V. Lunev wrote:
> I believe that if the helper exists, it must be used always for reading
> of the value. It breaks expectations in the other case.
> 
> Signed-off-by: Denis V. Lunev<den@openvz.org>
> CC: Kevin Wolf<kwolf@redhat.com>
> CC: Hanna Reitz<hreitz@redhat.com>
> CC: Stefan Hajnoczi<stefanha@redhat.com>
> CC: Fam Zheng<fam@euphon.net>
> CC: Ronnie Sahlberg<ronniesahlberg@gmail.com>
> CC: Paolo Bonzini<pbonzini@redhat.com>
> CC: Peter Lieven<pl@kamp.de>
> CC: Vladimir Sementsov-Ogievskiy<vsementsov@yandex-team.ru>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] block: make serializing requests functions 'void'
  2022-08-17  8:37 ` [PATCH 2/2] block: make serializing requests functions 'void' Denis V. Lunev
@ 2022-08-19 15:54   ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2022-08-19 15:54 UTC (permalink / raw)
  To: Denis V. Lunev, qemu-block, qemu-devel
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Fam Zheng,
	Ronnie Sahlberg, Paolo Bonzini, Peter Lieven

On 8/17/22 11:37, Denis V. Lunev wrote:
> 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
> 
> Signed-off-by: Denis V. Lunev<den@openvz.org>
> CC: Kevin Wolf<kwolf@redhat.com>
> CC: Hanna Reitz<hreitz@redhat.com>
> CC: Stefan Hajnoczi<stefanha@redhat.com>
> CC: Fam Zheng<fam@euphon.net>
> CC: Ronnie Sahlberg<ronniesahlberg@gmail.com>
> CC: Paolo Bonzini<pbonzini@redhat.com>
> CC: Peter Lieven<pl@kamp.de>
> CC: Vladimir Sementsov-Ogievskiy<vsementsov@yandex-team.ru>

Oh, good cleanup!


Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for 7.2] minor fixups in block code
  2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
  2022-08-17  8:37 ` [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading Denis V. Lunev
  2022-08-17  8:37 ` [PATCH 2/2] block: make serializing requests functions 'void' Denis V. Lunev
@ 2022-08-29 10:09 ` Denis V. Lunev
  2022-09-07 17:25 ` Denis V. Lunev
  2022-09-22 16:04 ` Kevin Wolf
  4 siblings, 0 replies; 8+ messages in thread
From: Denis V. Lunev @ 2022-08-29 10:09 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Fam Zheng,
	Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

On 17.08.2022 10:37, Denis V. Lunev wrote:
> These 2 patches are just minor improvements to make code a bit better.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Hanna Reitz <hreitz@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>
>
ping


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for 7.2] minor fixups in block code
  2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
                   ` (2 preceding siblings ...)
  2022-08-29 10:09 ` [PATCH for 7.2] minor fixups in block code Denis V. Lunev
@ 2022-09-07 17:25 ` Denis V. Lunev
  2022-09-22 16:04 ` Kevin Wolf
  4 siblings, 0 replies; 8+ messages in thread
From: Denis V. Lunev @ 2022-09-07 17:25 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Fam Zheng,
	Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

On 8/17/22 10:37, Denis V. Lunev wrote:
> These 2 patches are just minor improvements to make code a bit better.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Hanna Reitz <hreitz@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Fam Zheng <fam@euphon.net>
> CC: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Peter Lieven <pl@kamp.de>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>
>
ping v2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH for 7.2] minor fixups in block code
  2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
                   ` (3 preceding siblings ...)
  2022-09-07 17:25 ` Denis V. Lunev
@ 2022-09-22 16:04 ` Kevin Wolf
  4 siblings, 0 replies; 8+ messages in thread
From: Kevin Wolf @ 2022-09-22 16:04 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: qemu-block, qemu-devel, Hanna Reitz, Stefan Hajnoczi, Fam Zheng,
	Ronnie Sahlberg, Paolo Bonzini, Peter Lieven,
	Vladimir Sementsov-Ogievskiy

Am 17.08.2022 um 10:37 hat Denis V. Lunev geschrieben:
> These 2 patches are just minor improvements to make code a bit better.

Thanks, applied to the block branch.

Kevin



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-22 16:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-17  8:37 [PATCH for 7.2] minor fixups in block code Denis V. Lunev
2022-08-17  8:37 ` [PATCH 1/2] block: use bdrv_is_sg() helper instead of raw bs->sg reading Denis V. Lunev
2022-08-19 15:51   ` Vladimir Sementsov-Ogievskiy
2022-08-17  8:37 ` [PATCH 2/2] block: make serializing requests functions 'void' Denis V. Lunev
2022-08-19 15:54   ` Vladimir Sementsov-Ogievskiy
2022-08-29 10:09 ` [PATCH for 7.2] minor fixups in block code Denis V. Lunev
2022-09-07 17:25 ` Denis V. Lunev
2022-09-22 16:04 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).