ceph_mon: check for existing mon store before opening db

This will make sure that the monitor data directory is populated before
proceeding to opening it up.  We have to do this in order to work around
leveldb, which will create 'store.db' (even though it won't populate it)
upon opening the database.  Unwillingly, running the monitor without
first issuing a mkfs would have us ending up with a 'store.db' in the
monitor's data directory, and later on we would get errors from the
monitor not finding magic values within the store -- which given mkfs
hadn't been run isn't surprising.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: fix occasional message leak after session reset

Consider:

 - we get a message, put it on a wait list
 - the client session resets
 - we go back to process the message later and discard
   - _ms_dispatch returns false, but nobody drops the msg ref

Since we call _ms_dispatch() a lot internally, we need to always return
true when we are an internal caller.

Fixes: #9176
Backport: firefly, dumpling
Signed-off-by: Sage Weil <sage@redhat.com>
mon: always process the message in dispatch

Nobody should be chained after teh mon, so we can safely drop any message
we don't understand.

Signed-off-by: Sage Weil <sage@redhat.com>
mon: make dispatch(), _ms_dispatch() void

They always return true.

Signed-off-by: Sage Weil <sage@redhat.com>
Merge pull request #2301 from ceph/wip-9176

mon: fix occasional memory leak; clean up dispatch return codes

Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
needs network or it will not start if enabled

example error message: "unable to find any IP address in networks: 10.2.27.0/25", so the service wont start
common: remove spurious uint32_t in buffer.c

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
rgw: admin ops create user API can not determine existing user

Fixes: #8583

Signed-off-by: Ray Lv <raylv@yahoo-inc.com>
CollectionIndex: Collection name is added to the access_lock name

The CollectionIndex constructor is changed to accept the coll_t
so that the collection name can be used to form access_lock(RWLock)
name.This is needed otherwise lockdep will report a recursive lock error
and assert. lockdep needs unique lock names for each Index object.

Fixes: #9145

Signed-off-by: Somnath Roy <somnath.roy@sandisk.com>
(cherry picked from commit 615d2d904024526cc58557ee5250c2536a3cd5c8)
ceph_test_rados_api_tier: make PromoteOn2ndRead test tolerate retries

If there is an ill-timed connection reset our read could get sent twice.
Weaken our assertion if the read was slow to tolerate this case.

Fixes: #9221
Signed-off-by: Sage Weil <sage@redhat.com>
rgw: fix test to identify whether object has tail

Fixes: #9226
Reported-by: Sylvain Munaut <s.munaut@whatever-company.com>
Backport: firefly

We need to identify whether an object is just composed of a head, or
also has a tail. Test for pre-firefly objects ("explicit objs") was
broken as it was just looking at the number of explicit objs in the
manifest. However, this is insufficient, as we might have empty head,
and in this case it wouldn't appear, so we need to check whether the
sole object is actually pointing at the head.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Merge pull request #2320 from ceph/wip-9221

ceph_test_rados_api_tier: make PromoteOn2ndRead test tolerate retries

Reviewed-by: Samuel Just <sam.just@inktank.com>
osd/OSDMap: encode blacklist in deterministic order

When we use an unordered_map the encoding order is non-deterministic,
which is problematic for OSDMap.  Construct an ordered map<> on encode
and use that.  This lets us keep the hash table for lookups in the general
case.

Fixes: #9211
Backport: firefly
Signed-off-by: Sage Weil <sage@redhat.com>
Merge pull request #2321 from ceph/wip-9226

rgw: fix test to identify whether object has tail

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #2330 from ceph/wip-9211

osd/OSDMap: encode blacklist in deterministic order

Reviewed-by: Samuel Just <sam.just@inktank.com>
tests: histogram prevent re-use of local variables

By moving the test to a separate function.

http://tracker.ceph.com/issues/9235 Fixes: #9235

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Merge pull request #2333 from dachary/wip-9235-uninitialized-variables

tests: histogram prevent re-use of local variables

Reviewed-by: Sage Weil <sage@redhat.com>
tests: histogram prevent re-use of local variables

By moving the tests to separate functions.

http://tracker.ceph.com/issues/9235 Fixes: #9235

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Merge pull request #2334 from dachary/wip-9235-uninitialized-variables

tests: histogram prevent re-use of local variables
common: config: let us obtain a diff between current and default config

It's mildly annoying when trying to figure out what has been changed on
a running system's config options and having to rely on whatever is set
on ceph.conf and the admin's memory of what has been injected.

With this we can simply ask the daemon for the diff between what would be
its default and what is its current config.

Current form will output extraneous information that was not directly
supplied by the user though, such as 'host' 'fsid' and 'daemonize', as
well as defaults we may rewrite ourselves (leveldb tunables on the monitor
for instance).  Nonetheless, it's way better than the alternative and
considering it should be used solely for debug purposes I think we can
get away with it.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>