AsyncMessenger: Eating up pipe buffer for waking up

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Release connection if stopped

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Normalise log informations

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Try send in queue bufferlist

If previous try_send failed to send all buffers, it will create write event
for next write. But if the message queue is empty and no need to send
in_seq_acked, handle_write will skip to send and in this condition buffers
in queue won't be send forever.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Fix large bufferlist send segment fault

If send long bufferlist exceed IOV_LEN(1024), try_send will stuck in looping
send the first IOV_LEN(1024) ptrs and raise segment fault.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
mon: fix formatted 'pg stat'

Previously it did a full pg dump, which is almost certainly not what the
user wants.

Signed-off-by: Sage Weil <sage@redhat.com>
mon/PGMap: fix {recovery,degraded,unfound}_ratio units, type

These are floats, and *not* percentages!

Signed-off-by: Sage Weil <sage@redhat.com>
common/Formatter: fix JSON dump of floating point values

These are numbers -- they should not be quoted.

Signed-off-by: Sage Weil <sage@redhat.com>
SimpleMessenger: Pipe: do not block on takeover while holding global lock

We previously were able to cause deadlocks:
1) Existing pipe is fast_dispatching
2) Replacement incoming pipe is accepted
  *) blocks on stop_and_wait() of existing Pipe
3) External things are blocked on SimpleMessenger::lock() while
  blocking completion of the fast dispatch.

To resolve this, if we detect that an existing Pipe we want to take over is
in the process of fast dispatching, we unlock our locks and wait on it to
finish. Then we go back to the lookup step and retry.

The effect of this should be safe:
1) We are not making any changes to the existing Pipe in new ways
2) We have not registered the new Pipe anywhere
3) We have not sent back any replies based on Messenger state to
   the remote endpoint.

Backport: giant

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
msg/Pipe: inject delay in stop_and_wait

Inject a delay in stop_and_wait.  This will mostly affect the connection
race Pipe takeover code which currently calls stop_and_wait while holding
the msgr->lock.  This should make it easier for a racing fast_dispatch
method to get stuck on a call that (indirectly) needs the msgr lock.
See #9921.

Signed-off-by: Sage Weil <sage@redhat.com>
msg/simple: ms_die_on_skipped_message

Assert if we skip an incoming seq.  The SimpleMessenger never does this,
but the kernel messenger does.  Hopefully useful for tracking down bugs
like #10057.

Signed-off-by: Sage Weil <sage@redhat.com>
rgw/rgw_gc.cc: silence cppcheck

Silence cppcheck warning about std::remove, clarify the
used remove() function from RGWGC.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
crush/CrushWrapper.cc: prefer ++operator for non-primitive iterators

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ceph_erasure_code_benchmark.cc: prefer ++operator for non-primitive iterators

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ceph_erasure_code_non_regression.cc: prefer ++op for non-primitive iterators

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ceph_erasure_code_benchmark.cc: don't check unsigned for < 0

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
net_handler.cc: close socket leak

Close socket if set_nonblock() fails before return.

Fix for:

CID 1249633 (#1 of 1): Resource leak (RESOURCE_LEAK)
7. leaked_handle: Handle variable s going out of scope leaks the handle.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
net_handler.cc: close another socket leak

Close socket if ::setsockopt() fails before return.

Fix for:

CID 1249632 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable s going out of scope leaks the handle.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
st_rados_list_objects.cc: free resources in error case

Fix for:

CID 1251453 (#2 of 2): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable io_ctx going out of scope leaks the
 storage it points to.

CID 1251454 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable h going out of scope leaks the storage it
 points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
MDSMonitor.cc: remove cmd_getval for poolid

Remove useless check for invalid parameter for
"mds remove_data_pool", we have already the poolid
from the correct parameter 'poolname'.

Fix for:

CID 1251445 (#1 of 1): Unchecked return value (CHECKED_RETURN)
 check_return: Calling cmd_getval without checking return value
 (is done elsewhere 19 out of 22 times).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>