DNM: Squashed commit of the following:

commit 7e553e71a03b6c6cca12d1770e604172270ae836
Author: Jason Dillaman <dillaman@redhat.com>
Date:   Thu Oct 9 00:00:17 2014 -0400

    librbd: Coordinate maintenance through exclusive lock leader

    When the exclusive lock feature is enabled, only a single client can
    modify the image.  As a result, certain maintenance activities
    need to be proxied from the maintenance client to the active
    leader.

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

commit c6cf61867064b57041eea9fe2adc87d4649451dc
Author: Jason Dillaman <dillaman@redhat.com>
Date:   Wed Oct 8 23:25:28 2014 -0400

    librbd: Add maintenance operation requests to ImageWatcher

    Snapshot, flatten, and resize maintenance operations can now
    be coordinated via the client holding the exclusive lock for the
    image.

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

commit 4796e476fb6391f701e818f348a911a6bd9e6951
Author: Jason Dillaman <dillaman@redhat.com>
Date:   Sun Sep 28 03:46:04 2014 -0400

    librados: Expose RadosClient instance id through librados

    Allow librados clients to utilize the global id of the RadosClient.

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

commit 7facd612569c405d5541eedcd9edaadcb7e8d3fa
Author: Jason Dillaman <dillaman@redhat.com>
Date:   Mon Nov 10 12:25:50 2014 -0500

    librbd: Create async versions of long-running maintenance operations

    Resize and flatten now have async versions. The existing resize
    and flatten operations now use the async versions internally. The
    async operations will be used by the client holding the exclusive
    lock when it receives maintenance requests from other clients.

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

