]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGBackend/ReplicatedBackend: move rollback methods into PGBackend
authorSamuel Just <sam.just@inktank.com>
Thu, 23 Jan 2014 01:46:22 +0000 (17:46 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 18 Feb 2014 04:11:05 +0000 (20:11 -0800)
These will end up essentially unchanged in ECBackend as it turns out.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/PGBackend.cc
src/osd/PGBackend.h
src/osd/ReplicatedBackend.h

index 80e289ed5af31b1ecd46e0bf33a21c2060cb442d..3d46da16d3657e8b124e4cadb1b6f862d82741e3 100644 (file)
 
 
 #include "PGBackend.h"
+#include "OSD.h"
+
+#define dout_subsys ceph_subsys_osd
+#define DOUT_PREFIX_ARGS this
+#undef dout_prefix
+#define dout_prefix _prefix(_dout, this)
+static ostream& _prefix(std::ostream *_dout, PGBackend *pgb) {
+  return *_dout << pgb->get_parent()->gen_dbg_prefix();
+}
 
 // -- ObjectModDesc --
 struct RollbackVisitor : public ObjectModDesc::Visitor {
@@ -64,3 +73,55 @@ void PGBackend::rollback(
 }
 
 
+void PGBackend::rollback_setattrs(
+  const hobject_t &hoid,
+  map<string, boost::optional<bufferlist> > &old_attrs,
+  ObjectStore::Transaction *t) {
+  map<string, bufferlist> to_set;
+  set<string> to_remove;
+  for (map<string, boost::optional<bufferlist> >::iterator i = old_attrs.begin();
+       i != old_attrs.end();
+       ++i) {
+    if (i->second) {
+      to_set[i->first] = i->second.get();
+    } else {
+      t->rmattr(coll, hoid, i->first);
+    }
+  }
+  t->setattrs(
+    coll,
+    ghobject_t(hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
+    to_set);
+}
+
+void PGBackend::rollback_append(
+  const hobject_t &hoid,
+  uint64_t old_size,
+  ObjectStore::Transaction *t) {
+  t->truncate(coll, hoid, old_size);
+}
+
+void PGBackend::rollback_stash(
+  const hobject_t &hoid,
+  version_t old_version,
+  ObjectStore::Transaction *t) {
+  t->remove(coll, hoid);
+  t->collection_move_rename(
+    coll,
+    ghobject_t(hoid, old_version, 0),
+    coll,
+    ghobject_t(hoid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard));
+}
+
+void PGBackend::rollback_create(
+  const hobject_t &hoid,
+  ObjectStore::Transaction *t) {
+  t->remove(coll, hoid);
+}
+
+void PGBackend::trim_stashed_object(
+  const hobject_t &hoid,
+  version_t old_version,
+  ObjectStore::Transaction *t) {
+  t->remove(coll, ghobject_t(hoid, old_version, 0));
+}
index 2b8a382c5a61eda7b1371a8192ccbc5ec0a7f097..57d0a25ec1ce3d854e13c2912503925dc7d17efd 100644 (file)
@@ -22,6 +22,7 @@
 #include "osd_types.h"
 #include "include/Context.h"
 #include "os/ObjectStore.h"
+#include "common/LogClient.h"
 #include <string>
 
  /**
      ObjectStore::Transaction *t);
 
    /// Reapply old attributes
-   virtual void rollback_setattrs(
+   void rollback_setattrs(
      const hobject_t &hoid,
      map<string, boost::optional<bufferlist> > &old_attrs,
-     ObjectStore::Transaction *t) = 0;
+     ObjectStore::Transaction *t);
 
    /// Truncate object to rollback append
    virtual void rollback_append(
      const hobject_t &hoid,
      uint64_t old_size,
-     ObjectStore::Transaction *t) = 0;
+     ObjectStore::Transaction *t);
 
    /// Unstash object to rollback stash
-   virtual void rollback_stash(
+   void rollback_stash(
      const hobject_t &hoid,
      version_t old_version,
-     ObjectStore::Transaction *t) = 0;
+     ObjectStore::Transaction *t);
 
    /// Delete object to rollback create
-   virtual void rollback_create(
+   void rollback_create(
      const hobject_t &hoid,
-     ObjectStore::Transaction *t) = 0;
+     ObjectStore::Transaction *t);
 
    /// Trim object stashed at stashed_version
-   virtual void trim_stashed_object(
+   void trim_stashed_object(
      const hobject_t &hoid,
      version_t stashed_version,
-     ObjectStore::Transaction *t) = 0;
+     ObjectStore::Transaction *t);
 
    /// List objects in collection
    virtual int objects_list_partial(
index cee5023cacccce3fd0ef4f782213d080a4d0ca46..9b996217dc324e8dc5edf2fec8de30055687d5fe 100644 (file)
@@ -388,56 +388,6 @@ public:
     OpRequestRef op
     );
 
-  void rollback_setattrs(
-    const hobject_t &hoid,
-    map<string, boost::optional<bufferlist> > &old_attrs,
-    ObjectStore::Transaction *t) {
-    map<string, bufferlist> to_set;
-    set<string> to_remove;
-    for (map<string, boost::optional<bufferlist> >::iterator i = old_attrs.begin();
-        i != old_attrs.end();
-        ++i) {
-      if (i->second) {
-       to_set[i->first] = i->second.get();
-      } else {
-       t->rmattr(coll, hoid, i->first);
-      }
-    }
-    t->setattrs(coll, hoid, to_set);
-  }
-
-  void rollback_append(
-    const hobject_t &hoid,
-    uint64_t old_size,
-    ObjectStore::Transaction *t) {
-    t->truncate(coll, hoid, old_size);
-  }
-
-  void rollback_stash(
-    const hobject_t &hoid,
-    version_t old_version,
-    ObjectStore::Transaction *t) {
-    t->remove(coll, hoid);
-    t->collection_move_rename(
-      coll,
-      ghobject_t(hoid, old_version, 0),
-      coll,
-      hoid);
-  }
-
-  void rollback_create(
-    const hobject_t &hoid,
-    ObjectStore::Transaction *t) {
-    t->remove(coll, hoid);
-  }
-
-  void trim_stashed_object(
-    const hobject_t &hoid,
-    version_t old_version,
-    ObjectStore::Transaction *t) {
-    t->remove(coll, ghobject_t(hoid, old_version, 0));
-  }
-
 private:
   void issue_op(
     const hobject_t &soid,