summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-08-29 18:15:19 -0700
committerSamuel Just <sam.just@inktank.com>2013-09-14 00:45:30 -0700
commitbd7a805e163b1f5a679df4942ee5f9f160b2fae1 (patch)
tree2efc3f55996ab53d26ddc6898e03fd320f242071
parente7bb2abc776e33b9ab1f63cfbe3d05ba9f295f52 (diff)
downloadceph-bd7a805e163b1f5a679df4942ee5f9f160b2fae1.tar.gz
OSD,ReplicatedPG: let PGBackend handle the temp collection
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/osd/OSD.cc38
-rw-r--r--src/osd/PG.h8
-rw-r--r--src/osd/ReplicatedBackend.cc4
-rw-r--r--src/osd/ReplicatedBackend.h8
-rw-r--r--src/osd/ReplicatedPG.cc29
-rw-r--r--src/osd/ReplicatedPG.h26
6 files changed, 48 insertions, 65 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 20aef0301ec..68ba722bb4c 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -3399,16 +3399,16 @@ void OSD::RemoveWQ::_process(pair<PGRef, DeletingStateRef> item)
if (!item.second->start_clearing())
return;
- if (pg->have_temp_coll()) {
+ list<coll_t> colls_to_remove;
+ pg->get_colls(&colls_to_remove);
+ for (list<coll_t>::iterator i = colls_to_remove.begin();
+ i != colls_to_remove.end();
+ ++i) {
bool cont = remove_dir(
- pg->cct, store, &mapper, &driver, pg->osr.get(), pg->get_temp_coll(), item.second);
+ pg->cct, store, &mapper, &driver, pg->osr.get(), *i, item.second);
if (!cont)
return;
}
- bool cont = remove_dir(
- pg->cct, store, &mapper, &driver, pg->osr.get(), coll, item.second);
- if (!cont)
- return;
if (!item.second->start_deleting())
return;
@@ -3419,9 +3419,12 @@ void OSD::RemoveWQ::_process(pair<PGRef, DeletingStateRef> item)
OSD::make_infos_oid(),
pg->log_oid,
t);
- if (pg->have_temp_coll())
- t->remove_collection(pg->get_temp_coll());
- t->remove_collection(coll);
+
+ for (list<coll_t>::iterator i = colls_to_remove.begin();
+ i != colls_to_remove.end();
+ ++i) {
+ t->remove_collection(*i);
+ }
// We need the sequencer to stick around until the op is complete
store->queue_transaction(
@@ -5872,22 +5875,11 @@ void OSD::split_pgs(
dout(10) << "m_seed " << i->ps() << dendl;
dout(10) << "split_bits is " << split_bits << dendl;
- rctx->transaction->create_collection(
- coll_t(*i));
- rctx->transaction->split_collection(
- coll_t(parent->info.pgid),
+ parent->split_colls(
+ *i,
split_bits,
i->m_seed,
- coll_t(*i));
- if (parent->have_temp_coll()) {
- rctx->transaction->create_collection(
- coll_t::make_temp_coll(*i));
- rctx->transaction->split_collection(
- coll_t::make_temp_coll(parent->info.pgid),
- split_bits,
- i->m_seed,
- coll_t::make_temp_coll(*i));
- }
+ rctx->transaction);
parent->split_into(
*i,
child,
diff --git a/src/osd/PG.h b/src/osd/PG.h
index cbafd0f43d9..6f35937e6ce 100644
--- a/src/osd/PG.h
+++ b/src/osd/PG.h
@@ -869,8 +869,12 @@ public:
virtual void _scrub(ScrubMap &map) { }
virtual void _scrub_clear_state() { }
virtual void _scrub_finish() { }
- virtual coll_t get_temp_coll() = 0;
- virtual bool have_temp_coll() = 0;
+ virtual void get_colls(list<coll_t> *out) = 0;
+ virtual void split_colls(
+ pg_t child,
+ int split_bits,
+ int seed,
+ ObjectStore::Transaction *t) = 0;
virtual bool _report_snap_collection_errors(
const hobject_t &hoid,
const map<string, bufferptr> &attrs,
diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc
index ecbfea9149b..d020b18d901 100644
--- a/src/osd/ReplicatedBackend.cc
+++ b/src/osd/ReplicatedBackend.cc
@@ -28,7 +28,9 @@ static ostream& _prefix(std::ostream *_dout, ReplicatedBackend *pgb) {
ReplicatedBackend::ReplicatedBackend(
PGBackend::Listener *pg, coll_t coll, OSDService *osd) :
- PGBackend(pg), temp_created(false), coll(coll), osd(osd) {}
+ PGBackend(pg), temp_created(false),
+ temp_coll(coll_t::make_temp_coll(pg->get_info().pgid)),
+ coll(coll), osd(osd), cct(osd->cct) {}
void ReplicatedBackend::run_recovery_op(
PGBackend::RecoveryHandle *h,
diff --git a/src/osd/ReplicatedBackend.h b/src/osd/ReplicatedBackend.h
index f2a7e4ca9e0..e787b16e920 100644
--- a/src/osd/ReplicatedBackend.h
+++ b/src/osd/ReplicatedBackend.h
@@ -27,7 +27,7 @@ class ReplicatedBackend : public PGBackend {
};
private:
bool temp_created;
- coll_t temp_coll;
+ const coll_t temp_coll;
coll_t get_temp_coll(ObjectStore::Transaction *t);
coll_t get_temp_coll() const {
return temp_coll;
@@ -39,6 +39,7 @@ private:
public:
coll_t coll;
OSDService *osd;
+ CephContext *cct;
ReplicatedBackend(PGBackend::Listener *pg, coll_t coll, OSDService *osd);
@@ -78,14 +79,15 @@ public:
int split_bits,
int seed,
ObjectStore::Transaction *t) {
+ coll_t target = coll_t::make_temp_coll(child);
if (!temp_created)
return;
- t->create_collection(temp_coll);
+ t->create_collection(target);
t->split_collection(
temp_coll,
split_bits,
seed,
- coll_t::make_temp_coll(child));
+ target);
}
virtual void dump_recovery_info(Formatter *f) const {
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index d3205cc37c0..bd519f6c5cb 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -3972,21 +3972,6 @@ void ReplicatedPG::do_osd_op_effects(OpContext *ctx)
}
}
-bool ReplicatedPG::have_temp_coll()
-{
- return temp_created || osd->store->collection_exists(temp_coll);
-}
-
-coll_t ReplicatedPG::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;
-}
-
int ReplicatedPG::prepare_transaction(OpContext *ctx)
{
assert(!ctx->ops.empty());
@@ -7023,20 +7008,6 @@ void ReplicatedPG::on_shutdown()
cancel_recovery();
}
-void ReplicatedPG::on_flushed()
-{
- assert(object_contexts.empty());
- if (have_temp_coll() &&
- !osd->store->collection_empty(get_temp_coll())) {
- vector<hobject_t> objects;
- osd->store->collection_list(get_temp_coll(), objects);
- derr << __func__ << ": found objects in the temp collection: "
- << objects << ", crashing now"
- << dendl;
- assert(0 == "found garbage in the temp collection");
- }
-}
-
void ReplicatedPG::on_activate()
{
for (unsigned i = 1; i<acting.size(); i++) {
diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h
index bbe041fc004..a472f9cda0f 100644
--- a/src/osd/ReplicatedPG.h
+++ b/src/osd/ReplicatedPG.h
@@ -961,15 +961,27 @@ public:
int do_tmapup_slow(OpContext *ctx, bufferlist::iterator& bp, OSDOp& osd_op, bufferlist& bl);
void do_osd_op_effects(OpContext *ctx);
-private:
- bool temp_created;
- coll_t temp_coll;
- coll_t get_temp_coll(ObjectStore::Transaction *t);
public:
- bool have_temp_coll();
- coll_t get_temp_coll() {
- return temp_coll;
+ void get_colls(list<coll_t> *out) {
+ out->push_back(coll);
+ return pgbackend->temp_colls(out);
+ }
+ void split_colls(
+ pg_t child,
+ int split_bits,
+ int seed,
+ ObjectStore::Transaction *t) {
+ coll_t target = coll_t(child);
+ t->create_collection(target);
+ t->split_collection(
+ coll,
+ split_bits,
+ seed,
+ target);
+ pgbackend->split_colls(child, split_bits, seed, t);
}
+ /// TODOXXX: remove this one, stub
+ coll_t get_temp_coll(ObjectStore::Transaction *t) { return coll_t(); }
private:
struct NotTrimming;
struct SnapTrim : boost::statechart::event< SnapTrim > {