]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add an MDSInternalContextWrapper and MDSIOContextWrapper
authorGreg Farnum <greg@inktank.com>
Thu, 28 Aug 2014 00:37:28 +0000 (17:37 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 7 Nov 2014 19:48:00 +0000 (11:48 -0800)
These let us wrap generic function tooling up inside of the appropriate
type-checking, and verify we haven't done anything too stupid.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/MDSContext.cc
src/mds/MDSContext.h

index 47143f260d1664ce44f258d65eb510a1b678857a..9a9a6f15ba14343a8fc297375e53540b36c16341 100644 (file)
@@ -35,6 +35,16 @@ MDS *MDSInternalContext::get_mds() {
   return mds;
 }
 
+MDS *MDSInternalContextWrapper::get_mds()
+{
+  return mds;
+}
+
+void MDSInternalContextWrapper::finish(int r)
+{
+  fin->complete(r);
+}
+
 
 void MDSIOContextBase::complete(int r) {
   MDS *mds = get_mds();
@@ -54,6 +64,15 @@ MDS *MDSIOContext::get_mds() {
   return mds;
 }
 
+MDS *MDSIOContextWrapper::get_mds() {
+  return mds;
+}
+
+void MDSIOContextWrapper::finish(int r)
+{
+  fin->complete(r);
+}
+
 MDS *MDSInternalContextGather::get_mds()
 {
   derr << "Forbidden call to MDSInternalContextGather::get_mds by " << typeid(*this).name() << dendl;
index 9da667403e3db7ddcaba12107ee6a754b84fa61f..346330936758dd12908e6bdea4ea52f1241b81fc 100644 (file)
@@ -60,6 +60,20 @@ public:
   }
 };
 
+/**
+ * Wrap a regular Context up as an Internal context. Useful
+ * if you're trying to work with one of our more generic frameworks.
+ */
+class MDSInternalContextWrapper : public MDSInternalContextBase
+{
+protected:
+  MDS *mds;
+  Context *fin;
+  MDS *get_mds();
+public:
+  MDSInternalContextWrapper(MDS *m, Context *c) : mds(m), fin(c) {}
+  void finish(int r);
+};
 
 class MDSIOContextBase : public MDSContext
 {
@@ -82,6 +96,20 @@ public:
   }
 };
 
+/**
+ * Wrap a regular Context up as an IO Context. Useful
+ * if you're trying to work with one of our more generic frameworks.
+ */
+class MDSIOContextWrapper : public MDSIOContextBase
+{
+protected:
+  MDS *mds;
+  Context *fin;
+  MDS *get_mds();
+public:
+  MDSIOContextWrapper(MDS *m, Context *c) : mds(m), fin(c) {}
+  void finish(int r);
+};
 
 /**
  * No-op for callers expecting MDSInternalContextBase