ReplicatedPG: Don't use the return value of getattr_maybe_cache as attr length.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
ReplicatedPG: For MAPEXT, using bl.length() instead of op.extent.length as num_rd_kb.

For fiemap, it don't real read the data(offset,length). It only fetech the infos of
extents. So don't use length as num_rd_kb.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
ReplicatedPG: Make pull and push op use sparse read

If user enable fiemap feature in osd side, there exists three ways to make
read/write sprase:

1. normal sparse read/write op
2. clone op
3. recover op

If any op doesn't support sparse way, it will destroy the advantage of this
way and write zero hole to sparse file. Now clone op can support sparse write,
this commit implement sparse read/write for recover op.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Merge pull request #2137 from yuyuyu101/pg-sparse-recovery

ReplicatedPG: Make recovery using fiemap and fix perf counter

sage-2014-12-16_08:43:28-powercycle-wip-sage-testing-distro

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #2530 from majianpeng/fiemap

Fiemap

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Samuel Just <sjust@redhat.com>
librbd: Stub out new exclusive image feature

When an image is flagged with the exclusive feature, only a
single client can modify the image.  This is groundwork for
an RBD object map optimization and for RBD mirroring.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
encoding: wrap ENCODE_START/FINISH arguments

Wrapped the bufferlist argument with parentheses to prevent
compile errors when attempting to pass a dereferenced bufferlist
pointer to the ENCODE_START/FINISH macros.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Create image exclusive lock watch/notify handler

The new watch/notify handler replaces the existing header
update watch/notify handler and adds support for managing
image exclusive lock leadership.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Integrate librbd with new exclusive lock feature

Operations that update the image now require the exclusive lock
if the feature is enabled.  AIO write and discard operations will
automatically request the exclusive lock from the current leader
to support live-migration.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
rbd: Allow CLI to optionally create shared images

Images that are flagged as shared cannot use the RBD
object map nor RBD mirroring features.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Add convenience library to support unit tests

Unit tests need access to the private symbols of librbd no
longer exported from librbd.so.  A new librbd_internal
convenience library was created to allow access.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Add ImageWatcher unit test cases

Directly unit test the new ImageWatcher class to complement
the existing librbd integration tests of exclusive lock
handling.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Add internal unit test cases

The new unit tests cover the modifications made to integrate
the internal librbd functionality with the new ImageWatcher.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: differentiate between R/O vs R/W RBD features

The new RBD exclusive lock feature should be treated as a
feature that is only applied when the image is opened in
R/W mode.

Older clients will need to handle the updated
cls_rbd::get_features method in order to properly determine
the incompatible features for an image depending on the
current mode.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>