From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com,
wencongyang2@huawei.com, xiechanglong.d@gmail.com,
qemu-devel@nongnu.org, armbru@redhat.com, jsnow@redhat.com,
stefanha@redhat.com, den@openvz.org, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH v11 02/14] block/backup: split shareable copying part from backup_do_cow
Date: Tue, 10 Sep 2019 13:23:20 +0300 [thread overview]
Message-ID: <20190910102332.20560-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20190910102332.20560-1-vsementsov@virtuozzo.com>
Split copying logic which will be shared with backup-top filter.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
block/backup.c | 47 ++++++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 15 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index 83c4fd284d..62a747b281 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -248,26 +248,18 @@ static int64_t backup_bitmap_reset_unallocated(BackupBlockJob *s,
return ret;
}
-static int coroutine_fn backup_do_cow(BackupBlockJob *job,
- int64_t offset, uint64_t bytes,
- bool *error_is_read,
- bool is_write_notifier)
+static int coroutine_fn backup_do_copy(BackupBlockJob *job,
+ int64_t start, uint64_t bytes,
+ bool *error_is_read,
+ bool is_write_notifier)
{
- CowRequest cow_request;
int ret = 0;
- int64_t start, end; /* bytes */
+ int64_t end = bytes + start; /* bytes */
void *bounce_buffer = NULL;
int64_t status_bytes;
- qemu_co_rwlock_rdlock(&job->flush_rwlock);
-
- start = QEMU_ALIGN_DOWN(offset, job->cluster_size);
- end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size);
-
- trace_backup_do_cow_enter(job, start, offset, bytes);
-
- wait_for_overlapping_requests(job, start, end);
- cow_request_begin(&cow_request, job, start, end);
+ assert(QEMU_IS_ALIGNED(start, job->cluster_size));
+ assert(QEMU_IS_ALIGNED(end, job->cluster_size));
while (start < end) {
int64_t dirty_end;
@@ -326,6 +318,31 @@ static int coroutine_fn backup_do_cow(BackupBlockJob *job,
qemu_vfree(bounce_buffer);
}
+ return ret;
+}
+
+static int coroutine_fn backup_do_cow(BackupBlockJob *job,
+ int64_t offset, uint64_t bytes,
+ bool *error_is_read,
+ bool is_write_notifier)
+{
+ CowRequest cow_request;
+ int ret = 0;
+ int64_t start, end; /* bytes */
+
+ qemu_co_rwlock_rdlock(&job->flush_rwlock);
+
+ start = QEMU_ALIGN_DOWN(offset, job->cluster_size);
+ end = QEMU_ALIGN_UP(bytes + offset, job->cluster_size);
+
+ trace_backup_do_cow_enter(job, start, offset, bytes);
+
+ wait_for_overlapping_requests(job, start, end);
+ cow_request_begin(&cow_request, job, start, end);
+
+ ret = backup_do_copy(job, start, end - start, error_is_read,
+ is_write_notifier);
+
cow_request_end(&cow_request);
trace_backup_do_cow_return(job, offset, bytes, ret);
--
2.18.0
next prev parent reply other threads:[~2019-09-10 10:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 10:23 [Qemu-devel] [PATCH v11 00/14] backup-top filter driver for backup Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 01/14] block/backup: fix backup_cow_with_offload for last cluster Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` Vladimir Sementsov-Ogievskiy [this message]
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 03/14] block/backup: improve comment about image fleecing Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 04/14] block/backup: introduce BlockCopyState Vladimir Sementsov-Ogievskiy
2019-09-13 18:25 ` Vladimir Sementsov-Ogievskiy
2019-09-20 12:46 ` Max Reitz
2019-09-20 12:56 ` Vladimir Sementsov-Ogievskiy
2019-09-20 12:56 ` Vladimir Sementsov-Ogievskiy
2019-09-20 13:26 ` Max Reitz
2019-09-20 13:32 ` Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 05/14] block/backup: fix block-comment style Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 06/14] block: move block_copy from block/backup.c to separate file Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 07/14] block: teach bdrv_debug_breakpoint skip filters with backing Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 08/14] iotests: prepare 124 and 257 bitmap querying for backup-top filter Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 09/14] iotests: 257: drop unused Drive.device field Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 10/14] iotests: 257: drop device_add Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 11/14] block/io: refactor wait_serialising_requests Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 12/14] block: add lock/unlock range functions Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 13/14] block: introduce backup-top filter driver Vladimir Sementsov-Ogievskiy
2019-09-10 10:23 ` [Qemu-devel] [PATCH v11 14/14] block/backup: use backup-top instead of write notifiers Vladimir Sementsov-Ogievskiy
2019-09-13 15:44 ` [Qemu-devel] [PATCH v11 00/14] backup-top filter driver for backup Vladimir Sementsov-Ogievskiy
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=20190910102332.20560-3-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=fam@euphon.net \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.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;
as well as URLs for NNTP newsgroup(s).