qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure
@ 2023-03-27 21:19 Stefan Hajnoczi
  2023-03-28 12:27 ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2023-03-27 21:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Coiby Xu, qemu-block, Hanna Reitz, Kevin Wolf, Stefan Hajnoczi

When I/O request parameters are validated for virtio-blk exports like
vhost-user-blk and vduse-blk, we call blk_get_geometry() from a
coroutine. This hits an assume_graph_lock() assertion failure.

Use blk_co_nb_sectors() instead and mark virtio_blk_sect_range_ok() with
coroutine_fn.

This assertion failure is triggered by any I/O to a vhost-user-blk
export.

Fixes: 8ab8140a04cf ("block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK")
Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/export/virtio-blk-handler.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/block/export/virtio-blk-handler.c b/block/export/virtio-blk-handler.c
index 313666e8ab..2f729a9ce2 100644
--- a/block/export/virtio-blk-handler.c
+++ b/block/export/virtio-blk-handler.c
@@ -22,8 +22,9 @@ struct virtio_blk_inhdr {
     unsigned char status;
 };
 
-static bool virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size,
-                                     uint64_t sector, size_t size)
+static bool coroutine_fn
+virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size,
+                         uint64_t sector, size_t size)
 {
     uint64_t nb_sectors;
     uint64_t total_sectors;
@@ -41,7 +42,7 @@ static bool virtio_blk_sect_range_ok(BlockBackend *blk, uint32_t block_size,
     if ((sector << VIRTIO_BLK_SECTOR_BITS) % block_size) {
         return false;
     }
-    blk_get_geometry(blk, &total_sectors);
+    total_sectors = blk_co_nb_sectors(blk);
     if (sector > total_sectors || nb_sectors > total_sectors - sector) {
         return false;
     }
-- 
2.39.2



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

* Re: [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure
  2023-03-27 21:19 [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure Stefan Hajnoczi
@ 2023-03-28 12:27 ` Kevin Wolf
  2023-03-28 15:09   ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2023-03-28 12:27 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Coiby Xu, qemu-block, Hanna Reitz

Am 27.03.2023 um 23:19 hat Stefan Hajnoczi geschrieben:
> When I/O request parameters are validated for virtio-blk exports like
> vhost-user-blk and vduse-blk, we call blk_get_geometry() from a
> coroutine. This hits an assume_graph_lock() assertion failure.
> 
> Use blk_co_nb_sectors() instead and mark virtio_blk_sect_range_ok() with
> coroutine_fn.
> 
> This assertion failure is triggered by any I/O to a vhost-user-blk
> export.
> 
> Fixes: 8ab8140a04cf ("block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK")
> Cc: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>

This is a duplicate of this fix:

https://patchew.org/QEMU/20230327113959.60071-1-kwolf@redhat.com/

Kevin



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

* Re: [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure
  2023-03-28 12:27 ` Kevin Wolf
@ 2023-03-28 15:09   ` Stefan Hajnoczi
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2023-03-28 15:09 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel, Coiby Xu, qemu-block, Hanna Reitz

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

On Tue, Mar 28, 2023 at 02:27:35PM +0200, Kevin Wolf wrote:
> Am 27.03.2023 um 23:19 hat Stefan Hajnoczi geschrieben:
> > When I/O request parameters are validated for virtio-blk exports like
> > vhost-user-blk and vduse-blk, we call blk_get_geometry() from a
> > coroutine. This hits an assume_graph_lock() assertion failure.
> > 
> > Use blk_co_nb_sectors() instead and mark virtio_blk_sect_range_ok() with
> > coroutine_fn.
> > 
> > This assertion failure is triggered by any I/O to a vhost-user-blk
> > export.
> > 
> > Fixes: 8ab8140a04cf ("block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK")
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> 
> This is a duplicate of this fix:
> 
> https://patchew.org/QEMU/20230327113959.60071-1-kwolf@redhat.com/

Okay, thanks. Your fix looks good.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2023-03-28 15:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-27 21:19 [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure Stefan Hajnoczi
2023-03-28 12:27 ` Kevin Wolf
2023-03-28 15:09   ` Stefan Hajnoczi

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).