From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Coiby Xu <Coiby.Xu@gmail.com>,
qemu-block@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure
Date: Mon, 27 Mar 2023 17:19:21 -0400 [thread overview]
Message-ID: <20230327211921.1612727-1-stefanha@redhat.com> (raw)
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
next reply other threads:[~2023-03-27 21:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 21:19 Stefan Hajnoczi [this message]
2023-03-28 12:27 ` [PATCH for-8.0] block/export: fix assume_graph_lock() assertion failure Kevin Wolf
2023-03-28 15:09 ` Stefan Hajnoczi
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=20230327211921.1612727-1-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=Coiby.Xu@gmail.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).