summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Farnum <greg@inktank.com>2013-09-24 16:12:06 -0700
committerGreg Farnum <greg@inktank.com>2013-09-26 08:40:30 -0700
commitfa048e22ab0d58dc3ec5d5d64d9b548671e7b70a (patch)
tree6d599730033d8fc36b6963c1f4f2a6da6a066901
parent36b868a24e06500db270b3fc099368fa909c66ca (diff)
downloadceph-fa048e22ab0d58dc3ec5d5d64d9b548671e7b70a.tar.gz
ReplicatedPG: implement promote_object
This doesn't work at all if the underlying object doesn't exist -- it will just fetch over and over again. (To say nothing of less obvious ways in which it is probably broken). Signed-off-by: Greg Farnum <greg@inktank.com>
-rw-r--r--src/osd/ReplicatedPG.cc24
-rw-r--r--src/osd/ReplicatedPG.h6
2 files changed, 30 insertions, 0 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index b17f5dde6da..04906ee1240 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -962,7 +962,31 @@ void ReplicatedPG::do_cache_redirect(OpRequestRef op, ObjectContextRef obc)
void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc)
{
+ MOSDOp *m = static_cast<MOSDOp*>(op->request);
+ if (!obc.get()) { // we need to create an ObjectContext
+ int r = find_object_context(
+ hobject_t(m->get_oid(),
+ m->get_object_locator().key,
+ m->get_snapid(),
+ m->get_pg().ps(),
+ m->get_object_locator().get_pool(),
+ m->get_object_locator().nspace),
+ &obc, true, NULL);
+ assert(r == 0); // a lookup that allows creates can't fail now
+ }
+ vector<OSDOp> ops;
+ tid_t rep_tid = osd->get_tid();
+ osd_reqid_t reqid(osd->get_cluster_msgr_name(), 0, rep_tid);
+ OpContext *cctx = new OpContext(OpRequestRef(), reqid, ops,
+ &obc->obs, obc->ssc, this);
+ cctx->obc = obc;
+ object_locator_t oloc(m->get_object_locator());
+ oloc.pool = pool.info.tier_of;
+ start_copy(cctx, obc->obs.oi.soid, oloc, 0, true);
+
+ assert(obc->is_blocked());
+ wait_for_blocked_object(obc->obs.oi.soid, op);
}
void ReplicatedPG::execute_ctx(OpContext *ctx)
diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h
index 5855c0e6ea6..dd0110da373 100644
--- a/src/osd/ReplicatedPG.h
+++ b/src/osd/ReplicatedPG.h
@@ -630,7 +630,13 @@ protected:
* @returns true if the caching code is handling the Op, false otherwise.
*/
inline bool maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, int r);
+ /**
+ * This helper function tells the client to redirect their request elsewhere.
+ */
void do_cache_redirect(OpRequestRef op, ObjectContextRef obc);
+ /**
+ * This function starts up a copy from
+ */
void promote_object(OpRequestRef op, ObjectContextRef obc);
int prepare_transaction(OpContext *ctx);