These will end up essentially unchanged in ECBackend as it turns out.
Signed-off-by: Samuel Just <sam.just@inktank.com>
#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 {
}
+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));
+}
#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(
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,