From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC qemu 7/7] block/backup: set callback for cbw errors
Date: Mon, 10 Jun 2024 14:59:42 +0200 [thread overview]
Message-ID: <20240610125942.116985-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20240610125942.116985-1-f.ebner@proxmox.com>
The callback is invoked when cbw is configured to not break the guest
write and will abort a backup job immediately. Currently the backup
has to wait for the rest of the block copy operation to finish before
checking the cbw error state.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Note for testers: if e.g. the PBS is compeletly unreachable, the
backup job still will need to wait until the in-flight request is
aborted after 15 minutes. But the guest writes should be fast again.
block/backup.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/block/backup.c b/block/backup.c
index ba153110d3..43d34ce4c2 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -32,6 +32,45 @@
static const BlockJobDriver backup_job_driver;
+typedef struct {
+ Job *job;
+ int ret;
+} BackupOnCbwError;
+
+static void backup_on_cbw_error_cb_bh(void *opaque)
+{
+ BackupOnCbwError *data = opaque;
+ if (data->job) {
+ WITH_JOB_LOCK_GUARD() {
+ if (!job_is_completed_locked(data->job)) {
+ error_report("backup was cancelled because of copy-before-write error: %s",
+ strerror(-data->ret));
+ job_cancel_locked(data->job, true);
+ }
+ }
+ } else {
+ error_report("backup_on_cbw_error_cb_bh: no job! Error: %s", strerror(-data->ret));
+ }
+
+ g_free(data);
+}
+
+static void backup_on_cbw_error_cb(void *opaque, int ret)
+{
+ BackupOnCbwError *data = g_new0(BackupOnCbwError, 1);
+ data->job = opaque;
+ data->ret = ret;
+
+ /*
+ * backup_cancel() cannot run in coroutine context.
+ */
+ if (qemu_in_coroutine()) {
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), backup_on_cbw_error_cb_bh, data);
+ } else {
+ backup_on_cbw_error_cb_bh(data);
+ }
+}
+
static void backup_cleanup_sync_bitmap(BackupBlockJob *job, int ret)
{
BdrvDirtyBitmap *bm;
@@ -477,6 +516,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
goto error;
}
+ bdrv_cbw_set_error_cb(cbw, backup_on_cbw_error_cb, job);
+
job->cbw = cbw;
job->source_bs = bs;
job->target_bs = target;
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-06-10 12:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 12:59 [pve-devel] [RFC qemu] fix #3231+#3631: PVE backup: fail backup rather than guest write when backup target cannot be reached or is too slow Fiona Ebner
2024-06-10 12:59 ` [pve-devel] [PATCH qemu 1/7] PVE backup: fleecing: properly set minimum cluster size Fiona Ebner
2024-06-10 12:59 ` [pve-devel] [RFC qemu 2/7] block/copy-before-write: allow passing additional options for bdrv_cbw_append() Fiona Ebner
2024-06-10 12:59 ` [pve-devel] [RFC qemu 3/7] block/backup: allow passing additional options for copy-before-write upon job creation Fiona Ebner
2024-07-05 9:30 ` Fabian Grünbichler
2024-06-10 12:59 ` [pve-devel] [RFC qemu 4/7] block/backup: make cbw error also fail backup that does not use fleecing Fiona Ebner
2024-06-10 12:59 ` [pve-devel] [RFC qemu 5/7] fix #3231+#3631: PVE backup: add timeout for copy-before-write operations and fail backup instead of guest writes Fiona Ebner
2024-06-10 12:59 ` [pve-devel] [RFC qemu 6/7] block/copy-before-write: allow specifying error callback Fiona Ebner
2024-06-10 12:59 ` Fiona Ebner [this message]
2024-07-05 9:37 ` [pve-devel] [RFC qemu 7/7] block/backup: set callback for cbw errors Fabian Grünbichler
2024-07-05 9:41 ` [pve-devel] [RFC qemu] fix #3231+#3631: PVE backup: fail backup rather than guest write when backup target cannot be reached or is too slow Fabian Grünbichler
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=20240610125942.116985-8-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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