osdc: locking for Journaler

also remove the lock pointers that JournalPointer load/save
used to require in order to use the objecter.

Signed-off-by: John Spray <john.spray@redhat.com>
osdc: Use a finisher from Journaler

Completions from I/O operations (i.e. the objecter) hop
through the finisher twice, because of the three layers of
locking (MDS::mds_lock -> Journaler::lock -> Objecter osd session lock)

Because on the way "right" we take the locks in that order, to avoid
deadlock we can't take the locks in the opposite order on the way
"left", hence the finishers.

Signed-off-by: John Spray <john.spray@redhat.com>
mds: update mds_lock handling in Locker contexts

For some contexts, we expect to be called back from the objecter/filer
on an I/O completion, so we must take mds_lock before updating any
MDS metadata.  In others, we expect to be called back from the MDCache
in response to updates to a CInode's state, so we assert that mds_lock
is already held.

Signed-off-by: John Spray <john.spray@redhat.com>
mds: fix Server::C_MarkEvent locking

... it should acquire mds_lock.

Signed-off-by: John Spray <john.spray@redhat.com>
mds: fix C_MDC_TruncateFinish locking

This one needed to take mds_lock, and be invoked
from a finisher.

Signed-off-by: John Spray <john.spray@redhat.com>
mds/MDLog: del stale ref to C_MDS_WroteImportMap

(class no longer exists)

Signed-off-by: John Spray <john.spray@redhat.com>
mds/MDLog: enable Journaler finisher

Signed-off-by: John Spray <john.spray@redhat.com>
osdc/Objecter: make homeless_session a pointer

Have a non-pointer member that's a RefCountedObject
was awkward, e.g. tripping nref==0 assertion during
destruction.  Rather than play games with refcount
during destruction, just make it a new/delete instance
instead.

Signed-off-by: John Spray <john.spray@redhat.com>
mds: fix leak in wait_for_map, clean up whitespace

Squash this?

Signed-off-by: Sage Weil <sage@redhat.com>
mds: rename IO completions with _IO_

If they are IO operations and need to take mds_lock on finish, label them.

Signed-off-by: Sage Weil <sage@redhat.com>
mon: fix get_pool_name usages

Squash into "osd/OSDMap: return const string from get_pool_name"

Signed-off-by: John Spray <john.spray@redhat.com>
osdc: make Journaler::last_committed public again

Rebasing on master, this field now used from Dumper.

Squash into "osdc: locking for Journaler"

Signed-off-by: John Spray <john.spray@redhat.com>
client: remove unused C_SnapFlush

Signed-off-by: John Spray <john.spray@redhat.com>
client: add missing lock in sync_write_commit

This would otherwise assert when entering
the objectcacher.

Also add assertions for all the other Contexts
in Client, which are currently correct but not
so obvious.

Signed-off-by: John Spray <john.spray@redhat.com>
[rough cut] mds: add MDSContext subclasses

Divide all contexts into MDSInternalContext (things to
be called back inside mds_lock), and MDSIOContext (entry
points to the MDS from e.g. the objecter, which should
themselves take mds_lock when they are called).

Three nice things about this:
 * Static enforcement, where references such as CacheObject
   waiters expect a certain type of context, they can now
   declare it to be so using one of the new types.
 * Runtime enforcement, MDSInternalContext now asserts
   that the lock is indeed held when a context is called back.
 * Readability

Still TODO:
 * Get per-subsystem subclasses of MDSInternalContext that
   use their existing Server/MDCache/Locker whatever reference
   instead of bloating the structure with an extra MDS*
 * Maybe make Finisher a template that can accept only
   a particular type of context (perhaps the MDS finisher
   should only accept MDSIOContexts?)
 * Convert the IO contexts over to MDSIOContext (mostly
   they are currently still Context)

Signed-off-by: John Spray <john.spray@redhat.com>