From: Jeff Cody <jcody@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, qemu-block@nongnu.org,
jsnow@redhat.com, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 17/20] backup: Switch backup_run() to byte-based
Date: Fri, 30 Jun 2017 17:25:35 -0400 [thread overview]
Message-ID: <20170630212535.GP4997@localhost.localdomain> (raw)
In-Reply-To: <20170627192458.15519-18-eblake@redhat.com>
On Tue, Jun 27, 2017 at 02:24:55PM -0500, Eric Blake wrote:
> We are gradually converting to byte-based interfaces, as they are
> easier to reason about than sector-based. Change the internal
> loop iteration of backups to track by bytes instead of sectors
> (although we are still guaranteed that we iterate by steps that
> are cluster-aligned).
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: John Snow <jsnow@redhat.com>
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
> ---
> v2: no change
> ---
> block/backup.c | 32 +++++++++++++++-----------------
> 1 file changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/block/backup.c b/block/backup.c
> index c029d44..04def91 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -370,11 +370,10 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
> int ret = 0;
> int clusters_per_iter;
> uint32_t granularity;
> - int64_t sector;
> + int64_t offset;
> int64_t cluster;
> int64_t end;
> int64_t last_cluster = -1;
> - int64_t sectors_per_cluster = cluster_size_sectors(job);
> BdrvDirtyBitmapIter *dbi;
>
> granularity = bdrv_dirty_bitmap_granularity(job->sync_bitmap);
> @@ -382,8 +381,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
> dbi = bdrv_dirty_iter_new(job->sync_bitmap, 0);
>
> /* Find the next dirty sector(s) */
> - while ((sector = bdrv_dirty_iter_next(dbi)) != -1) {
> - cluster = sector / sectors_per_cluster;
> + while ((offset = bdrv_dirty_iter_next(dbi) * BDRV_SECTOR_SIZE) >= 0) {
> + cluster = offset / job->cluster_size;
>
> /* Fake progress updates for any clusters we skipped */
> if (cluster != last_cluster + 1) {
> @@ -410,7 +409,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)
> /* If the bitmap granularity is smaller than the backup granularity,
> * we need to advance the iterator pointer to the next cluster. */
> if (granularity < job->cluster_size) {
> - bdrv_set_dirty_iter(dbi, cluster * sectors_per_cluster);
> + bdrv_set_dirty_iter(dbi,
> + cluster * job->cluster_size / BDRV_SECTOR_SIZE);
> }
>
> last_cluster = cluster - 1;
> @@ -432,17 +432,15 @@ static void coroutine_fn backup_run(void *opaque)
> BackupBlockJob *job = opaque;
> BackupCompleteData *data;
> BlockDriverState *bs = blk_bs(job->common.blk);
> - int64_t start, end;
> + int64_t offset;
> int64_t sectors_per_cluster = cluster_size_sectors(job);
> int ret = 0;
>
> QLIST_INIT(&job->inflight_reqs);
> qemu_co_rwlock_init(&job->flush_rwlock);
>
> - start = 0;
> - end = DIV_ROUND_UP(job->common.len, job->cluster_size);
> -
> - job->done_bitmap = bitmap_new(end);
> + job->done_bitmap = bitmap_new(DIV_ROUND_UP(job->common.len,
> + job->cluster_size));
>
> job->before_write.notify = backup_before_write_notify;
> bdrv_add_before_write_notifier(bs, &job->before_write);
> @@ -457,7 +455,8 @@ static void coroutine_fn backup_run(void *opaque)
> ret = backup_run_incremental(job);
> } else {
> /* Both FULL and TOP SYNC_MODE's require copying.. */
> - for (; start < end; start++) {
> + for (offset = 0; offset < job->common.len;
> + offset += job->cluster_size) {
> bool error_is_read;
> int alloced = 0;
>
> @@ -480,8 +479,8 @@ static void coroutine_fn backup_run(void *opaque)
> * needed but at some point that is always the case. */
> alloced =
> bdrv_is_allocated(bs,
> - start * sectors_per_cluster + i,
> - sectors_per_cluster - i, &n);
> + (offset >> BDRV_SECTOR_BITS) + i,
> + sectors_per_cluster - i, &n);
> i += n;
>
> if (alloced || n == 0) {
> @@ -499,9 +498,8 @@ static void coroutine_fn backup_run(void *opaque)
> if (alloced < 0) {
> ret = alloced;
> } else {
> - ret = backup_do_cow(job, start * job->cluster_size,
> - job->cluster_size, &error_is_read,
> - false);
> + ret = backup_do_cow(job, offset, job->cluster_size,
> + &error_is_read, false);
> }
> if (ret < 0) {
> /* Depending on error action, fail now or retry cluster */
> @@ -510,7 +508,7 @@ static void coroutine_fn backup_run(void *opaque)
> if (action == BLOCK_ERROR_ACTION_REPORT) {
> break;
> } else {
> - start--;
> + offset -= job->cluster_size;
> continue;
> }
> }
> --
> 2.9.4
>
next prev parent reply other threads:[~2017-06-30 21:25 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 19:24 [Qemu-devel] [PATCH v3 00/20] make bdrv_is_allocated[_above] byte-based Eric Blake
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 01/20] blockjob: Track job ratelimits via bytes, not sectors Eric Blake
2017-06-30 19:42 ` Jeff Cody
2017-07-04 15:28 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 02/20] trace: Show blockjob actions " Eric Blake
2017-06-30 19:56 ` Jeff Cody
2017-07-04 15:28 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 03/20] stream: Switch stream_populate() to byte-based Eric Blake
2017-06-30 19:57 ` Jeff Cody
2017-07-04 15:28 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 04/20] stream: Switch stream_run() " Eric Blake
2017-06-30 20:01 ` Jeff Cody
2017-07-04 15:00 ` Kevin Wolf
2017-07-05 12:13 ` Eric Blake
2017-07-05 13:41 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 05/20] commit: Switch commit_populate() " Eric Blake
2017-06-30 20:17 ` Jeff Cody
2017-07-04 15:28 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 06/20] commit: Switch commit_run() " Eric Blake
2017-06-30 20:19 ` Jeff Cody
2017-07-04 15:29 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 07/20] mirror: Switch MirrorBlockJob " Eric Blake
2017-06-30 20:20 ` Jeff Cody
2017-07-05 11:42 ` Kevin Wolf
2017-07-05 20:18 ` Eric Blake
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 08/20] mirror: Switch mirror_do_zero_or_discard() " Eric Blake
2017-06-30 20:22 ` Jeff Cody
2017-07-05 16:36 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 09/20] mirror: Update signature of mirror_clip_sectors() Eric Blake
2017-06-30 20:51 ` Jeff Cody
2017-07-05 16:37 ` Kevin Wolf
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 10/20] mirror: Switch mirror_cow_align() to byte-based Eric Blake
2017-06-30 21:03 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 11/20] mirror: Switch mirror_do_read() " Eric Blake
2017-06-30 21:07 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 12/20] mirror: Switch mirror_iteration() " Eric Blake
2017-06-30 21:14 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 13/20] block: Drop unused bdrv_round_sectors_to_clusters() Eric Blake
2017-06-30 21:17 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 14/20] backup: Switch BackupBlockJob to byte-based Eric Blake
2017-06-30 21:18 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 15/20] backup: Switch block_backup.h " Eric Blake
2017-06-28 0:38 ` Xie Changlong
2017-06-30 21:23 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 16/20] backup: Switch backup_do_cow() " Eric Blake
2017-06-30 21:24 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 17/20] backup: Switch backup_run() " Eric Blake
2017-06-30 21:25 ` Jeff Cody [this message]
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 18/20] block: Make bdrv_is_allocated() byte-based Eric Blake
2017-06-28 9:14 ` Juan Quintela
2017-06-30 21:32 ` Jeff Cody
2017-07-03 18:22 ` Eric Blake
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 19/20] block: Minimize raw use of bds->total_sectors Eric Blake
2017-06-28 8:57 ` [Qemu-devel] [Qemu-block] " Manos Pitsidianakis
2017-06-30 21:34 ` Jeff Cody
2017-06-27 19:24 ` [Qemu-devel] [PATCH v3 20/20] block: Make bdrv_is_allocated_above() byte-based Eric Blake
2017-06-28 0:38 ` Xie Changlong
2017-06-30 21:36 ` Jeff Cody
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=20170630212535.GP4997@localhost.localdomain \
--to=jcody@redhat.com \
--cc=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).