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/MDLog: enable Journaler finisher

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>
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>
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>
common: assert non-null ptrs in OnFinisher

Callers should not be constructing C_OnFinisher
if they have no context to call back.

Signed-off-by: John Spray <john.spray@redhat.com>
include: generalize C_Contexts and C_Gather*

... by making them templates so that they can be
used in places that expect a subclass of Context.

The existing names are now typedefs to template
instantiations using Context.

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

These allow contexts within the MDS to identify themselves
as either 'internal' contexts (expecting to be called within
the big MDS lock) or 'IO' contexts (which should take the big
mds lock themselves when called back).

Signed-off-by: John Spray <john.spray@redhat.com>
mds: Switch to new context types

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