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>
librbd: protect list_children from invalid child pool IoCtxs

While listing child images, don't ignore error codes returned
from librados when creating an IoCtx. This will prevent seg
faults from occurring when an invalid IoCtx is used.

Fixes: #10123
Backport: giant, firefly, dumpling
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
KeyValueStore: Add KEY_ENDING sign to the end of key

Keys stored in alphabetical order and need to follow ghobject_t comparison
rule. "generation" and "shard_id" are optional fields for object key, but
a default ghobject with UINT64_MAX generation(by default) will larger than
the same ghobject with other generation. GenericObjectMap rejects to store
generation if generation is UINT64_MAX in order to reduce too much words
in key. So we need to add a MAX sign to the end of key to make ordering
is same with ghobject's comparison rule.

For example:

_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head
_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head!78!0

The first key should larger than the second in ghobject_t ordering because
of generation. But the first key less than the second in GenericObjectMap.

_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head
_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head!78!0

After we add KEY_ENDING, '!' is (21) in hexadecimal:

_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head(21)78!0(FF)
_GHOBJTOSEQ_:1%e1ds0_head!D168A7E8!!1!!benchmark_last_metadata!head(FF)

Fix bug #10119
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
StoreTest: Add scrub situation to tests

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
KeyValueStore: Fix parse_header_key

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
blkdev: using strncpy instead of strcpy.

Coverity Scan reported this bug:
> New defect(s) Reported-by: Coverity Scan Showing 1 of 1 defect(s)
> *** CID 1255369:  Copy into fixed size buffer  (STRING_OVERFLOW)
> /common/blkdev.cc: 34 in block_device_support_discard(const char *)()
> 28     bool block_device_support_discard(const char *devname)
> 29     {
> 30       bool can_trim = false;
> 31       char *p = strstr((char *)devname, "sd");
> 32       char name[32] = {0};
> 33
> >>>     CID 1255369:  Copy into fixed size buffer  (STRING_OVERFLOW)
> >>>     You might overrun the 32 byte fixed-size string "name" by
> >>>     copying "p" without checking the length.
> 34       strcpy(name, p);
> 35       for (unsigned int i = 0; i < strlen(name); i++) {
> 36         if(isdigit(name[i])) {
> 37           name[i] = 0;
> 38           break;
> 39         }
>

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Merge pull request #2978 from majianpeng/fix4

blkdev: using strncpy instead of strcpy.

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #2966 from yuyuyu101/wip-10119

KeyValueStore: Fix EC+ KV OSDs crashing

Reviewed-by: Sage Weil <sage@redhat.com>
GenericObjectMap: Fix typo

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Merge pull request #2981 from yuyuyu101/quick-fix

GenericObjectMap: Avoid master branch compile error
Merge pull request #2980 from ceph/wip-10123

librbd: protect list_children from invalid child pool IoCtxs

Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Merge pull request #2895 from yuyuyu101/wip-10022

AsyncMessenger: Fix several problems

Reviewed-by: Sage Weil <sage@redhat.com>
lockdep: do not use $CEPH_LOCKDEP for g_lockdep

* a non-zero CEPH_LOCKDEP brings ceph down because g_lockdep_ceph_ctx
  is still being constructed when dout_impl() dereferences it.
* fix a typo in comment.
* remove dead code.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Merge pull request #2983 from tchaikov/wip-fix-lock-dep

lockdep: do not use $CEPH_LOCKDEP for g_lockdep

Reviewed-by: Sage Weil <sage@redhat.com>