[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/45] scsi: fix device removal race vs IO restart callback on res
From: |
Paolo Bonzini |
Subject: |
[PULL 25/45] scsi: fix device removal race vs IO restart callback on resume |
Date: |
Tue, 15 Dec 2020 12:54:25 -0500 |
From: Maxim Levitsky <mlevitsk@redhat.com>
There is (mostly theoretical) race between removal of a scsi device and
scsi_dma_restart_bh.
It used to be easier to hit this race prior to my / Paulo's patch series
that added rcu to scsi bus device handling code, but IMHO this race
should still be possible to hit, at least in theory.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1854811
Fix it anyway with a patch that was proposed by Paulo in the above bugzilla.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201210125929.1136390-2-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi/scsi-bus.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index b901e701f0..edb5c3492a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -170,6 +170,8 @@ static void scsi_dma_restart_bh(void *opaque)
scsi_req_unref(req);
}
aio_context_release(blk_get_aio_context(s->conf.blk));
+ /* Drop the reference that was acquired in scsi_dma_restart_cb */
+ object_unref(OBJECT(s));
}
void scsi_req_retry(SCSIRequest *req)
@@ -188,6 +190,8 @@ static void scsi_dma_restart_cb(void *opaque, int running,
RunState state)
}
if (!s->bh) {
AioContext *ctx = blk_get_aio_context(s->conf.blk);
+ /* The reference is dropped in scsi_dma_restart_bh.*/
+ object_ref(OBJECT(s));
s->bh = aio_bh_new(ctx, scsi_dma_restart_bh, s);
qemu_bh_schedule(s->bh);
}
--
2.26.2
- [PULL 23/45] Remove the deprecated -show-cursor option, (continued)
- [PULL 23/45] Remove the deprecated -show-cursor option, Paolo Bonzini, 2020/12/15
- [PULL 15/45] vl: Add an -action option specifying response to guest events, Paolo Bonzini, 2020/12/15
- [PULL 13/45] monitor: allow quitting while in preconfig state, Paolo Bonzini, 2020/12/15
- [PULL 16/45] vl: Add option to avoid stopping VM upon guest panic, Paolo Bonzini, 2020/12/15
- [PULL 21/45] docs/system: Move the list of removed features to a separate file, Paolo Bonzini, 2020/12/15
- [PULL 07/45] chardev: do not use machine_init_done, Paolo Bonzini, 2020/12/15
- [PULL 17/45] qtest/pvpanic: Test panic option that allows VM to continue, Paolo Bonzini, 2020/12/15
- [PULL 18/45] msix: assert that accesses are within bounds, Paolo Bonzini, 2020/12/15
- [PULL 22/45] Remove the deprecated -realtime option, Paolo Bonzini, 2020/12/15
- [PULL 26/45] kvm: Take into account the unaligned section size when preparing bitmap, Paolo Bonzini, 2020/12/15
- [PULL 25/45] scsi: fix device removal race vs IO restart callback on resume,
Paolo Bonzini <=
- [PULL 27/45] qemu-option: simplify search for end of key, Paolo Bonzini, 2020/12/15
- [PULL 36/45] tests: remove GCC < 4 fallbacks, Paolo Bonzini, 2020/12/15
- [PULL 32/45] qemu/atomic: Drop special case for unsupported compiler, Paolo Bonzini, 2020/12/15
- [PULL 35/45] qemu-plugin.h: remove GCC < 4, Paolo Bonzini, 2020/12/15
- [PULL 42/45] linux-user: remove GNUC check, Paolo Bonzini, 2020/12/15
- [PULL 20/45] accel/tcg: Remove deprecated '-tb-size' option, Paolo Bonzini, 2020/12/15
- [PULL 28/45] qemu-option: pass QemuOptsList to opts_accepts_any, Paolo Bonzini, 2020/12/15
- [PULL 24/45] icount: improve exec nocache usage, Paolo Bonzini, 2020/12/15
- [PULL 29/45] vl: rename local variable in configure_accelerators, Paolo Bonzini, 2020/12/15
- [PULL 31/45] hw/core: Restrict 'fw-path-provider.c' to system mode emulation, Paolo Bonzini, 2020/12/15