cond: reorder asserts

Make the more specific checks assert before the less specific ones, so we
are more likely to crash with useful information.

Signed-off-by: Sage Weil <sage@inktank.com>
mutex: assert we are unlocked by the same thread that locked

This only works for non-recursive locks.  (Which is probably all of them?)

Signed-off-by: Sage Weil <sage@inktank.com>
objecter: fix mon command resends

The monitor session is lossy.  Send these when the op is initiated, or
when we reconnect.  The timeout/cutoff was preventing ops from getting
resent if there was an ill-timed mon reset.

Backport: testing, stable/argonaut
Signed-off-by: Sage Weil <sage@inktank.com>
librados: make pool create/destroy handle client-side errors

Add tests!

Signed-off-by: Sage Weil <sage@inktank.com>
objecter: make pool create/delete return EEXIST/ENOENT

Do these checks on the client side to mask monitor idempotency from
the user.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: make pool removal idempotent

Return success if pool does not exist.  Part of #2638.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: make pool creation idempotent

Return success if the pool already exists.  Part of #2638.

Also, fix this so we wait until a creating pool is created before we reply.

Signed-off-by: Sage Weil <sage@inktank.com>
qa: simple test for pool create/delete commands

Signed-off-by: Sage Weil <sage@inktank.com>
mon: make 'osd rm ...' idempotent

Signed-off-by: Sage Weil <sage@inktank.com>
qa: simple tests for 'ceph osd create|rm' commands

Signed-off-by: Sage Weil <sage@inktank.com>
mon: check for invalid pool snap creates in preprocess_op, too

This avoids waiting for a paxos commit just to return an error.

Signed-off-by: Sage Weil <sage@inktank.com>
librados: make snap create/destroy handle client-side errors

Signed-off-by: Sage Weil <sage@inktank.com>
objecter: return ENOENT/EEXIST on pool snap delete/create

Do these checks on the client to mask monitor idempotency from the user.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: make pool snap creation ops idempotent

Return 0 if the snap already exists, or is already deleted.

Also, avoid updating the pg_pool if we are just waiting for the current
round to commit.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: remove superfluous "can't delete except on master" comments

That's what 'return false' means for preprocess_*().

Signed-off-by: Sage Weil <sage@inktank.com>
conf: make dup lines override previous value

If you put

[some section]
 foo = 1
 ...
 foo = 2

in a .conf file, make the second key override the first.

Generate a warning if a value is overridden to sidestep some user hangbanging.

Signed-off-by: Sage Weil <sage@inktank.com>
vstart.sh: apply extra conf after the defaults

This let's you do e.g., -o 'debug ms = 100' and it will apply after
the default logging levels.

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Pipe: make STANDBY behavior optional

In particular, lossless_peers should use STANDBY, but lossless_clients
should reconnect immediately since they are already doing their own session
management.

Specifically, this fixes the problem where the Client tries to open a
connection to the MDS and faults after delivering its OPEN_SESSION message
but before it gets the reply: the session isn't open yet, so it isn't
pinging.  It could, but it is simpler and faster to make the msgr layer
keep the connection open instead of waiting for a periodic keepalive.

Fixes: #2824
Signed-off-by: Sage Weil <sage@inktank.com>
client: handle fault during session teardown

We may have a sequence like:

 - client does REQUEST_CLOSE
 - mds sends reply
 - connection faults, client does get reply
 - mds closes out its connection
 - client tries to reconnect/resend, gets RESET_SESSION
   -> continues lamely waiting

If we get a session reset and we were asking to close the connection,
we are happy--it was closed.

This was exposed with ceph-fuse start/stop tests with socket failure
injection.

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Pipe: if we send a wait, make sure we follow through

Mark our outgoing connection attempt if we send a WAIT in accept().  This
ensures we don't go to standby or closed in fault() on the outgoing
connection for any reason.

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