1 | The following changes since commit 346ed3151f1c43e72c40cb55b392a1d4cface62c: | 1 | The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20200206.0' into staging (2020-02-07 11:52:15 +0000) | 3 | Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://gitlab.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 11a18c84db4a71497d3d40769688a01b6f64b2ad: | 9 | for you to fetch changes up to 66547f416a61e0cb711dc76821890242432ba193: |
10 | 10 | ||
11 | hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host (2020-02-07 16:49:39 +0000) | 11 | block/nvme: invoke blk_io_plug_call() outside q->lock (2023-07-17 09:17:41 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Pull request | 14 | Pull request |
15 | 15 | ||
16 | Fix the hang in the nvme:// block driver during startup. | ||
17 | |||
16 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
17 | 19 | ||
18 | Philippe Mathieu-Daudé (1): | 20 | Stefan Hajnoczi (1): |
19 | hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host | 21 | block/nvme: invoke blk_io_plug_call() outside q->lock |
20 | 22 | ||
21 | Vladimir Sementsov-Ogievskiy (1): | 23 | block/nvme.c | 3 ++- |
22 | block: fix crash on zero-length unaligned write and read | 24 | 1 file changed, 2 insertions(+), 1 deletion(-) |
23 | |||
24 | block/io.c | 28 +++++++++++++++++++++++++++- | ||
25 | hw/core/machine.c | 3 ++- | ||
26 | 2 files changed, 29 insertions(+), 2 deletions(-) | ||
27 | 25 | ||
28 | -- | 26 | -- |
29 | 2.24.1 | 27 | 2.40.1 |
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | Commit 7a3f542fbd "block/io: refactor padding" occasionally dropped | ||
4 | aligning for zero-length request: bdrv_init_padding() blindly return | ||
5 | false if bytes == 0, like there is nothing to align. | ||
6 | |||
7 | This leads the following command to crash: | ||
8 | |||
9 | ./qemu-io --image-opts -c 'write 1 0' \ | ||
10 | driver=blkdebug,align=512,image.driver=null-co,image.size=512 | ||
11 | |||
12 | >> qemu-io: block/io.c:1955: bdrv_aligned_pwritev: Assertion | ||
13 | `(offset & (align - 1)) == 0' failed. | ||
14 | >> Aborted (core dumped) | ||
15 | |||
16 | Prior to 7a3f542fbd we does aligning of such zero requests. Instead of | ||
17 | recovering this behavior let's just do nothing on such requests as it | ||
18 | is useless. | ||
19 | |||
20 | Note that driver may have special meaning of zero-length reqeusts, like | ||
21 | qcow2_co_pwritev_compressed_part, so we can't skip any zero-length | ||
22 | operation. But for unaligned ones, we can't pass it to driver anyway. | ||
23 | |||
24 | This commit also fixes crash in iotest 80 running with -nocache: | ||
25 | |||
26 | ./check -nocache -qcow2 80 | ||
27 | |||
28 | which crashes on same assertion due to trying to read empty extra data | ||
29 | in qcow2_do_read_snapshots(). | ||
30 | |||
31 | Cc: qemu-stable@nongnu.org # v4.2 | ||
32 | Fixes: 7a3f542fbd | ||
33 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
34 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
35 | Message-id: 20200206164245.17781-1-vsementsov@virtuozzo.com | ||
36 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
37 | --- | ||
38 | block/io.c | 28 +++++++++++++++++++++++++++- | ||
39 | 1 file changed, 27 insertions(+), 1 deletion(-) | ||
40 | |||
41 | diff --git a/block/io.c b/block/io.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/block/io.c | ||
44 | +++ b/block/io.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool bdrv_init_padding(BlockDriverState *bs, | ||
46 | pad->tail = align - pad->tail; | ||
47 | } | ||
48 | |||
49 | - if ((!pad->head && !pad->tail) || !bytes) { | ||
50 | + if (!pad->head && !pad->tail) { | ||
51 | return false; | ||
52 | } | ||
53 | |||
54 | + assert(bytes); /* Nothing good in aligning zero-length requests */ | ||
55 | + | ||
56 | sum = pad->head + bytes + pad->tail; | ||
57 | pad->buf_len = (sum > align && pad->head && pad->tail) ? 2 * align : align; | ||
58 | pad->buf = qemu_blockalign(bs, pad->buf_len); | ||
59 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, | ||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { | ||
64 | + /* | ||
65 | + * Aligning zero request is nonsense. Even if driver has special meaning | ||
66 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass | ||
67 | + * it to driver due to request_alignment. | ||
68 | + * | ||
69 | + * Still, no reason to return an error if someone do unaligned | ||
70 | + * zero-length read occasionally. | ||
71 | + */ | ||
72 | + return 0; | ||
73 | + } | ||
74 | + | ||
75 | bdrv_inc_in_flight(bs); | ||
76 | |||
77 | /* Don't do copy-on-read if we read data before write operation */ | ||
78 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, | ||
79 | return -ENOTSUP; | ||
80 | } | ||
81 | |||
82 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { | ||
83 | + /* | ||
84 | + * Aligning zero request is nonsense. Even if driver has special meaning | ||
85 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass | ||
86 | + * it to driver due to request_alignment. | ||
87 | + * | ||
88 | + * Still, no reason to return an error if someone do unaligned | ||
89 | + * zero-length write occasionally. | ||
90 | + */ | ||
91 | + return 0; | ||
92 | + } | ||
93 | + | ||
94 | bdrv_inc_in_flight(bs); | ||
95 | /* | ||
96 | * Align write if necessary by performing a read-modify-write cycle. | ||
97 | -- | ||
98 | 2.24.1 | ||
99 | |||
100 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | blk_io_plug_call() is invoked outside a blk_io_plug()/blk_io_unplug() |
---|---|---|---|
2 | section while opening the NVMe drive from: | ||
2 | 3 | ||
3 | Commit ed65fd1a2750 ("virtio-blk: switch off scsi-passthrough by | 4 | nvme_file_open() -> |
4 | default") changed the default value of the 'scsi' property of | 5 | nvme_init() -> |
5 | virtio-blk, which is only available on Linux hosts. It also added | 6 | nvme_identify() -> |
6 | an unconditional compat entry for 2.4 or earlier machines. | 7 | nvme_admin_cmd_sync() -> |
8 | nvme_submit_command() -> | ||
9 | blk_io_plug_call() | ||
7 | 10 | ||
8 | Trying to set this property on a pre-2.5 machine on OSX, we get: | 11 | blk_io_plug_call() immediately invokes the given callback when the |
12 | current thread is not plugged, as is the case during nvme_file_open(). | ||
9 | 13 | ||
10 | Unexpected error in object_property_find() at qom/object.c:1201: | 14 | Unfortunately, nvme_submit_command() calls blk_io_plug_call() with |
11 | qemu-system-x86_64: -device virtio-blk-pci,id=scsi0,drive=drive0: can't apply global virtio-blk-device.scsi=true: Property '.scsi' not found | 15 | q->lock still held: |
12 | 16 | ||
13 | Fix this error by marking the property optional. | 17 | ... |
18 | q->sq.tail = (q->sq.tail + 1) % NVME_QUEUE_SIZE; | ||
19 | q->need_kick++; | ||
20 | blk_io_plug_call(nvme_unplug_fn, q); | ||
21 | qemu_mutex_unlock(&q->lock); | ||
22 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
14 | 23 | ||
15 | Fixes: ed65fd1a27 ("virtio-blk: switch off scsi-passthrough by default") | 24 | nvme_unplug_fn() deadlocks trying to acquire q->lock because the lock is |
16 | Suggested-by: Cornelia Huck <cohuck@redhat.com> | 25 | already acquired by the same thread. The symptom is that QEMU hangs |
17 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | 26 | during startup while opening the NVMe drive. |
18 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 27 | |
19 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | 28 | Fix this by moving the blk_io_plug_call() outside q->lock. This is safe |
20 | Message-id: 20200207001404.1739-1-philmd@redhat.com | 29 | because no other thread runs code related to this queue and |
30 | blk_io_plug_call()'s internal state is immune to thread safety issues | ||
31 | since it is thread-local. | ||
32 | |||
33 | Reported-by: Lukáš Doktor <ldoktor@redhat.com> | ||
34 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
35 | Tested-by: Lukas Doktor <ldoktor@redhat.com> | ||
36 | Message-id: 20230712191628.252806-1-stefanha@redhat.com | ||
37 | Fixes: f2e590002bd6 ("block/nvme: convert to blk_io_plug_call() API") | ||
21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 38 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
22 | --- | 39 | --- |
23 | hw/core/machine.c | 3 ++- | 40 | block/nvme.c | 3 ++- |
24 | 1 file changed, 2 insertions(+), 1 deletion(-) | 41 | 1 file changed, 2 insertions(+), 1 deletion(-) |
25 | 42 | ||
26 | diff --git a/hw/core/machine.c b/hw/core/machine.c | 43 | diff --git a/block/nvme.c b/block/nvme.c |
27 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/core/machine.c | 45 | --- a/block/nvme.c |
29 | +++ b/hw/core/machine.c | 46 | +++ b/block/nvme.c |
30 | @@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_2_5[] = { | 47 | @@ -XXX,XX +XXX,XX @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req, |
31 | const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); | 48 | q->sq.tail * NVME_SQ_ENTRY_BYTES, cmd, sizeof(*cmd)); |
32 | 49 | q->sq.tail = (q->sq.tail + 1) % NVME_QUEUE_SIZE; | |
33 | GlobalProperty hw_compat_2_4[] = { | 50 | q->need_kick++; |
34 | - { "virtio-blk-device", "scsi", "true" }, | 51 | + qemu_mutex_unlock(&q->lock); |
35 | + /* Optional because the 'scsi' property is Linux-only */ | 52 | + |
36 | + { "virtio-blk-device", "scsi", "true", .optional = true }, | 53 | blk_io_plug_call(nvme_unplug_fn, q); |
37 | { "e1000", "extra_mac_registers", "off" }, | 54 | - qemu_mutex_unlock(&q->lock); |
38 | { "virtio-pci", "x-disable-pcie", "on" }, | 55 | } |
39 | { "virtio-pci", "migrate-extra", "off" }, | 56 | |
57 | static void nvme_admin_cmd_sync_cb(void *opaque, int ret) | ||
40 | -- | 58 | -- |
41 | 2.24.1 | 59 | 2.40.1 |
42 | 60 | ||
43 | 61 | diff view generated by jsdifflib |