Received: from eggs.gnu.org ([2001:4830:134:3::10]:49429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdeTu-000147-BV for qemu-devel@nongnu.org; Thu, 02 Apr 2015 08:44:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdeTt-0007ax-5z for qemu-devel@nongnu.org; Thu, 02 Apr 2015 08:44:22 -0400 Date: Thu, 2 Apr 2015 13:44:13 +0100 From: Stefan Hajnoczi Message-ID: <20150402124413.GE25244@stefanha-thinkpad.redhat.com> References: <1426879023-18151-1-git-send-email-jsnow@redhat.com> <1426879023-18151-11-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gMR3gsNFwZpnI/Ts" Content-Disposition: inline In-Reply-To: <1426879023-18151-11-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v4 10/20] qmp: Add support of "dirty-bitmap" sync mode for drive-backup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com, mreitz@redhat.com --gMR3gsNFwZpnI/Ts Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 20, 2015 at 03:16:53PM -0400, John Snow wrote: > + } else if (job->sync_mode == MIRROR_SYNC_MODE_DIRTY_BITMAP) { > + /* Dirty Bitmap sync has a slightly different iteration method */ > + HBitmapIter hbi; > + int64_t sector; > + int64_t cluster; > + int64_t last_cluster = -1; > + bool polyrhythmic; > + > + bdrv_dirty_iter_init(bs, job->sync_bitmap, &hbi); > + /* Does the granularity happen to match our backup cluster size? */ > + polyrhythmic = (bdrv_dirty_bitmap_granularity(job->sync_bitmap) != > + BACKUP_CLUSTER_SIZE); > + > + /* Find the next dirty /sector/ and copy that /cluster/ */ > + while ((sector = hbitmap_iter_next(&hbi)) != -1) { > + cluster = sector / BACKUP_SECTORS_PER_CLUSTER; > + > + /* Fake progress updates for any clusters we skipped, > + * excluding this current cluster. */ > + if (cluster != last_cluster + 1) { > + job->common.offset += ((cluster - last_cluster - 1) * > + BACKUP_CLUSTER_SIZE); > + } > + > + if (yield_and_check(job)) { > + goto leave; > + } > + > + do { > + ret = backup_do_cow(bs, cluster * BACKUP_SECTORS_PER_CLUSTER, > + BACKUP_SECTORS_PER_CLUSTER, &error_is_read); > + if ((ret < 0) && > + backup_error_action(job, error_is_read, -ret) == > + BLOCK_ERROR_ACTION_REPORT) { > + goto leave; > + } > + } while (ret < 0); > + > + /* Advance (or rewind) our iterator if we need to. */ > + if (polyrhythmic) { > + bdrv_set_dirty_iter(&hbi, > + (cluster + 1) * BACKUP_SECTORS_PER_CLUSTER); > + } > + > + last_cluster = cluster; > + } What happens when the dirty bitmap granularity is larger than BACKUP_SECTORS_PER_CLUSTER? |-----bitmap granularity-----| |---backup cluster---| ~~~~~~~ Will these sectors ever be copied? I think this case causes an infinite loop: cluster = hbitmap_iter_next(&hbi) / BACKUP_SECTORS_PER_CLUSTER The iterator is reset: bdrv_set_dirty_iter(&hbi, (cluster + 1) * BACKUP_SECTORS_PER_CLUSTER); So we get the same cluster ever time and never advance? --gMR3gsNFwZpnI/Ts Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVHTmdAAoJEJykq7OBq3PIcHwH/j+5Y+Ujn9+60NLqxiK4mR4p V+cYtOIBbx//dG2iaBMfQJOpGPUlJBhekyqqUDN62R7A+OA1/3aPAHr7DmWJVw7E djvs9sw8LrAYd66K5qzdp9f02PoxZZjPAWJSqa0+M6CPJin1Qi53bFIEoT4Cv1YO JFgcpYONjQvPhq5IYJ1JFHf/G4mHDBZXLkBf04bJJ94tisVuVFn68CUrCytf1smg 1AH5tvD7Vwyi79nYoNJ4pf/om9/uM00X/JK542DsmHS3CAgF7J1pql9Pn/kiJPfi AvHlcesF8RVeOi8yfSSgTnrs4I6eXs6O3dzN/zUyjn0RRo6ovngi3/rub4pmxOk= =ECo6 -----END PGP SIGNATURE----- --gMR3gsNFwZpnI/Ts--