rbd: implement 'export-diff' and 'import-diff' commands

Export a diff of an image from a previous snapshot to a file (or stdout).

Import a diff and apply it to an image, and then create the ending
snapshot.

Signed-off-by: Sage Weil <sage@inktank.com>
qa: add rbd/diff_continuous.sh stress test

Stress test that does io on an image while we are mirroring a diff from
earlier snaps to a second copy.  At the end, verify that all snaps have
matching content.

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: send import debug noise to dout, not stdout

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: handle diff from clone

If we have a parent image, and the reference is from snap 0 (beginning of
time) we need to look at the diff on the parent from the beginning of time
and report that when we get an ENOENT.

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: implement simple 'diff' command

Report extents allocated/changed, and whether they contain data or zeros.

Signed-off-by: Sage Weil <sage@inktank.com>
qa: rbd/diff_continuous.sh: base test off a clone

Get a bit of coverage on clones by starting with a clone.

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: fix diff_iterate arithmetic for non-standard striping

This code is confusing because we are moving back and forth between
image offsets, "buffer" offsets (image offsets relative to off), and
object offsets.  Fix the math.

Signed-off-by: Sage Weil <sage@inktank.com>
qa: rbd/diff_continuous.sh: use non-standard striping

Exercise the striping arithmetic by using non-standard striping that
varies between the parent and child.

Signed-off-by: Sage Weil <sage@inktank.com>
doc/dev/rbd-diff: update incremental file format

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: uint64_t len for diff_iterate

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: document diff_iterate in header

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: diff_iterate fromsnapname after the end snap is also invalid

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: drop unused elapsed calc for diff_iterate

Signed-off-by: Sage Weil <sage@inktank.com>
librados: document list_snaps

Signed-off-by: Sage Weil <sage@inktank.com>
librados: cleanly define SNAP_HEAD, SNAP_DIR constants

We were using the internal CEPH_NOSNAP and CEPH_SNAPDIR constants, and
defining a clone_info_t::HEAD (with a different value).  The docs were
referrring to the internal constant names.

Instead, define librados constants (C and C++) with the same values as the
internal types.

Note that this changes the clone_info_t::HEAD value from -1 to -2 so that
it now matches the internal type.

Signed-off-by: Sage Weil <sage@inktank.com>
librados: move snap_set_diff to librados/

This is most closely related to the librados list_snaps API; move it there.

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: set meaningful limit on snapshot name length

This should be enforced elsewhere too, but isn't yet.

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: implement image.snap_exists()

This is a much more convenient way to tell if a snapshot already exists.

Signed-off-by: Sage Weil <sage@inktank.com>
doc/dev/rbd-diff: specify that metadata records come before data

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: fail import-diff if end snap already exists

This will prevent a user from inadvertantly reapplying a diff twice.

Signed-off-by: Sage Weil <sage@inktank.com>