Temp handling is also the same in ReplicatedBackend as in ECBackend.
Signed-off-by: Samuel Just <sam.just@inktank.com>
}
+void PGBackend::on_change(ObjectStore::Transaction *t)
+{
+ dout(10) << __func__ << dendl;
+ // clear temp
+ for (set<hobject_t>::iterator i = temp_contents.begin();
+ i != temp_contents.end();
+ ++i) {
+ dout(10) << __func__ << ": Removing oid "
+ << *i << " from the temp collection" << dendl;
+ t->remove(
+ get_temp_coll(t),
+ ghobject_t(*i, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard));
+ }
+ temp_contents.clear();
+ _on_change(t);
+}
+
+coll_t PGBackend::get_temp_coll(ObjectStore::Transaction *t)
+{
+ if (temp_created)
+ return temp_coll;
+ if (!store->collection_exists(temp_coll))
+ t->create_collection(temp_coll);
+ temp_created = true;
+ return temp_coll;
+}
+
int PGBackend::objects_list_partial(
const hobject_t &begin,
int min,
* 4) Handling scrub, deep-scrub, repair
*/
class PGBackend {
+ protected:
+ ObjectStore *store;
+ const coll_t coll;
+ const coll_t temp_coll;
public:
/**
* Provides interfaces for PGBackend callbacks
};
Listener *parent;
Listener *get_parent() const { return parent; }
- PGBackend(Listener *l) : parent(l) {}
+ PGBackend(Listener *l, ObjectStore *store, coll_t coll, coll_t temp_coll) :
+ store(store),
+ coll(coll),
+ temp_coll(temp_coll),
+ parent(l), temp_created(false) {}
bool is_primary() const { return get_parent()->pgb_is_primary(); }
OSDMapRef get_osdmap() const { return get_parent()->pgb_get_osdmap(); }
const pg_info_t &get_info() { return get_parent()->get_info(); }
* implementation should clear itself, contexts blessed prior to on_change
* won't be called after on_change()
*/
- virtual void on_change(ObjectStore::Transaction *t) = 0;
+ void on_change(ObjectStore::Transaction *t);
+ virtual void _on_change(ObjectStore::Transaction *t) = 0;
virtual void clear_state() = 0;
virtual void on_flushed() = 0;
- virtual void split_colls(
+
+ void temp_colls(list<coll_t> *out) {
+ if (temp_created)
+ out->push_back(temp_coll);
+ }
+ void split_colls(
pg_t child,
int split_bits,
int seed,
- ObjectStore::Transaction *t) = 0;
-
- virtual void temp_colls(list<coll_t> *out) = 0;
+ ObjectStore::Transaction *t) {
+ coll_t target = coll_t::make_temp_coll(child);
+ if (!temp_created)
+ return;
+ t->create_collection(target);
+ t->split_collection(
+ temp_coll,
+ split_bits,
+ seed,
+ target);
+ }
virtual void dump_recovery_info(Formatter *f) const = 0;
- virtual coll_t get_temp_coll(ObjectStore::Transaction *t) = 0;
- virtual void add_temp_obj(const hobject_t &oid) = 0;
- virtual void clear_temp_obj(const hobject_t &oid) = 0;
+ private:
+ bool temp_created;
+ set<hobject_t> temp_contents;
+ public:
+ coll_t get_temp_coll(ObjectStore::Transaction *t);
+ coll_t get_temp_coll() const {
+ return temp_coll;
+ }
+ bool have_temp_coll() const { return temp_created; }
+
+ // Track contents of temp collection, clear on reset
+ void add_temp_obj(const hobject_t &oid) {
+ temp_contents.insert(oid);
+ }
+ void add_temp_objs(const set<hobject_t> &oids) {
+ temp_contents.insert(oids.begin(), oids.end());
+ }
+ void clear_temp_obj(const hobject_t &oid) {
+ temp_contents.erase(oid);
+ }
+ void clear_temp_objs(const set<hobject_t> &oids) {
+ for (set<hobject_t>::const_iterator i = oids.begin();
+ i != oids.end();
+ ++i) {
+ temp_contents.erase(*i);
+ }
+ }
virtual ~PGBackend() {}
pull_from_peer.clear();
}
-void ReplicatedBackend::on_change(ObjectStore::Transaction *t)
+void ReplicatedBackend::_on_change(ObjectStore::Transaction *t)
{
- dout(10) << __func__ << dendl;
- // clear temp
- for (set<hobject_t>::iterator i = temp_contents.begin();
- i != temp_contents.end();
- ++i) {
- dout(10) << __func__ << ": Removing oid "
- << *i << " from the temp collection" << dendl;
- t->remove(get_temp_coll(t), *i);
- }
- temp_contents.clear();
for (map<tid_t, InProgressOp>::iterator i = in_progress_ops.begin();
i != in_progress_ops.end();
in_progress_ops.erase(i++)) {
clear_state();
}
-coll_t ReplicatedBackend::get_temp_coll(ObjectStore::Transaction *t)
-{
- if (temp_created)
- return temp_coll;
- if (!osd->store->collection_exists(temp_coll))
- t->create_collection(temp_coll);
- temp_created = true;
- return temp_coll;
-}
-
void ReplicatedBackend::on_flushed()
{
if (have_temp_coll() &&
ObjectStore::Transaction local_t;
if (t->get_temp_added().size()) {
get_temp_coll(&local_t);
- temp_contents.insert(t->get_temp_added().begin(), t->get_temp_added().end());
- }
- for (set<hobject_t>::const_iterator i = t->get_temp_cleared().begin();
- i != t->get_temp_cleared().end();
- ++i) {
- temp_contents.erase(*i);
+ add_temp_objs(t->get_temp_added());
}
+ clear_temp_objs(t->get_temp_cleared());
+
parent->log_operation(log_entries, trim_to, true, &local_t);
local_t.append(*op_t);
local_t.swap(*op_t);
map<int, vector<PullOp> > pulls;
};
friend struct C_ReplicatedBackend_OnPullComplete;
-private:
- bool temp_created;
- const coll_t temp_coll;
- coll_t get_temp_coll() const {
- return temp_coll;
- }
- bool have_temp_coll() const { return temp_created; }
-
- // Track contents of temp collection, clear on reset
- set<hobject_t> temp_contents;
public:
- coll_t coll;
OSDService *osd;
CephContext *cct;
OpRequestRef op
);
- void on_change(ObjectStore::Transaction *t);
+ void _on_change(ObjectStore::Transaction *t);
void clear_state();
void on_flushed();
- void temp_colls(list<coll_t> *out) {
- if (temp_created)
- out->push_back(temp_coll);
- }
- void split_colls(
- pg_t child,
- int split_bits,
- int seed,
- ObjectStore::Transaction *t) {
- coll_t target = coll_t::make_temp_coll(child);
- if (!temp_created)
- return;
- t->create_collection(target);
- t->split_collection(
- temp_coll,
- split_bits,
- seed,
- target);
- }
-
virtual void dump_recovery_info(Formatter *f) const {
{
f->open_array_section("pull_from_peer");
}
};
- coll_t get_temp_coll(ObjectStore::Transaction *t);
- void add_temp_obj(const hobject_t &oid) {
- temp_contents.insert(oid);
- }
- void clear_temp_obj(const hobject_t &oid) {
- temp_contents.erase(oid);
- }
-
map<hobject_t, PullInfo> pulling;
// Reverse mapping from osd peer to objects beging pulled from that peer