[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 6/7] block/copy-before-write: implement cbw-timeout option
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH v4 6/7] block/copy-before-write: implement cbw-timeout option |
Date: |
Tue, 28 Jun 2022 10:38:04 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 |
While debugging my "[PULL 00/10] Block jobs & NBD patches", I found that we
have bdrv_dec_in_flight() and bdrv_inc_in_flight().
So, this should be fixed:
On 4/7/22 16:27, Vladimir Sementsov-Ogievskiy wrote:
In some scenarios, when copy-before-write operations lasts too long
time, it's better to cancel it.
Most useful would be to use the new option together with
on-cbw-error=break-snapshot: this way if cbw operation takes too long
time we'll just cancel backup process but do not disturb the guest too
much.
[..]
+static void block_copy_cb(void *opaque)
+{
+ BlockDriverState *bs = opaque;
+
+ bs->in_flight--;
+ aio_wait_kick();
Just bdrv_dec_in_flight(bs), which includes aio_wait_kick().
+}
+
/*
* Do copy-before-write operation.
*
@@ -111,7 +120,16 @@ static coroutine_fn int
cbw_do_copy_before_write(BlockDriverState *bs,
off = QEMU_ALIGN_DOWN(offset, cluster_size);
end = QEMU_ALIGN_UP(offset + bytes, cluster_size);
- ret = block_copy(s->bcs, off, end - off, true, 0, NULL, NULL);
+ /*
+ * Increase in_flight, so that in case of timed-out block-copy, the
+ * remaining background block_copy() request (which can't be immediately
+ * cancelled by timeout) is presented in bs->in_flight. This way we are
+ * sure that on bs close() we'll previously wait for all timed-out but yet
+ * running block_copy calls.
+ */
+ bs->in_flight++;
bdrv_inc_in_flight(bs)
+ ret = block_copy(s->bcs, off, end - off, true, s->cbw_timeout_ns,
+ block_copy_cb, bs);
if (ret < 0 && s->on_cbw_error == ON_CBW_ERROR_BREAK_GUEST_WRITE) {
return ret;
}
@@ -377,6 +395,7 @@ static BlockdevOptions *cbw_parse_options(QDict *options,
Error **errp)
*/
qdict_extract_subqdict(options, NULL, "bitmap");
qdict_del(options, "on-cbw-error");
+ qdict_del(options, "cbw-timeout");
I'm going to resend "[PULL 00/10] Block jobs & NBD patches" with this fix and
with fix in 03, if no objections.
--
Best regards,
Vladimir
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v4 6/7] block/copy-before-write: implement cbw-timeout option,
Vladimir Sementsov-Ogievskiy <=