mon: create fail_mds_gid() helper; make 'ceph mds rm ...' more generic

Take a gid or a rank or a name.  Use a nicer helper.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: enforce unique name in mdsmap

Add 'mds enforce unique name' option, defaulting to true.

If set, when an MDS boots, it will kick any previous mds with the same
name from the mdsmap.  This is possibly less confusing for users.  If
an mds daemon restarts, it will immediately replace its previous
instantiation.

Two misconfigured daemons running with the same name will fight over
the same role.

Fixes: #3857
Signed-off-by: Sage Weil <sage@inktank.com>
mds: gracefully exit if newer gid replaces us by name

If 'mds enforce unique name' is set, and another MDS with the same name
kicks us out of the MDSMap, gracefully exit instead of respawning and
fighting over our position.

Signed-off-by: Sage Weil <sage@inktank.com>
mds: open mydir after replay

In certain cases, we may replay the journal and not end up with the
dirfrag for mydir open.  This is fine--we just need to open it up and
fetch it below.

Signed-off-by: Sage Weil <sage@inktank.com>
Unit tests for chain_xattr.cc

Create a new test file covering most (> 97%) of src/os/chain_xattr.{cc,h}
lines of code. The following functions are tested:

int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
int chain_listxattr(const char *fn, char *names, size_t len);
int chain_flistxattr(int fd, char *names, size_t len);
int chain_removexattr(const char *fn, const char *name);
int chain_fremovexattr(int fd, const char *name);

The function translate_raw_name substitutes @@ into @. When the trailing
character is a @, it breaks. However, such an occurence cannot be created by
chain_setxattr because it always create pairs of @. Instead of silently
breaking the loop, the function should probably return on error so that the
caller can ignore it.

The function chain_fgetxattr_len may return on error if fgetxattr
returns on error. However, it is only called after another attr function
returned success and the tests cannot create the conditions under which
it would fail.

The function chain_fsetxattr may leak attributes when used to override
an existing attribute. This leak is not tested or fixed, it is just
discussed in http://marc.info/?l=ceph-devel&m=136027076615853&w=4

If the file system in which the tests are run does not support extended
attributes, the tests are not run. The detection uses the same logic as
the one implemented in FileStore::_detect_fs

The output of the tests are silenced to reduce the output when testing
assertions ( except for the dout_emergency function which cannot be
controlled).
doc: document hadoop replication config

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
doc: fix command syntax

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
java: make CephMountTest use user.* xattr names

Changes to the xattr code in Ceph require
a few tweaks to existing test cases.
Specifically, there is now a ceph.file.layout
xattr by default and user defined xattrs
are prepended with "user."

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Joe Buck <jbbuck@gmail.com>
Reviewed-by: Noah Watkins <noahwatkins@gmail.com>
CephxProtocol.h: pass CryptoKey by reference to decode_decrypt()

Fix issues found by cppcheck:

[src/auth/cephx/CephxProtocol.h:469]: (performance) Function
  parameter 'key' should be passed by reference.

Pass CryptoKey by reference as already done in encode_encrypt().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CInode.h: use !old_inodes.empty() instead of size()

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

warning from cppcheck was:
[src/mds/journal.cc:470]: (performance) Possible inefficient
  checking for 'old_inodes' emptiness.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
AuthMonitor.cc: use !pending_auth.empty() instead of 'size() > 0'

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

warning from cppcheck was:
[src/mon/AuthMonitor.cc:210]: (performance) Possible inefficient
  checking for 'pending_auth' emptiness.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
OSDMonitor.h: use !reporters.empty() instead of size()

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Using empty() in this case makes the code more logical.

warning from cppcheck was:

[src/mon/OSDMonitor.h:59]: (performance) Possible inefficient
  checking for 'reporters' emptiness.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
MonCaps.cc: use !empty() instead of size()

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Monitor.cc: use empty() instead of size()

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

warning from cppcheck was:
[src/mon/Monitor.cc:487]: (performance) Possible inefficient
  checking for 'initial_members' emptiness.
[src/mon/Monitor.cc:1361]: (performance) Possible inefficient
  checking for 'timecheck_skews' emptiness.
[src/mon/Monitor.cc:2302]: (performance) Possible inefficient
  checking for 'timecheck_waiting' emptiness.
[src/mon/Monitor.cc:2547]: (performance) Possible inefficient
  checking for 'timecheck_waiting' emptiness.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
OSDMonitor.cc: use !empty() instead of size()

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
PGMonitor.cc: use !empty() instead of size() to check for emptiness

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
monmaptool.cc: use empty() instead of size() to check for emptiness

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
DBObjectMap.cc: use empty() instead of size() to check for emptiness

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
FileStore.cc: use empty() instead of size() to check for emptiness

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
HashIndex.cc: use empty() instead of size() to check for emptiness

Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().

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