From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] virtio_blk: write back the block cache before resetting the device
Date: Wed, 26 Aug 2026 11:33:26 +0200 [thread overview]
Message-ID: <20260826093327.2400414-1-a.fatoum@pengutronix.de> (raw)
virtio_blk_remove() resets the virtio device first and unregisters the
block device afterwards, but that second step is what writes barebox'
block cache back: blockdevice_unregister() calls writebuffer_flush(),
which issues ->write() for every dirty chunk and then ->flush(). Both go
to a device that no longer has a driver-owned virtqueue, so nothing
answers them.
Booting an OS makes this visible, as ExitBootServices() shuts the devices
down:
EFI stub: Exiting boot services...
ERROR: virtio_blk virtio0: I/O error: type 4 sector 0 count 0 status 1 ret Connection timed out
Here it is only the flush that is lost, but a dirty chunk - a variable
file written just before booting, say - would be dropped just as quietly.
Reset after unregistering, like Linux' virtblk_remove() does around
del_gendisk().
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/block/virtio_blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index f1ee76da9750..a82d6774c385 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -115,8 +115,8 @@ static void virtio_blk_remove(struct virtio_device *vdev)
{
struct virtio_blk_priv *priv = vdev->priv;
- vdev->config->reset(vdev);
blockdevice_unregister(&priv->blk);
+ vdev->config->reset(vdev);
vdev->config->del_vqs(vdev);
free(priv);
--
2.47.3
next reply other threads:[~2026-08-26 9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 9:33 Ahmad Fatoum [this message]
2026-08-28 11:55 ` Sascha Hauer
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=20260826093327.2400414-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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