mds: open inode by ino

This patch adds "open-by-ino" helper. It utilizes backtrace to find
inode's path and open the inode. The algorithm looks like:

1. Check MDS peers. If any MDS has the inode in its cache, goto step 6.
2. Fetch backtrace. If backtrace was previously fetched and get the
   same backtrace again, return -EIO.
3. Traverse the path in backtrace. If the inode is found, goto step 6;
   if non-auth dirfrag is encountered, goto next step. If fail to find
   the inode in its parent dir, goto step 1.
4. Request MDS peers to traverse the path in backtrace. If the inode
   is found, goto step 6. If MDS peer encounters non-auth dirfrag, it
   stops traversing. If any MDS peer fails to find the inode in its
   parent dir, goto step 1.
5. Use the same algorithm to open the inode's parent. Goto step 3 if
   succeeds; goto step 1 if fails.
6. return the inode's auth MDS ID.

The algorithm has two main assumptions:
1. If an inode is in its auth MDS's cache, its on-disk backtrace
   can be out of date.
2. If an inode is not in any MDS's cache, its on-disk backtrace
   must be up to date.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: bump the protocol version

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: open missing cap inodes

When a recovering MDS enters reconnect stage, client sends reconnect
messages to it. The message lists open files, their path, and issued
caps. If an inode is not in the cache, the recovering MDS uses the
path client provides to determine if it's the inode's authority. If
not, the recovering MDS exports the inode's caps to other MDS. The
issue here is that the path client provides isn't always accuracy.

The fix is use recently added "open inode by ino" function to open
any missing cap inodes when the recovering MDS enters rejoin stage.
Send cache rejoin messages to other MDS after all caps' authorities
are determined.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: use "open-by-ino" function to open remote link

Also add a new config option "mds_open_remote_link_mode". The anchor
approach is used by default. If mode is non-zero, use the open-by-ino
function. In case open-by-ino function fails, if mode is 1, retry
using the anchor approach, otherwise trigger assertion.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Remove mon socket in post-stop

If ceph-mon segfault, socket file isn't removed.

By adding a remove in post-stop, upstart clean run directory properly.

Signed-off-by: Guilhem Lettron <guilhem@lettron.fr>
kv_flat_btree_async.cc: fix AioCompletion resource leak

Call AioCompletion::release() if the completion is no longer
needed.

CID 727980 (#1-4 of 4): Resource leak (RESOURCE_LEAK)
  leaked_storage: Variable "aioc" going out of scope leaks
  the storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
kv_flat_btree_async.cc: fix AioCompletion resource leak

Call AioCompletion::release() if the completion is no longer needed.

CID 727979 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
  leaked_storage: Variable "a" going out of scope leaks the storage
  it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
kv_flat_btree_async.cc: fix AioCompletion resource leak

Call AioCompletion::release() if the completion is no longer needed.

CID 727978 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
  leaked_storage: Variable "obj_aioc" going out of scope leaks the
  storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Merge pull request #322 from guilhem/patch-1

Reviewed-by: Sage Weil <sage@inktank.com>
osd/OSDMap: fix Incremental dump

The front hb addr entry may not be present.

Signed-off-by: Sage Weil <sage@inktank.com>
Merge pull request #324 from dalgaaf/wip-da-CID-727979

kv_flat_btree_async.cc: fix AioCompletion resource leak
Merge pull request #325 from dalgaaf/wip-da-CID-727980

kv_flat_btree_async.cc: fix AioCompletion resource leak
WBThrottle: add perfcounters

Signed-off-by: Samuel Just <sam.just@inktank.com>
doc/dev/osd_internals: add wbthrottle.rst

Signed-off-by: Samuel Just <sam.just@inktank.com>
HashIndex: sync top directory during start_split,merge,col_split

Otherwise, the links might be ordered after the in progress
operation tag write.  We need the in progress operation tag to
correctly recover from an interrupted merge, split, or col_split.

Fixes: #5180
Backport: cuttlefish, bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
ceph, MonCommands.h:  code format/help format tweaks

Signed-off-by: Dan Mick <dan.mick@inktank.com>
ceph: first cut at --completion

Factor out parsing JSON to sigdict; use from both main and completion
Currently invoking from bash completion with

        n=${#COMP_WORDS} # length
        # invoke with all but first word
        COMPREPLY=( $(ceph --completion "${COMP_WORDS[@]:1:$n}") )

Not handling --arg and not dealing correctly with cursor-on-last-letter
vs. cursor-on-space

Signed-off-by: Dan Mick <dan.mick@inktank.com>
rgw: mdlog, bilog RESTful api cleanup

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
v0.63
Merge pull request #326 from dalgaaf/wip-da-CID-727978

kv_flat_btree_async.cc: fix AioCompletion resource leak