commit ddddbc729677571dd45af4fbf6a7ee3c555292e0
Author: Jason Dillaman <dillaman@redhat.com>
Date:   Wed Nov 5 02:49:37 2014 -0500

    Squashed commit of the following:

    commit 2aae01b41cb8658dc5e685b39b37500e2201e382
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Mon Nov 3 16:51:06 2014 -0500

        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>

    commit 2c1053ddb7a05eada40d76026ac37dbf86daa652
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Mon Oct 20 22:09:29 2014 -0400

        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>

    commit 35cd45e6dac9db4e23b910ebd85a00dc0c80d5ab
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Fri Oct 17 09:05:22 2014 -0400

        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>

    commit 3bed84ad5bfadc002795c033dc5ac76c8908b468
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Wed Oct 1 16:12:21 2014 -0400

        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>

    commit cc901901447af959225a526775d7b5efe630c0ac
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Wed Oct 8 08:41:53 2014 -0400

        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>

    commit 752021eecdb231aaede8e63855c34eb1be9dcd81
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Wed Oct 8 08:20:47 2014 -0400

        librbd: Create image exclusive lock watch/notify handler

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

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

    commit 4056e167c855df8c72c5a4db0346e91503a8841c
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Tue Oct 7 16:23:03 2014 -0400

        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>

    commit 298eb135388f0eb28a91cb39d37972867221c3b2
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Tue Oct 7 14:17:50 2014 -0400

        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>

    commit d784e61233227e552b100778f1af9c6ca4045e8e
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Tue Nov 4 18:49:17 2014 -0500

        DNM: osdc: Temporary workaround to linger ping deadlock

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

    commit 0e8d2fe3b86b91f033587a9e4cd04f678a04cdc5
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Tue Oct 21 20:24:52 2014 -0400

        DNM: osd: Fix PG compile error due to watch/notify changes

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

    commit d009ce336af1f9a6d6f082eeb3a771d2711098f5
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Mon Oct 20 13:54:51 2014 -0400

        DNM: librados: Fix compile issues with watch_notify tests

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

    commit f326447d5bb4320c4fb33406b99587275e86549d
    Merge: a554766 cc116b1
    Author: Jason Dillaman <dillaman@redhat.com>
    Date:   Tue Nov 4 20:01:54 2014 -0500

        Merge remote branch 'upstream/wip-watch-notify' into HEAD

    commit cc116b16de2ac7522751f78de33085101df986e6
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:19:00 2014 -0700

        osdc/Objecter: send regular PING ops

        Send a full PING op to the object to ensure we are still connected. For
        now just use the existing ping interval; we may want to change this in
        the future.

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

    commit 3816e3471abb34296a3a7f2616f413e0ef62a0a6
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:17:40 2014 -0700

        osdc/Objecter: queue an error if reconnect fails

        If we fail to reconnect, trigger the on_error (reusable) context to
        let the user know about it.

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

    commit 81ccf6cbc7f9d9a53653dc414d3a2e53f030d4f7
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:16:07 2014 -0700

        osdc/Objecter: separate WATCH from RECONNECT

        Use WATCH op for the initial registration.  This is idempotent in that
        it will succeed whether the watch information has been persisted or not.
        It is used by the client if it does not know that it is registered.

        The RECONNECT op is used for any subsequent session reconnect.  It will
        fail if the watch state isn't already persisted on the OSD.

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

    commit 3bad110b687492cdc041378dd3405572640fa5d5
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:12:22 2014 -0700

        rados: improve watch command output

        - hexdump the notify payload, and include all of the new metadata
        - print error events too

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

    commit cd4c4cecd5c14e15cf0a2251c25b19c5859c0381
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:11:43 2014 -0700

        librados: add infrastructure to deliver an error notification

        Use a reusable context in the WatchNotifyInfo to trigger an error
        event, delivered via the existing Finisher thread.  Re-lookup the cookie
        in the thread to cope with races with unregister (just as we do with
        notify events).

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

    commit f4b50fca34c52d66da05c949a61e4a7aa0ad989e
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 20:09:07 2014 -0700

        librados: define error callback

        This is the async notification of a watch error (failure to reconnect to
        the object's OSD after a peering event or network disconnect).

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

    commit 69b40643924d94580b6fdb11821a6a4b2f9b8c09
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 19:52:52 2014 -0700

        librados: remove crufty declaration

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

    commit 1e8e54c3a9eaeb86c982af5cd3fc339a08f1e2b8
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 19:28:53 2014 -0700

        osd/ReplicatedPG: handle PING and RECONNECT watch ops

        The ping will essentially assert that a watch is still valid.

        A reconnect will reestablish session state *only* if the watch is
        still persistent.  If not, it will fail (and the client will know it
        may have missed something).

        Note that the only difference here is that a PING is a bit lighter
        weight; it will not reestablish the session state (which should already
        be established).  We could use a single op here but the unique op
        code makes the messages easier to understand and simplifies the code
        path a bit for PING.

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

    commit d44d9c7d52c3c3a98e14f7f67372a492ae5fdbd7
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 16 19:26:17 2014 -0700

        librados: define RECONNECT and PING watch ops

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

    commit 14f7803aa35a996051d6b31c5539a1d8c5bfc586
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 9 18:14:53 2014 -0700

        osdc/Objecter: fix assert_src_version

        Don't use the add_watch() helper; do it like assert_version
        does it.

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

    commit 861944e9311e240c8161d2c890218a979b085173
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 9 18:14:15 2014 -0700

        librados: use new watch op codes; simplify Objecter helpers

        - drop the useless add_watch() helper; do it explicitly
        - drop the unused var arg everywhere
        - make a separate notify member of the union that excludes
          the other unused fields

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

    commit 096b1136209770d6d0db77a92f99580ffb005755
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 9 18:11:44 2014 -0700

        librados: define CEPH_OSD_WATCH_OP_*

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

    commit 1197cfcb794b64b7c1e2ab8ce759c5e47330ec31
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 9 17:42:34 2014 -0700

        osd: assume WATCH_NOTIFY for MWatchNotify

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

    commit 367e99b508903be0ec0d7700cdd6bcc80a802029
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Oct 9 17:42:14 2014 -0700

        librados: unconditionally pass WATCH_NOTIFY to legacy callback

        This was always WATCH_NOTIFY; just pass that explicitly.  No need to
        pay attention to what's in the message.

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

    commit 73797d0878cb8e991eb594debc2b15b9e84e7dee
    Author: Sage Weil <sage@redhat.com>
    Date:   Wed Oct 8 08:25:45 2014 -0700

        osd: allow multiple watchers/notify replies per client

        It is perfectly valid to register multiple watchers via the same
        librados client.  Make the notify_replies a multimap to capture all
        of the acks.

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

    commit 6b0d4976dcf02c9203c7e2c4ce87121c30df34b8
    Author: Sage Weil <sage@redhat.com>
    Date:   Tue Oct 7 15:56:52 2014 -0700

        librados: include notifier's gid in notify

        The notify replies include the identify of everyone who acked the
        notify.  For symmetry, inform the notified client who sent the notify.

        Fixes: #9198
        Signed-off-by: Sage Weil <sage@redhat.com>

    commit ac78f315b42960b824d733f182bbb914ca5ade67
    Author: Sage Weil <sage@redhat.com>
    Date:   Tue Oct 7 15:28:55 2014 -0700

        ceph_test_rados_api_watch_notify: test notify2 api

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

    commit c10e4791132a91852f22b2967168b5ca00162979
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Aug 21 14:52:34 2014 -0700

        librados: update notify2 API to accept reply payloads

        Allow the notify2 callers to provide bufferlists or char ** pointers
        so that we can pass the reply buffer back to them.

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

    commit 7f8003a7ddfd513fa0f710535d7060e635795f77
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Aug 21 14:46:35 2014 -0700

        osd: implement notify ack payloads

        If the notified send back reply payloads, pass them back to the notifier.

        Note that we have changed the on-wire behavior of the watch completion
        message a bit: instead of sending the original notify payload back to the
        notifier, we send the map of notified to replies.  Note that only users of
        the new API will know what to do with the notify acknowledgement
        information.  At the same time, we stop sending the original payload.
        However, the old API users never saw that data; we were uselessly sending
        it over the wire.

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

    commit 096fc63530d16dfae4b59092dfae25ee297f02fe
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Aug 21 14:32:48 2014 -0700

        librados: define updated watch/notify interface

        - new notify callback with the correct values:
          - notify_id
          - watch handle
          - payload
        - new notify_ack call
          - not implicit when the callback returns (for new api only)
          - optional payload
        - new watch2 call
          - that provides the new callback
        - new notify2 call
          - with the right arguments, and optional timeout

        A couple refactors in here:
        - IoCtx notify_ack is now called unlocked (Note: this will soon change
          with pending Objecter locking changes)
        - Objecter notify_ack takes a buffer

        TODO:
        - no timeout on the individual watch, yet...

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

    commit 4ba535adca51f0329325a2330a6a7c8861ea3a03
    Author: Sage Weil <sage@redhat.com>
    Date:   Thu Aug 21 13:38:17 2014 -0700

        librados: drop useless ver arg to _notify_ack

        Signed-off-by: Sage Weil <sage@redhat.com>
librados: Add exec_mutable operation

The existing exec operation does not pass the current
snapshot context.  The new exec_mutable operation
includes the snapshot context so that methods which
update objects can be rolled back.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
cls_rbd: Add methods for manipulating an image object map

The object map will track the current state of each object
within an RBD image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Implement object map for tracking in-use objects

The object map is stored in a new 'rbd_object_map.<id>'
object in the image's pool. The object map tracks blocks
that are in-use, non-existent, and are pending deletion.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Use object map for IO operations

When the RBD exclusive lock is enabled, IO operations
now check whether or not an object exists before
sending a IO operation to RADOS.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
cls_rbd: Add support for image flags

Image flags are an optional addition to the RBD image header
which can be used to preserve state.  The flags support
snapshot history.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
librbd: Use RBD image flags for invalid object maps

If the RBD object map state is corrupted, flag the object map
as invalid so that it won't be used for IO operations.

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