From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, jsnow@redhat.com,
famz@redhat.com, den@openvz.org, stefanha@redhat.com,
vsementsov@virtuozzo.com, pbonzini@redhat.com, jcody@redhat.com
Subject: [Qemu-devel] [PATCH 21/21] backup: refactor: remove backup_do_cow()
Date: Fri, 23 Dec 2016 17:29:04 +0300 [thread overview]
Message-ID: <1482503344-6424-22-git-send-email-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <1482503344-6424-1-git-send-email-vsementsov@virtuozzo.com>
Call backup_copy_cluster directly from backup_worker_co. Move io buffer
allocation to backup_worker_co (and do not reallocate it for each
cluster).
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/backup.c | 28 +++++++++-------------------
block/trace-events | 6 ++----
2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index b79a481..4a3a874 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -222,8 +222,6 @@ static void release_pending_notifiers(BackupBlockJob *job)
}
}
-static void coroutine_fn backup_do_cow(BackupBlockJob *job, int64_t cluster);
-
/* Size of a cluster in sectors, instead of bytes. */
static inline int64_t cluster_size_sectors(BackupBlockJob *job)
{
@@ -403,9 +401,14 @@ static inline int64_t backup_get_work(BackupBlockJob *job)
return cluster;
}
+static void coroutine_fn backup_copy_cluster(BackupBlockJob *job,
+ int64_t cluster,
+ void *bounce_buffer);
+
static void coroutine_fn backup_worker_co(void *opaque)
{
BackupBlockJob *job = opaque;
+ void *io_buf = blk_blockalign(job->common.blk, job->cluster_size);
job->running_workers++;
job->nb_busy_workers++;
@@ -424,12 +427,13 @@ static void coroutine_fn backup_worker_co(void *opaque)
trace_backup_worker_stop(qemu_coroutine_self(),
job->nb_busy_workers, job->running_workers,
job->waiting_for_workers);
+ qemu_vfree(io_buf);
return;
case BACKUP_WORKER_PAUSE:
backup_worker_pause(job);
break;
default:
- backup_do_cow(job, cluster);
+ backup_copy_cluster(job, cluster, io_buf);
}
}
}
@@ -546,8 +550,7 @@ static void coroutine_fn backup_copy_cluster(BackupBlockJob *job,
int64_t sectors_per_cluster = cluster_size_sectors(job);
int64_t offset = cluster * job->cluster_size;
- trace_backup_do_cow_process(job, cluster);
-
+ trace_backup_copy_cluster_enter(job, qemu_coroutine_self(), cluster);
n = MIN(sectors_per_cluster,
job->common.len / BDRV_SECTOR_SIZE -
cluster * sectors_per_cluster);
@@ -579,20 +582,7 @@ static void coroutine_fn backup_copy_cluster(BackupBlockJob *job,
*/
job->sectors_read += n;
job->common.offset += n * BDRV_SECTOR_SIZE;
-}
-
-static void coroutine_fn backup_do_cow(BackupBlockJob *job, int64_t cluster)
-{
- BlockBackend *blk = job->common.blk;
- void *bounce_buffer;
-
- trace_backup_do_cow_enter(job, qemu_coroutine_self(), cluster);
-
- bounce_buffer = blk_blockalign(blk, job->cluster_size);
- backup_copy_cluster(job, cluster, bounce_buffer);
- qemu_vfree(bounce_buffer);
-
- trace_backup_do_cow_return(job, qemu_coroutine_self(), cluster);
+ trace_backup_copy_cluster_success(job, qemu_coroutine_self(), cluster);
}
static int coroutine_fn backup_before_write_notify(
diff --git a/block/trace-events b/block/trace-events
index 54cde28..770b407 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -40,10 +40,8 @@ mirror_yield_buf_busy(void *s, int nb_chunks, int in_flight) "s %p requested chu
mirror_break_buf_busy(void *s, int nb_chunks, int in_flight) "s %p requested chunks %d in_flight %d"
# block/backup.c
-backup_do_cow_enter(void *job, void *self, int64_t cluster) "job %p self %p cluster %"PRId64
-backup_do_cow_return(void *job, void *self, int64_t cluster) "job %p self %p cluster %"PRId64
-backup_do_cow_skip(void *job, int64_t cluster) "job %p cluster %"PRId64
-backup_do_cow_process(void *job, int64_t cluster) "job %p cluster %"PRId64
+backup_copy_cluster_enter(void *job, void *self, int64_t cluster) "job %p self %p cluster %"PRId64
+backup_copy_cluster_success(void *job, void *self, int64_t cluster) "job %p self %p cluster %"PRId64
backup_do_read_fail(void *job, void *self, int64_t offset, unsigned bytes, int ret) "job %p self %p offset %"PRId64" bytes %u ret %d"
backup_do_write_fail(void *job, void *self, int64_t offset, unsigned bytes, int ret) "job %p self %p offset %"PRId64" bytes %u ret %d"
backup_job_wait_workers_start(void) ""
--
1.8.3.1
next prev parent reply other threads:[~2016-12-23 15:30 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-23 14:28 [Qemu-devel] [PATCH 00/21] new backup architecture Vladimir Sementsov-Ogievskiy
2016-12-23 14:28 ` [Qemu-devel] [PATCH 01/21] backup: move from done_bitmap to copy_bitmap Vladimir Sementsov-Ogievskiy
2017-01-23 5:34 ` Jeff Cody
2017-01-23 12:20 ` Vladimir Sementsov-Ogievskiy
2017-01-31 10:25 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 02/21] backup: init copy_bitmap from sync_bitmap for incremental Vladimir Sementsov-Ogievskiy
2017-01-24 7:09 ` Fam Zheng
2017-01-24 9:00 ` Vladimir Sementsov-Ogievskiy
2017-01-24 9:46 ` Fam Zheng
2017-01-24 10:16 ` Vladimir Sementsov-Ogievskiy
2017-01-31 10:36 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 03/21] backup: improve non-dirty bits progress processing Vladimir Sementsov-Ogievskiy
2017-01-24 7:17 ` Fam Zheng
2017-01-24 9:12 ` Vladimir Sementsov-Ogievskiy
2017-01-31 10:56 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 04/21] backup: use copy_bitmap in incremental backup Vladimir Sementsov-Ogievskiy
2017-01-31 11:01 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 05/21] hbitmap: improve dirty iter Vladimir Sementsov-Ogievskiy
2017-01-31 11:20 ` Stefan Hajnoczi
2017-01-31 11:29 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 06/21] backup: rewrite top mode cluster skipping Vladimir Sementsov-Ogievskiy
2017-01-31 13:31 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 07/21] backup: refactor: merge top/full/incremental backup code Vladimir Sementsov-Ogievskiy
2017-01-31 14:26 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 08/21] backup: skip unallocated clusters for full mode Vladimir Sementsov-Ogievskiy
2017-01-24 7:59 ` Fam Zheng
2017-01-24 9:18 ` Vladimir Sementsov-Ogievskiy
2017-01-24 9:36 ` Fam Zheng
2017-01-24 10:13 ` Vladimir Sementsov-Ogievskiy
2017-01-24 11:12 ` Fam Zheng
2017-01-31 14:33 ` Stefan Hajnoczi
2017-01-31 14:38 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 09/21] backup: separate copy function Vladimir Sementsov-Ogievskiy
2017-01-31 14:40 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 10/21] backup: refactor backup_copy_cluster() Vladimir Sementsov-Ogievskiy
2017-01-31 14:57 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 11/21] backup: move r/w error handling code to r/w functions Vladimir Sementsov-Ogievskiy
2017-01-31 14:57 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 12/21] iotests: add supported_cache_modes to main function Vladimir Sementsov-Ogievskiy
2017-01-31 14:58 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 13/21] coroutine: add qemu_coroutine_add_next Vladimir Sementsov-Ogievskiy
2017-01-31 15:03 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 14/21] block: add trace point on bdrv_close_all Vladimir Sementsov-Ogievskiy
2017-01-31 15:03 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 15/21] bitmap: add bitmap_count_between() function Vladimir Sementsov-Ogievskiy
2017-01-31 15:15 ` Stefan Hajnoczi
2016-12-23 14:28 ` [Qemu-devel] [PATCH 16/21] hbitmap: add hbitmap_count_between() function Vladimir Sementsov-Ogievskiy
2017-01-31 15:56 ` Stefan Hajnoczi
2016-12-23 14:29 ` [Qemu-devel] [PATCH 17/21] backup: make all reads not serializing Vladimir Sementsov-Ogievskiy
2017-01-31 16:30 ` Stefan Hajnoczi
2016-12-23 14:29 ` [Qemu-devel] [PATCH 18/21] backup: new async architecture Vladimir Sementsov-Ogievskiy
2017-01-31 16:46 ` Stefan Hajnoczi
2017-02-01 16:13 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-12-23 14:29 ` [Qemu-devel] [PATCH 20/21] backup: move bitmap handling from backup_do_cow to get_work Vladimir Sementsov-Ogievskiy
2016-12-23 14:29 ` Vladimir Sementsov-Ogievskiy [this message]
2017-01-09 11:04 ` [Qemu-devel] [PATCH 00/21] new backup architecture Stefan Hajnoczi
2017-01-10 6:05 ` Jeff Cody
2017-01-10 18:48 ` John Snow
2017-01-31 10:20 ` Stefan Hajnoczi
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=1482503344-6424-22-git-send-email-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).