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>
osdc/Journaler: remove unused waitfor_trim

There was no code path for ever adding contexts to this list.

Signed-off-by: John Spray <john.spray@redhat.com>
osdc/Journaler: use finisher for public callbacks

This is needed because of occasional lock cycles with
external callers doing e.g. write_head.

We do get some weird-looking multiply-nested
C_OnFinisher(C_OnFinisher(...)) from this approach,
where one finisher exists to protect journaler from
lock cycles wrt objecter, and the other exists
to protect the MDS from lock cycles wrt journaler.

Signed-off-by: John Spray <john.spray@redhat.com>
mds: convert IO contexts

As of this change, the only thing in the MDS inheriting
directly from Context is MDSContext.

The only files touching mds_lock explicitly are MDS, MDLog and
MDSContext -- everyone else should be getting their locking behaviour
via the contexts.  (one minor exception made for an assertion in
Locker).

Signed-off-by: John Spray <john.spray@redhat.com>
fixup io context
fixup journaler to handle null ctx
osdc/Journaler: fix C_RetryRead locking

Not sure this was ever actually getting used, but
it would have had a problem if it was.

Signed-off-by: John Spray <john.spray@redhat.com>
mds/Server: fix wait_for_osd_map calls

These needed a C_OnFinisher and C_IO_Wrapper because they
are called back from the Objecter like an I/O completion.

Signed-off-by: John Spray <john.spray@redhat.com>
osdc: Add lock to Filer::Probe

This is necessary now that Objecter can call back
from multiple OSD op completions in parallel: otherwise
we get multiple threads trying to update
the same Probe object.

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