- sw_64: Added sw64 architecture related updates - virtio-crypto: verify src&dst buffer length for sym request - vhost-vdpa: do not cleanup the vdpa/vhost-net structures if peer nic is present - qga: Fix suspend on Linux guests without systemd - tests: vhost-user-test: release mutex on protocol violation - qapi: support updating expected test output via make - block: Fix misleading hexadecimal format - block/rbd: fix write zeroes with growing images - block/nbd.c: Fixed IO request coroutine not being wakeup when kill NBD server - block/nfs: Fix 32-bit Windows build - qapi/qdev: Tidy up device_add documentation - hw/xen/xen_pt: fix uninitialized variable - migration/ram: Fix error handling in ram_write_tracking_start() - docs/about/build-platforms: Refine the distro support policy - xen-block: Avoid leaks on new error path - QGA VSS: Add wrapper to send log to debugger and stderr - chardev/char-socket: set s->listener = NULL in char_socket_finalize - qapi/block: Tidy up block-latency-histogram-set documentation - disas/riscv Fix ctzw disassemble - vfio: Fix vfio_get_dev_region() trace event - migration/ram: Fix populate_read_range() - Check and report for incomplete 'global' option format Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
77 lines
2.8 KiB
Diff
77 lines
2.8 KiB
Diff
From c0caaf3367912df00107e6cd49809a48ccc566fb Mon Sep 17 00:00:00 2001
|
|
From: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
Date: Fri, 4 Aug 2023 08:03:35 +0000
|
|
Subject: [PATCH] block/rbd: fix write zeroes with growing images mainline
|
|
inclusion commit cc5387a544325c26dcf124ac7d3999389c24e5c6 category: bugfix
|
|
|
|
---------------------------------------------------------------
|
|
|
|
Commit d24f80234b ("block/rbd: increase dynamically the image size")
|
|
added a workaround to support growing images (eg. qcow2), resizing
|
|
the image before write operations that exceed the current size.
|
|
|
|
We recently added support for write zeroes and without the
|
|
workaround we can have problems with qcow2.
|
|
|
|
So let's move the resize into qemu_rbd_start_co() and do it when
|
|
the command is RBD_AIO_WRITE or RBD_AIO_WRITE_ZEROES.
|
|
|
|
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2020993
|
|
Fixes: c56ac27d2a ("block/rbd: add write zeroes support")
|
|
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
Message-Id: <20220317162638.41192-1-sgarzare@redhat.com>
|
|
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
|
Signed-off-by: tangbinzy <tangbin_yewu@cmss.chinamobile.com>
|
|
---
|
|
block/rbd.c | 26 ++++++++++++++------------
|
|
1 file changed, 14 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/block/rbd.c b/block/rbd.c
|
|
index 92dfb6083b..ccb14efd55 100644
|
|
--- a/block/rbd.c
|
|
+++ b/block/rbd.c
|
|
@@ -1107,6 +1107,20 @@ static int coroutine_fn qemu_rbd_start_co(BlockDriverState *bs,
|
|
|
|
assert(!qiov || qiov->size == bytes);
|
|
|
|
+ if (cmd == RBD_AIO_WRITE || cmd == RBD_AIO_WRITE_ZEROES) {
|
|
+ /*
|
|
+ * RBD APIs don't allow us to write more than actual size, so in order
|
|
+ * to support growing images, we resize the image before write
|
|
+ * operations that exceed the current size.
|
|
+ */
|
|
+ if (offset + bytes > s->image_size) {
|
|
+ int r = qemu_rbd_resize(bs, offset + bytes);
|
|
+ if (r < 0) {
|
|
+ return r;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
r = rbd_aio_create_completion(&task,
|
|
(rbd_callback_t) qemu_rbd_completion_cb, &c);
|
|
if (r < 0) {
|
|
@@ -1182,18 +1196,6 @@ coroutine_fn qemu_rbd_co_pwritev(BlockDriverState *bs, int64_t offset,
|
|
int64_t bytes, QEMUIOVector *qiov,
|
|
BdrvRequestFlags flags)
|
|
{
|
|
- BDRVRBDState *s = bs->opaque;
|
|
- /*
|
|
- * RBD APIs don't allow us to write more than actual size, so in order
|
|
- * to support growing images, we resize the image before write
|
|
- * operations that exceed the current size.
|
|
- */
|
|
- if (offset + bytes > s->image_size) {
|
|
- int r = qemu_rbd_resize(bs, offset + bytes);
|
|
- if (r < 0) {
|
|
- return r;
|
|
- }
|
|
- }
|
|
return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_WRITE);
|
|
}
|
|
|
|
--
|
|
2.41.0.windows.1
|
|
|