[pve-devel] [PATCH pve-qemu] fix mutex lock for backup dump callback
Tim Marx
t.marx at proxmox.com
Fri Feb 14 10:39:18 CET 2020
Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
...-mutex-lock-for-backup-dump-callback.patch | 34 +++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 35 insertions(+)
create mode 100644 debian/patches/pve/0048-PVE-fix-mutex-lock-for-backup-dump-callback.patch
diff --git a/debian/patches/pve/0048-PVE-fix-mutex-lock-for-backup-dump-callback.patch b/debian/patches/pve/0048-PVE-fix-mutex-lock-for-backup-dump-callback.patch
new file mode 100644
index 0000000..3e87da8
--- /dev/null
+++ b/debian/patches/pve/0048-PVE-fix-mutex-lock-for-backup-dump-callback.patch
@@ -0,0 +1,34 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tim Marx <t.marx at proxmox.com>
+Date: Fri, 14 Feb 2020 10:21:22 +0100
+Subject: [PATCH] PVE: fix mutex lock for backup dump callback
+
+Locking the backup_state while vma_writer_write is called, can result in a yield
+if the write buffer needs to be flushed and the corresponding fd isn't writeable.
+This could happen multiple times during one flush operation. If the lock is kept
+this will affect other qmp calls which can lead to various problems e.g. blocking
+the main loop.
+Signed-off-by: Tim Marx <t.marx at proxmox.com>
+---
+ blockdev.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/blockdev.c b/blockdev.c
+index 46e8a2780a..e37408bd08 100644
+--- a/blockdev.c
++++ b/blockdev.c
+@@ -3266,8 +3266,11 @@ static int coroutine_fn pvebackup_co_dump_cb(void *opaque, BlockBackend *target,
+ size_t zero_bytes = 0;
+ uint64_t remaining = size;
+ while (remaining > 0) {
++ // unlock the mutex in case the vma write yields on flush
++ qemu_co_mutex_unlock(&backup_state.backup_mutex);
+ ret = vma_writer_write(backup_state.vmaw, di->dev_id, cluster_num,
+ buf, &zero_bytes);
++ qemu_co_mutex_lock(&backup_state.backup_mutex);
+ ++cluster_num;
+ if (buf) {
+ buf += VMA_CLUSTER_SIZE;
+--
+2.20.1
+
diff --git a/debian/patches/series b/debian/patches/series
index c37c4e1..97025f8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -47,3 +47,4 @@ pve/0044-Acquire-aio_context-before-calling-block_job_add_bdr.patch
pve/0045-PVE-Compat-4.0-used-balloon-qemu-4-0-config-size-fal.patch
pve/0046-PVE-Allow-version-code-in-machine-type.patch
pve/0047-PVE-fix-hmp-info-backup-cmd-for-not-initialized-back.patch
+pve/0048-PVE-fix-mutex-lock-for-backup-dump-callback.patch
--
2.20.1
More information about the pve-devel
mailing list