PG: always clear_primary_state when leaving Primary

Otherwise, entries from the log collection process might leak into the next
epoch, where we might end up choosing a different authoritative log.  In this
case, it resulted in us not rolling back to log entries on one of the replicas
prior to trying to recover from an affected object due to the peer_missing not
being cleared.

Fixes: #10059
Backport: giant, firefly, dumpling
Signed-off-by: Samuel Just <sjust@redhat.com>
PG: always clear_primary_state on new interval, but only clear pg temp if not primary

Signed-off-by: Samuel Just <sjust@redhat.com>
ReplicatedPG: fail a non-blocking flush if the object is being scrubbed

Fixes: #8011
Backport: firefly, giant
Signed-off-by: Samuel Just <sjust@redhat.com>
ReplicatedPG::scan_range: an object can disappear between the list and the attr get

The first item in the range is often last_backfill, upon which writes
can be occuring.  It's trimmed off on the primary side anyway.

Fixes: 10150
Backport: dumpling, firefly, giant
Signed-off-by: Samuel Just <sjust@redhat.com>
PGLog: include rollback_info_trimmed_to in (read|write)_log

Fixes: #10157
Backport: firefly, giant
Signed-off-by: Samuel Just <sjust@redhat.com>
AsyncMessenger: Async event threads shared by all AsyncMessenger

WorkerPool is a singleton class which is served to AsyncMessenger. All
AsyncMessenger used the same worker pool.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Ensure "mark_down" complete when returned

Now AsyncConnection try to process or modify any own variables within self
thread. It means actual function will be called by event loop not external.
So we can avoid lockdep or unnecessary lock for AsyncConnection.

So "mark_down" should be returned after _stop completed and all events has
be processed.

"external" for unregister_conn is unnecessary, because the caller won't
own AsyncMessenger::Lock again.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Introduce "signal" event

Ensure signal cond after all previous events has be done

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Event: Fix Coverity error

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Avoid deadlock for AsyncConnection::lock

accept and connection will be send to queue and deliver to dispatcher. So
it can avoid caller stuck into AsyncConnection::lock deadlock

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Skip delete_file_event if sd < 0

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Fix thread destroy when no active Messenger

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Cycles: A precious performance profile tool using rdstc

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
ObjectStoreBenchmark: Used to perf ObjectStore::Transaction

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
CephContext: Add AssociatedSingletonObject to allow CephContext's singleton

If some objects associated to CephContext want to create a singleton object,
it can inherit AssociatedSingletonObject and implement destruction to get notified.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Make WorkerPool use CephContext's singleton

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
common/Initialize.h: add header file to Makefile.am

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
common: bufferlist::get_contiguous return 0 when param len == 0

Change-Id: I3eaee45b12c634687cd1b294b3c264aed8cab03a
Signed-off-by: Dong Yuan <yuandong1222@gmail.com>
Merge pull request #3094 from yuandong1222/bufferlist-get_contiguous

common: bufferlist::get_contiguous return 0 when param len == 0

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #3043 from yuyuyu101/objectstore-perf

Objectstore::Transaction Perf Program

Reviewed-by: Sage Weil <sage@redhat.com>