diff mbox

[V6,3/3] Add backing drive while performing backup.

Message ID 1374530960-22031-4-git-send-email-imain@redhat.com
State New
Headers show

Commit Message

Ian Main July 22, 2013, 10:09 p.m. UTC
This patch adds the original source drive as a backing drive to our target
image so that the target image will appear complete during backup.  This
is especially useful for SYNC_MODE_NONE as it allows export via NBD to
have a complete point-in-time snapshot available for export.

Signed-off-by: Ian Main <imain@redhat.com>
---
 block/backup.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Kevin Wolf July 24, 2013, 11:28 a.m. UTC | #1
Am 23.07.2013 um 00:09 hat Ian Main geschrieben:
> This patch adds the original source drive as a backing drive to our target
> image so that the target image will appear complete during backup.  This
> is especially useful for SYNC_MODE_NONE as it allows export via NBD to
> have a complete point-in-time snapshot available for export.
> 
> Signed-off-by: Ian Main <imain@redhat.com>

This isn't directly usable, right?

Let's complettely leave it out for now, it's incomplete and most likely
wrong, and that's not easy to fix right. I expect that Fam's patches (at
which I have to take a look yet) offer a more complete solution for
this, but I wouldn't consider any change that allows users to access the
backup target for 1.6, because the user can do all sorts of interesting
things with it then, which we probably don't check for in most cases.

Kevin
diff mbox

Patch

diff --git a/block/backup.c b/block/backup.c
index 68abd23..d32b3b7 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -323,6 +323,11 @@  static void coroutine_fn backup_run(void *opaque)
 
     hbitmap_free(job->bitmap);
 
+    /* Set the target backing drive back to NULL before calling delete or
+     * it will also delete the underlying drive. */
+    target->backing_hd = NULL;
+    bdrv_set_in_use(target, 0);
+
     bdrv_iostatus_disable(target);
     bdrv_delete(target);
 
@@ -362,6 +367,17 @@  void backup_start(BlockDriverState *bs, BlockDriverState *target,
         return;
     }
 
+    /* Manually set the backing hd to be the backup source drive so
+     * that all reads done while we are backing up will be passed
+     * on to the original source drive.  This allows reading from the
+     * image while the backup is in progress, or in the case of
+     * SYNC_MODE_NONE allows a complete image to be present for export.
+     * Note that we do this for all modes including SYNC_MODE_TOP as
+     * even then it allows on-the-fly reading. */
+    target->backing_hd = bs;
+    /* Set in use so it can only be exported by NBD. */
+    bdrv_set_in_use(target, 1);
+
     job->on_source_error = on_source_error;
     job->on_target_error = on_target_error;
     job->target = target;