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>
mds: Use map for CInode pinrefs

Implements pin refs on the inode as a map instead of
a multiset, allowing individual ref counts to act as
real references with values that can be >1.
The pin refs are only used for debugging, but allowing
them to be >1 avoids the need for a separate state field
for things like DIRTYPARENT.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: New backtrace handling

Add unified backtrace handling for storing a backtrace on file objects
(the first data object) and dirs.  The backtrace store operation is
queued on the LogSegment (for performing the store on log segment
expire).  We encode the backtrace on queue to avoid keeping a reference
around to the CInode, which may get dropped from the cache by the time
the log segment is expired (and the backtrace is written out).
Fetching the backtrace is implemented on the CInode.

Also allow incrementing/decrementing the DIRTYPARENT pin ref as needed,
instead of using a state semaphore to keep track of whether itsset or
not.  This allows us to remove the STATE_DIRTYPARENT field on CInode.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Backtrace for create,rename,mkdir,setlayout

Design info:
http://www.spinics.net/lists/ceph-devel/msg11872.html

Adds a backtrace to the data pool for supporting lookup-by-ino,
storing the backtrace on the first object in the data pool
or the metadata pool for a directory, as the 'parent' xattr
on the object (named by inode) in that pool.  For create, rename,
mkdir, and setlayout operations, the backtrace is
queued (with the current log segment) after the journal is
committed and the safe reply is returned to the client, but the
the backtrace operation itself isn't started until the log segment is
expired.

For journal replay, we queue the backtrace so that it gets
written out on journal expire.  Inodes get added to the EMetaBlob
in the fullbits list, so we queue backtraces while iterating through
the fullbits during replay.

Using setlayout or setxattr('ceph.file.layout.pool'),
the data pool for a file can be changed after it is created
but before anything is written to the file.  A forwarding backtrace
is written to the old pool on a setlayout, to ensure we can always find
the latest backtrace.  We store a list of old pools with the backtrace
for cleaning up all forwarding pointers of an inode.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
dencoder:  Add inode_backtrace_t to types

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Cleanup new segment conditionals

The second conditional for adding a new segment is always
true when the first conditional is true.  Clean this up
to simply create a new segment when we've reached the end of
the current segment.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
pybind/cephfs:  Add initial py wrappers for cephfs.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
test/mds:  Add test to check backtraces

Signed-off-by: Sam Lang <sam.lang@inktank.com>
mds: Add kill points for backtrace testing

Signed-off-by: Sam Lang <sam.lang@inktank.com>