Makefile.am:  fix ceph_sbindir

This reinstates the fix for the ceph_sbindir from commit
352f362567bf270d0896fb7573df4ae5139a56fb, with corrections
from Danny's review commits pull request #389.
Fixes: #5492

Reported-by: Denis Kaganovich <mahatma@eu.by>
Reviewed-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
Merge branch 'wip-5492-gl' into next

Re-instate fix for #5492 with corrections.

Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
Get device-by-path by looking for it instead of assuming 3rd entry.

On some systems (virtual machines so far) the device-by-path entry
from udevadm is not always in the same spot so instead actually
look for the right output instead of blindy assuming that its a
specific field in the output.

Signed-off-by: Sandon Van Ness <sandon@inktank.com>
Reviewed-by: Gary Lowell  <gary.lowell@inktank.com>
ceph.in: output even a blank status line in compat mode

Fixes: #5594
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
cmdparse.cc: catch exception by reference

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rgw/rgw_rados.cc: use empty() instead of checking for size() > 0

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rgw/rgw_rest_opstate.cc: prefer prefix ++operator for non-trivial iterator

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_meta.cc: prefer prefix ++operator for non-trivial iterator

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_opstate.cc: prefer prefix ++operator for non-trivial iterator

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_log.cc: prefer prefix ++operator for non-trivial iterator

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
cls/rgw/cls_rgw.cc: use empty() instead of checking for size() == 0

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_meta.cc: prefer prefix ++operator for non-trivial iterator

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Merge pull request #426 from dalgaaf/wip-da-SCA-cppcheck-5

Fix some typical SCA issues from cppcheck

Reviewed-by: Sage Weil <sage@inktank.com>
Merge remote-tracking branch 'gh/next'
replace ObjectContext pointers with shared_ptr

The ObjectContext pointers are shared using a ref data member that
needs to be updated by the caller. This is tedious and error
prone. All pointers are replaced with shared_ptr for
automatic reference counting and the ref data member is removed.

The ReplicatedPG::object_contexts is changed to a SharedPtrRegistry.
The SharedPtrRegistry::get_next() method with a value of
ObjectContextRef instead of ObjectContext is added. The
SharedPtrRegistry::empty() method is added. When creating a new object
SharedPtrRegistry::lookup_or_create uses the default ObjectContext
constructor with no argument. The existing ObjectContext constructor
is modified to have no argument and the initialization that was
previously done withint the constructor is done by the caller (that only happens three times and .

The SharedPtrRegistry_ptr do not delete the ObjectContext or update the
ReplicatedPG::object_contexts at exactly the same point as
ReplicatedPG::put_object_context does. It happens when the last object
holding a shared_ptr goes out of scope, which is always later than
the call to ReplicatedPG::put_object_context.

The ObjectContext::get method is removed: its only purpose is to
increment the ref.

The ObjectContext::registered data member is removed as well as all
the associated assert()

The ReplicatedPG::_lookup_object_context method is removed because it
is used once to retrieve an ObjectContext without incrementing ref, in
order to save a call to ReplicatedPG::put_object_context. Since the ref
data member is no longer used, the method is redundant.

The ReplicatedPG::lookup_object_context (no underscore) method is
replaced with SharedPtrRegistry::lookup.

The ReplicatedPG::put_object_context has three different purposes: a)
check mode.wake b) decrement the ref of the associated ObjectContext
given in argument c) if the ref drops to zero delete the object,
delete its entry in the ReplicatedPG::object_contexts registry and
call PG::kick. The decrementing part is no longer necessary because
the SharedPtrRegistry takes care of it. The mode.wake check is moved
to the check_wake method. The cleanup that happens on deletion is
moved to the ObjectContext destructor, using a Context object as a
callback to invoke the
ReplicatedPG::object_context_destructor_callback method.

ReplicatedPG::register_object_context is removed. It was called after
creating a new ObjectContext to add it to
ReplicatedPG::object_contexts and also to initialize ssc, obs.exists
and obs.oi. The call is replaced with the desired side effects, in
addition to setting the new destructor_callback data member.

ReplicatedPG::put_object_contexts calls put_object_context on a list
of ObjectContexts and clears the list. It is replaced by a call to
list::clear. It also ( indirectly ) checks mode.wake because
put_object_context does. However, it is always called before or a
after a call to ReplicatedPG::put_object_context ( no s at the end )
which is replaced with check_wake, therefore the expected side effect
happens anyway.

ReplicatedPG::context_registry_on_change is a call to the
Watch::discard method of all the watchers found in
ReplicatedPG::object_contexts. It also calls
ReplicatedPG::put_object_contexts on all of them and it is replaced
with a single call to check_wake()

ReplicatedPG::_finish_mark_all_unfound_lost explicitely calls
ReplicatedPG::put_object_contexts in a loop to clear the list. It is
taken care of by SharedPtrRegistry and the list can be cleared without
iterating over all its elements. A single call to check_wake is added.

Watch::get_obc is inlined and does not rely on the ObjectContext::get
method.

http://tracker.ceph.com/issues/5510 refs #5510

Signed-off-by: Loic Dachary <loic@dachary.org>