Skip to contentSkip to conversation

RFC: incremental backups: qmp-block-dirty-bitmap-diff

Qemu-devel John Snow 2 participants 3 messages Feb 10, 2016 – Feb 22, 2016

lore
Share & tools
lore

John Snow

author
#0 lore raw

The thought was raised that it might be useful to create a "diff" command for bitmaps that allow us to populate a dirty bitmap based on the difference between a currently loaded disk image and some point-in-time stored on disk (an earlier full backup, incremental backup, etc).

I originally voiced a desire for this command in response to how to recover from a failed post-copy bitmap migration (Talks ongoing for if we'll pursue that, but let's not worry about that here.)

Another usage (apart from disaster recovery where we -- for whatever reason -- lost our bitmap or actually even lost an intermediate differential backup) for this kind of functionality would be to *start* a new incremental backup chain in a post-hoc fashion -- after we already made a full backup, but neglected to create a bitmap atomically.

There are some pros and cons here; I wanted to get a general "Yes, that sounds good" or a "No way, don't bother" before I sunk some hours into it, at Stefan's suggestion.

Cons:
- Added maintenance burden of yet-another-blockjob that does a fairly esoteric operation

- Catering to user carelessness. "You should have thought of that earlier!"

- Reading an entire drive could take quite a long time -- Especially if both the source and the target are through network storage.

- Reading an entire drive to populate a bitmap with the understanding that an incremental backup is soon to follow is inefficient if the drive is more than just a little dirty: it may have been quicker to just create a new full backup and bitmap.

- Not strictly unlocking new functionality in the normative case. (We do add 'bitmap rebuilding after a freak accident', but this is not the normative case.)

Pros:
- Since bitmaps (and persistent bitmaps) are off by default, it's nice to allow users to enable the feature post-hoc. The chance for a misconfiguration here seems reasonably good, especially considering the feature hasn't really hit all of the stable distros yet.

- Increases the flexibility overall of how to begin using the incremental backups feature.

- Allows us to sync bitmaps against images created by external tools if needed or desired by external backup appliances.

- If the image isn't that much different from the last good backup, reading the entire drive and writing out only a few changed blocks is likely to be faster than creating a new full backup, considering reads tend to be faster than writes -- reading the whole drive will be faster than writing a new full backup in many cases.

- The fact that a diff+incremental backup may be slower in some cases than just simply creating a new full backup isn't a good rationale for why we can't offer this tool for the cases in which it may outperform.

- Read of the last-known-good backup can be done in the background as a blockjob without impeding VM operation. Writes that occur during this process can be tracked in a temporary bitmap and merged after the diff completes.

#1 lore raw
Quoted 4 lines · John Snow

- Reading an entire drive to populate a bitmap with the understanding that an incremental backup is soon to follow is inefficient if the drive is more than just a little dirty: it may have been quicker to just create a new full backup and bitmap.

Above all I think this is a good idea. Just as an alternative, can we add another sync mode for drive-backup?

    (QMP) drive-backup device=d0 target=target.qcow2 format=qcow2 sync=diff \
                       base=full-backup.qcow2

(the data of d0 will be compared against full-backup.qcow2 and only different clusters will be copied to target.qcow2)

Fam

author
#2 lore raw
Quoted 9 lines · Fam Zheng
Quoted 4 lines · John Snow

- Reading an entire drive to populate a bitmap with the understanding that an incremental backup is soon to follow is inefficient if the drive is more than just a little dirty: it may have been quicker to just create a new full backup and bitmap.

Above all I think this is a good idea. Just as an alternative, can we add another sync mode for drive-backup?

Quoted 8 lines
    (QMP) drive-backup device=d0 target=target.qcow2 format=qcow2 sync=diff \
                       base=full-backup.qcow2

(the data of d0 will be compared against full-backup.qcow2 and only different clusters will be copied to target.qcow2)

Fam

I like this idea too, since it has the chance to do a lot of things for us all at once. If we allow a user to pass a bitmap that we can synchronize to this backup, it will be one command that can do a few things all at once.

Using the "bitmap-diff" approach [re-]establishes a bitmap, but still requires you to make the next backup. sync=diff just combines the two logical steps into one.

There are two phases here:
[Perform the diff] [Create a backup from that diff]

backup mode=diff as suggested above performs both, block-dirty-bitmap-diff as suggested previously performs just the first action, while we already have commands to perform the second.

I think arguably we'd only /need/ the bitmap-diff command, but I wouldn't personally mind having both for flexibility reasons (which historically don't fly too far on the qemu mailing list...)

I think I will move ahead with prototyping the QMP command and see how far I get. If it's not too bad I'll send some code out for further debate.

--js