client: check for mds state before sending messages

This fixes some callers, not all.

Signed-off-by: Sage Weil <sage@inktank.com>
client: pass around MetaSession* instead of int mds

This is mostly just shuffling argument types around.  In a few cases we
now assert that the session actually exists; these would have also been
problematic before when we call get_inst() on bad addrs or something, or
silently ignored bugs.

Signed-off-by: Sage Weil <sage@inktank.com>
client: instantiate MetaSession for opening connections

The previous kludge where a waiting_for_session key indicated that we
had an open in progress was... kludgey.

Introduce some helpers to do the session creation/open.

Move the waiting list to be a session member, and clean up associated
code.

Signed-off-by: Sage Weil <sage@inktank.com>
mds: flush log when we hit xlock during path traversal

This ensures we don't stall out waiting for a lock state to change.

This fixes ~4-5 second stalls easily reproducible and visible with
ceph-fuse and 'dbench 1'.

Signed-off-by: Sage Weil <sage@inktank.com>
client: use helper for _close_mds_session()

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix up _closed_mds_session

Drop useless arg.  Simplify callers.

Signed-off-by: Sage Weil <sage@inktank.com>
client: handle ESTALE redirection in make_request(), not reply handler

Resending the request in the reply handler is a bit fugly and throws a
small wrench into moving to a MetaSession*-based approach.  Check for
the case(s) where we *do* return ESTALE explicitly and fall through.
Otherwise, kick the caller and let them retry.

Signed-off-by: Sage Weil <sage@inktank.com>
client: switch kick_requests and send_request to take a session *

More cleanup!

Signed-off-by: Sage Weil <sage@inktank.com>
client: pass session to send_reconnect and resend_unsafe_requests

Signed-off-by: Sage Weil <sage@inktank.com>
client: drop unused release_lease()

Signed-off-by: Sage Weil <sage@inktank.com>
client: use session->inst where possible

Removing remaining lookups up the mds inst in the MDSMap.  Instead, use
the MetaSession inst field.

Signed-off-by: Sage Weil <sage@inktank.com>
client: use Connection* in MetaSession instead of the inst/addr

This moves us to a cleaner API, and makes the session lifetime explicit
and clean.  Yay!

Signed-off-by: Sage Weil <sage@inktank.com>
client: only signal session waiters on open and close

Signed-off-by: Sage Weil <sage@inktank.com>
client: remove unused MetaSession::was_stale

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix remaining s->inst users to use s->con

Signed-off-by: Sage Weil <sage@inktank.com>
client: validate/lookup mds session in each message handler

For every message handler, look up the MetaSession by int mds and verify
that the Connection* matches properly.  If so, proceed; otherwise, discard
the message.

In the future, we probably want to link the MetaSession to the Connection's
priv field, but that can come later.

Clean up a bunch of submethods that take int mds while we're here.

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix wake_inode_waiters() arg

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix trim_caps() args

Signed-off-by: Sage Weil <sage@inktank.com>
client: clean up useless MetaSession lookups

Signed-off-by: Sage Weil <sage@inktank.com>
client: fix kick_flushing_caps() args

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