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>
client: Wait for caps to flush when flushing metadata.

Embarrassingly, this conditional has been backwards since
I committed it in 818e7939. But we want to do the wait when
we did do the flush and are syncing metadata. As the code
previously stood, we only did the wait when we didn't care,
and it didn't wait anyway since it was waiting for 0. So,
bad all around.
Signed-off-by: Greg Farnum <greg@inktank.com>
client: return errors to the user if fsync fails

To do so, we allow callers of _flush(Inode) to pass in a Context
as well. This Context is then given to the ObjectCacher as
the completion callback instead of the C_Client_PutInode that
it uses by default. _fsync() passes in a SafeCond which is
pointing to its return code, and presto! The return code gets
a failure if the Objecter returns any.
To preserve existing semantics, _fsync() (and any similar
caller) is now required to take a reference to the inode.

However, this is a behavioral change: previously, a call to fsync
in the userspace code would simply spin as it waited for all the
data to flush out. That obviously wasn't desirable, but now a user
can call fsync, ignore the return value, and think that everything is
hunky-dory when in fact the client is repeatedly trying to flush out
the dirty data. Hrm...

This fixes the fsync case of #2753 for ceph-fuse.

Signed-off-by: Greg Farnum <greg@inktank.com>
install:  remove perl dependency

Change the filter in logrotate to use sed instead of perl, and remove the
package dependency on perl.

Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
cli test: add pg deep-scrub option to test

Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
Relax Throttle::_reset_max conditions and associated unit tests

Removes a condition in Throttle::_reset_max by which the waiting queue is only
Signal()ed if the new maximum is lower than the current maximum.
There is no evidence of a use case where such a restriction would be
useful. In addition waking up a thread when the maximum increases
gives it a chance to immediately continue the suspended process
instead of waiting for the next put().

Create a new test file covering 100% of src/Throttle.{cc,h} lines of code.
The following methods are tested:

* Throttle::Throttle with and without a maximum
* Throttle::~Throttle when each pending Cond is deleted
* Throttle::take
* Throttle::get when updating the maximum ( lower or higher ),
  when going to sleep waiting for the count to lower under
  the maximum, when going to sleep because another thread is
  already asleep waiting
* Throttle::get_or_fail when there is no maximum,
  when requesting a count that is larger than the maximum, either
  when the current value is under the maximum or above the maximum.
* Throttle::wait when used to reset the maximum and wake up
  another thread asleep waiting

All asserts checking the arguments sanity are exercised ( negative argument
for Throttle::take etc. ).
Adds the LGPLv2+ licensing terms to COPYING along with the others.
Adds a Contributors section to the AUTHORS file.

Notes:
Testing asserts outputs verbose error messages that should be silenced
but it does not seem possible.

Signed-off-by: Loic Dachary <loic@dachary.org>
Merge pull request #39 from dachary/master

Relax Throttle::_reset_max conditions and associated unit tests
osd: remove DecayCounter header

Neither the OSD nor the PG makes any use of this.

Signed-off-by: Greg Farnum <greg@inktank.com>
mds: add CEPH_FEATURE_MDSENC feature bit

This will cover the MDS cluster on upgrade, and determine which encoding
of the MDSMap they use for clients.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
 mds: Anchor now uses modern encoding

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
mds: SnapInfo, snaplink_t, sr_t now use modern encoding

This commit doesn't enable the dencoder integration due
to some build and compile issues, but we'll turn it
on later.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
client: rename client/SnapRealm files to avoid automake build conflict

We are about to move the MDS' SnapRealm into its own files, which conflicts.
The MDS is more important, so it wins the "SnapRealm" filename and we
move the client stuff to ClientSnapRealm.[h|cc].

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
mds: move SnapRealm into its own h/cc files

Signed-off-by: Sage Weil <sage@inktank.com>
mds: inode_back{trace,pointer}_t now uses modern encoding

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
mds: default_file_layout now uses modern encoding

And move implementations into mdstypes.cc from CInode and common/types.
mdstypes.cc sadly lives in libcommon; as several of the types we're going
to put there are needed for Messages and similar things.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
mds: frag_info_t now uses modern encoding

Signed-off-by: Sage Weil <sage@inktank.com>
mds: rename struct default_file_layout to file_layout_policy_t

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>