AsyncMessenger: Support select for other OS such as Windows

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Add tests for async drivers

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Fix select driver for add_event

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
tests: fix compilation warning

Signed-off-by: Loic Dachary <ldachary@redhat.com>
Merge pull request #2912 from dachary/wip-warning

tests: fix compilation warning

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Merge pull request #2909 from yuyuyu101/wip-10079

AsyncMessenger: Add select support and tests for async drivers
msg/Makefile: add new header to tarball

Signed-off-by: Sage Weil <sage@redhat.com>
Makefile: include 'ceph' in base target

This makes 'make base' enough to vstart.

Signed-off-by: Sage Weil <sage@redhat.com>
DNM: Squashed commit of the following:

commit a12d433f8eb48f0f15a638cc7b4a5ed8126cdfd7
Author: Sage Weil <sage@redhat.com>
Date:   Sun Nov 9 07:43:24 2014 -0800

    fix send ping now that lockign is different

commit 48ea4a8659cbb2b20e687995b69d4b6bdc55062d
Author: Sage Weil <sage@redhat.com>
Date:   Fri Oct 10 16:36:40 2014 -0700

    osdc/Objecter: fix tick() session locking

    We need to take the session read lock before traversing the ops lists.

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

commit e8e9c7593ba39bc992deecc5c0f5f047523f5d39
Author: Sage Weil <sage@redhat.com>
Date:   Sun Nov 9 07:43:01 2014 -0800

    osdc/Objecter: factor out _send_op_account()

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

commit b1b301099b713b97d920cd22193103712ba3c508
Author: Sage Weil <sage@redhat.com>
Date:   Sun Nov 9 07:42:34 2014 -0800

    osdc/Objecter: skip ping if PAUSERD

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

commit d59e30ff4d7b81e2f97ae0b2d07a1f835f57681e
Author: Sage Weil <sage@redhat.com>
Date:   Sun Nov 9 07:28:24 2014 -0800

    osdc/Objecter: do not resend PING messages

    On reconnect we will send a fresh reconnect.  Old pings will have no
    benefit.

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

commit b57875bb8502ff62f6c032bdb9c2fbe4a0cce2bf
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 20:01:50 2014 -0800

    osdc/Objecter: objecter_inject_no_watch_ping

    Tunable to prevent PINGs.  This will let us test paths the client gets
    disconnected from the OSD (at least from the client's perspective).

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

commit caac0ca4f468cfe8f7add0b762e62bb4534ef747
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 19:47:53 2014 -0800

    osdc/Objecter: stop sending pings once we get an error

    If we get ENOTCONN or ETIMEDOUT we can stop pinging.

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

commit a47b4d879db53b0d0d1581d6e4cc6ddc60c13192
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 19:45:21 2014 -0800

    osd/Watch: set timeout event for new watchers

    For a new watcher, we set the timeout event on connect, and reset it when
    we get a ping.

    For an old watcher, we continue to set the timeout on disconnect() and
    rely on the msgr Connection reset.

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

commit 5bbc1cda11997b0873059fd938b58f4cd1394707
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 19:38:24 2014 -0800

    make ping verify we are connected

commit 4b59400a3c14db424ca9c1e631fae8c09b0ca40c
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 19:26:03 2014 -0800

    osdc/Objecter: only ping watches (not notifies)

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

commit b5bbfd05118a837cd5932c2b466137ced67614c2
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 18:31:24 2014 -0800

    rados fix notify ack

commit 84b542af127be8ddae2b5571f9644e9e09dd448a
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 17:47:09 2014 -0800

    osd, librados: distinguish between old and new watchers

    Use a new watch op code that is different from the legacy one so we can
    tell when the client is doing all the new stuff (like sending pings).

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

commit 1f07ce93db855bc5a69b530c9d57694bb5e57af8
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 17:12:54 2014 -0800

    librados: tell watcher if we cause a notify timeout

    If we are a watcher and we fail to notify in a timely manner, or
    circumstances otherwise conspire to prevent out ack from arriving in time,
    initiate a callback.

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

commit a5c8082f3034a7fb95b0afa70c96fd3f74d9a2c0
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:36:43 2014 -0800

    osd/Watch: inform watchers when they cause a notify timeout

    If a watcher doesn't ack in time, let them know that they triggered a
    notify failure.

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

commit a8120788a166435ddfe4d4f83d082542d274b33f
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 17:10:18 2014 -0800

    librados: EINVAL on bad args to watch2

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

commit c1ab97bd3ea684dddd7ca0ed42251050780592b1
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 17:04:37 2014 -0800

    librados: behave if errcb is NULL

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

commit 4477a2fcd82c194bc7f6f645a73fa91dcfdc29b2
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:35:41 2014 -0800

    osd/Watch: drop redundant in_progress_watchers

    This is essentially watchers.size() at all times and obfuscates the code.
    In particular this makes the maybe_complete_notify() logic much clearer.

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

commit 202172106dd1aeef76def4e9728addc3eed1a7f6
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:18:32 2014 -0800

    Revert "osd: only send pending notifies on reconnect, not fresh watches"

    This reverts commit a883cd392258bade3e21a78441c6859d265e762e.

commit 24bf577a89f99627216e831d4a2476c2c90fc945
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:18:30 2014 -0800

    osd/Watch: fix comment typo

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

commit a70b06326925630a3e2e161acbc51e2ddc745534
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:13:23 2014 -0800

    ceph_test_rados_api_watch_notify: verify we get the right # of notifies

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

commit 1900fff5640b25494fcca7e0e85e2621f1c37f92
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 16:04:25 2014 -0800

    ceph_test_rados_api_watch_notify: s/handle/cookie/

    Use consist nameing for C and C++ tests.

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

commit 74a68d7a372d98106aaec688119e2f377544181b
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 15:58:02 2014 -0800

    osd: only send pending notifies on reconnect, not fresh watches

    If an existing watch reconnects, we must give them a chance on the
    in-progress notify because it will fail anyway if they don't ack it.

    However, a new watch should not receive a notify that initiated before it
    tried to add the watch.  It doesn't make sense from an API perspective, and
    on a practical level it means that even a well-behaved client may cause
    a notify to fail by adding the watch near the end of the notify timeout
    period when there isn't enough time for the notify to be processed.  (That
    would happen if another watcher is acking just in the nick of time.)

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

commit 6f66e270fc5448d4ec7e060beefc6a6c8b19c516
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 15:35:24 2014 -0800

    clean up CEPH_WATCH_EVENT_* namespace, and make COMPLETE distinct

    Use a proper prefix and make a separate event for the notify completion
    message.

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

commit c442891746dd6ee5a65c35d62a0938a276d3e596
Author: Sage Weil <sage@redhat.com>
Date:   Fri Nov 7 15:15:09 2014 -0800

    Revert "osd: assume WATCH_NOTIFY for MWatchNotify"

    This reverts commit 1197cfcb794b64b7c1e2ab8ce759c5e47330ec31.

commit df9f88ed9a66ee1a82c3fdfadb146fef3888df28
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 209ffaef93bf9b31fc6194a6cf60f295f2cd322e
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 5a64201f03a56a3368436569299a4e7652b40f1d
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 21e33307c23ab6419cd673030a53b19d8c63c5df
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 3e86da70e0c0e4c42a12195145678f315a763b9b
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 667c769ae04432a308ad1541633852f1d59d2c88
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>
DNM: osd: Fix PG compile error due to watch/notify changes

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
DNM: librados: Fix compile issues with watch_notify tests

Signed-off-by: Jason Dillaman <dillaman@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 add 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 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>