summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Farnum <greg@inktank.com>2014-08-28 02:37:28 +0200
committerGreg Farnum <gfarnum@redhat.com>2014-11-07 20:48:00 +0100
commit80fac9e627362f18136cea3c390e7c1ab9298e66 (patch)
treee55568fd9f7b32ab70d17c51a70157d4f8846e10 /src
parentMerge pull request #2707 from ceph/wip-9731 (diff)
downloadceph-80fac9e627362f18136cea3c390e7c1ab9298e66.tar.xz
ceph-80fac9e627362f18136cea3c390e7c1ab9298e66.zip
mds: add an MDSInternalContextWrapper and MDSIOContextWrapper
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>
Diffstat (limited to 'src')
-rw-r--r--src/mds/MDSContext.cc19
-rw-r--r--src/mds/MDSContext.h28
2 files changed, 47 insertions, 0 deletions
diff --git a/src/mds/MDSContext.cc b/src/mds/MDSContext.cc
index 47143f260d1..9a9a6f15ba1 100644
--- a/src/mds/MDSContext.cc
+++ b/src/mds/MDSContext.cc
@@ -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;
diff --git a/src/mds/MDSContext.h b/src/mds/MDSContext.h
index 9da667403e3..34633093675 100644
--- a/src/mds/MDSContext.h
+++ b/src/mds/MDSContext.h
@@ -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