qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 03/11] block/mirror: Fix NULL s->job in active writes
Date: Fri, 11 Nov 2022 16:27:36 +0100	[thread overview]
Message-ID: <20221111152744.261358-4-kwolf@redhat.com> (raw)
In-Reply-To: <20221111152744.261358-1-kwolf@redhat.com>

From: Hanna Reitz <hreitz@redhat.com>

There is a small gap in mirror_start_job() before putting the mirror
filter node into the block graph (bdrv_append() call) and the actual job
being created.  Before the job is created, MirrorBDSOpaque.job is NULL.

It is possible that requests come in when bdrv_drained_end() is called,
and those requests would see MirrorBDSOpaque.job == NULL.  Have our
filter node handle that case gracefully.

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221109165452.67927-4-hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/mirror.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 5b6f42392c..251adc5ae0 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1438,11 +1438,13 @@ static int coroutine_fn bdrv_mirror_top_do_write(BlockDriverState *bs,
     MirrorOp *op = NULL;
     MirrorBDSOpaque *s = bs->opaque;
     int ret = 0;
-    bool copy_to_target;
+    bool copy_to_target = false;
 
-    copy_to_target = s->job->ret >= 0 &&
-                     !job_is_cancelled(&s->job->common.job) &&
-                     s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING;
+    if (s->job) {
+        copy_to_target = s->job->ret >= 0 &&
+                         !job_is_cancelled(&s->job->common.job) &&
+                         s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING;
+    }
 
     if (copy_to_target) {
         op = active_write_prepare(s->job, offset, bytes);
@@ -1487,11 +1489,13 @@ static int coroutine_fn bdrv_mirror_top_pwritev(BlockDriverState *bs,
     QEMUIOVector bounce_qiov;
     void *bounce_buf;
     int ret = 0;
-    bool copy_to_target;
+    bool copy_to_target = false;
 
-    copy_to_target = s->job->ret >= 0 &&
-                     !job_is_cancelled(&s->job->common.job) &&
-                     s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING;
+    if (s->job) {
+        copy_to_target = s->job->ret >= 0 &&
+                         !job_is_cancelled(&s->job->common.job) &&
+                         s->job->copy_mode == MIRROR_COPY_MODE_WRITE_BLOCKING;
+    }
 
     if (copy_to_target) {
         /* The guest might concurrently modify the data to write; but
-- 
2.38.1



  parent reply	other threads:[~2022-11-11 15:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 15:27 [PULL 00/11] Block layer patches Kevin Wolf
2022-11-11 15:27 ` [PULL 01/11] block/mirror: Do not wait for active writes Kevin Wolf
2022-11-11 15:27 ` [PULL 02/11] block/mirror: Drop mirror_wait_for_any_operation() Kevin Wolf
2022-11-11 15:27 ` Kevin Wolf [this message]
2022-11-11 15:27 ` [PULL 04/11] iotests/151: Test that active mirror progresses Kevin Wolf
2022-11-11 15:27 ` [PULL 05/11] iotests/151: Test active requests on mirror start Kevin Wolf
2022-11-11 15:27 ` [PULL 06/11] qapi/block-core: Fix BlockdevOptionsNvmeIoUring @path description Kevin Wolf
2022-11-11 15:27 ` [PULL 07/11] block/blkio: Set BlockDriver::has_variable_length to false Kevin Wolf
2022-11-11 15:27 ` [PULL 08/11] block: Make bdrv_child_get_parent_aio_context I/O Kevin Wolf
2022-11-11 15:27 ` [PULL 09/11] block-backend: Update ctx immediately after root Kevin Wolf
2022-11-11 15:27 ` [PULL 10/11] block: Start/end drain on correct AioContext Kevin Wolf
2022-11-11 15:27 ` [PULL 11/11] tests/stream-under-throttle: New test Kevin Wolf
2022-11-11 19:20 ` [PULL 00/11] Block layer patches Stefan Hajnoczi
2022-11-14 10:12   ` Hanna Reitz
2022-11-14 10:56   ` Kevin Wolf
2022-11-14 23:58     ` John Snow
2022-11-15 10:14       ` Kevin Wolf
2022-11-15 10:21         ` Hanna Reitz
2022-11-15 15:32           ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221111152744.261358-4-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).