From bf9390f3e205bce601acd67a693ef670bcce5c9c Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 10 Oct 2013 16:10:36 -0700 Subject: [PATCH] hobject_t/ReplicatedPG: tempness is now an hobject thing PGBackend implmentations will have complete control over the temp collection. Rather than specifying the collection when sending ops into the PGBackend, hobjects themselves will be temp or not. Signed-off-by: Samuel Just --- src/common/hobject.h | 9 +++++++++ src/osd/ReplicatedPG.cc | 17 +++++++++-------- src/osd/ReplicatedPG.h | 1 - 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/common/hobject.h b/src/common/hobject.h index 17137545783..48027a8e3b7 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -35,6 +35,7 @@ struct hobject_t { uint32_t hash; private: bool max; + static const int64_t POOL_IS_TEMP = -1; public: int64_t pool; string nspace; @@ -55,6 +56,14 @@ public: bool match(uint32_t bits, uint32_t match) const { return match_hash(hash, bits, match); } + + static hobject_t make_temp(const string &name) { + hobject_t ret(object_t(name), "", CEPH_NOSNAP, 0, POOL_IS_TEMP, ""); + return ret; + } + bool is_temp() const { + return pool == POOL_IS_TEMP; + } hobject_t() : snap(0), hash(0), max(false), pool(-1) {} diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index f4a6f7c13d8..0d02ea7e0c7 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4540,7 +4540,8 @@ hobject_t ReplicatedPG::generate_temp_object() { ostringstream ss; ss << "temp_" << info.pgid << "_" << get_role() << "_" << osd->monc->get_global_id() << "_" << (++temp_seq); - hobject_t hoid(object_t(ss.str()), "", CEPH_NOSNAP, 0, -1, ""); + hobject_t hoid = hobject_t::make_temp(ss.str()); + // TODOSAM: adjust when this method gets absorbed into ReplicatedBackend pgbackend->add_temp_obj(hoid); dout(20) << __func__ << " " << hoid << dendl; return hoid; @@ -5019,7 +5020,6 @@ void ReplicatedPG::process_copy_chunk(hobject_t oid, tid_t tid, int r) ObjectContextRef tempobc = get_object_context(cop->results.temp_oid, true); RepGather *repop = simple_repop_create(tempobc); if (cop->temp_cursor.is_initial()) { - cop->results.temp_coll = get_temp_coll(&repop->ctx->local_t); repop->ctx->new_temp_oid = cop->results.temp_oid; } _write_copy_chunk(cop, &repop->ctx->op_t); @@ -5085,14 +5085,15 @@ void ReplicatedPG::_build_finish_copy_transaction(CopyOpRef cop, if (cop->temp_cursor.is_initial()) { // write directly to final object - cop->results.temp_coll = coll; cop->results.temp_oid = obs.oi.soid; _write_copy_chunk(cop, &t); } else { // finish writing to temp object, then move into place _write_copy_chunk(cop, &t); - t.collection_move_rename(cop->results.temp_coll, cop->results.temp_oid, - coll, obs.oi.soid); + t.collection_move_rename( + cop->results.temp_coll, cop->results.temp_oid, coll, obs.oi.soid); + + // TODOSAM: adjust when this method gets absorbed into ReplicatedBackend pgbackend->clear_temp_obj(cop->results.temp_oid); } } @@ -5152,9 +5153,7 @@ void ReplicatedPG::finish_promote(int r, OpRequestRef op, dout(10) << __func__ << " abort; will clean up partial work" << dendl; ObjectContextRef tempobc = get_object_context(results->temp_oid, true); RepGather *repop = simple_repop_create(tempobc); - repop->ctx->op_t.remove(results->temp_coll, results->temp_oid); - repop->ctx->discard_temp_oid = results->temp_oid; - pgbackend->clear_temp_obj(results->temp_oid); + repop->ctx->op_t->remove(results->temp_oid); simple_repop_submit(repop); results->started_temp_obj = false; } @@ -6663,11 +6662,13 @@ void ReplicatedPG::sub_op_modify(OpRequestRef op) if (m->new_temp_oid != hobject_t()) { dout(20) << __func__ << " start tracking temp " << m->new_temp_oid << dendl; + // TODOSAM: adjust when this method gets absorbed into ReplicatedBackend pgbackend->add_temp_obj(m->new_temp_oid); get_temp_coll(&rm->localt); } if (m->discard_temp_oid != hobject_t()) { dout(20) << __func__ << " stop tracking temp " << m->discard_temp_oid << dendl; + // TODOSAM: adjust when this method gets absorbed into ReplicatedBackend pgbackend->clear_temp_obj(m->discard_temp_oid); } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index bf31e6b5427..c921029aafc 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -107,7 +107,6 @@ public: utime_t mtime; ///< the copy source's mtime uint64_t object_size; ///< the copied object's size bool started_temp_obj; ///< true if the callback needs to delete temp object - coll_t temp_coll; ///< temp collection (if any) hobject_t temp_oid; ///< temp object (if any) /** * Final transaction; if non-empty the callback must execute it before any -- 2.47.3