From: Sage Weil Date: Thu, 23 Oct 2014 21:34:36 +0000 (-0700) Subject: osd/ReplicatedPG: make op argument to promote_object optional X-Git-Tag: v0.92~33^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d89f18158e74441fc072e579a2cf2b287210881;p=ceph.git osd/ReplicatedPG: make op argument to promote_object optional For now, we still always pass it. In preparation, however, we modify promote_object() so that it will work when op is null. Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index e897d6c5922a..fd5c415147b9 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1762,6 +1762,9 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return false; } + MOSDOp *m = static_cast(op->get_req()); + const object_locator_t& oloc = m->get_object_locator(); + switch (pool.info.cache_mode) { case pg_pool_t::CACHEMODE_NONE: return false; @@ -1785,23 +1788,23 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return false; } if (op->may_write() || write_ordered || must_promote || !hit_set) { - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); } else { switch (pool.info.min_read_recency_for_promote) { case 0: - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); break; case 1: // Check if in the current hit set if (in_hit_set) { - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); } else { do_cache_redirect(op, obc); } break; default: if (in_hit_set) { - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); } else { // Check if in other hit sets map::iterator itor; @@ -1813,7 +1816,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, } } if (in_other_hit_sets) { - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); } else { do_cache_redirect(op, obc); } @@ -1828,7 +1831,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, return false; } if (must_promote) - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); else do_cache_redirect(op, obc); return true; @@ -1840,7 +1843,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, } if (!obc.get() && r == -ENOENT) { // we don't have the object and op's a read - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); return true; } if (!r) { // it must be a write @@ -1866,13 +1869,13 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, if (!must_promote && can_skip_promote(op, obc)) { return false; } - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); return true; } // If it is a read, we can read, we need to forward it if (must_promote) - promote_object(op, obc, missing_oid); + promote_object(obc, missing_oid, oloc, op); else do_cache_redirect(op, obc); return true; @@ -1929,10 +1932,11 @@ public: } }; -void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc, - const hobject_t& missing_oid) +void ReplicatedPG::promote_object(ObjectContextRef obc, + const hobject_t& missing_oid, + const object_locator_t& oloc, + OpRequestRef op) { - MOSDOp *m = static_cast(op->get_req()); if (!obc) { // we need to create an ObjectContext assert(missing_oid != hobject_t()); obc = get_object_context(missing_oid, true); @@ -1940,16 +1944,18 @@ void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc, dout(10) << __func__ << " " << obc->obs.oi.soid << dendl; PromoteCallback *cb = new PromoteCallback(op, obc, this); - object_locator_t oloc(m->get_object_locator()); - oloc.pool = pool.info.tier_of; - start_copy(cb, obc, obc->obs.oi.soid, oloc, 0, + object_locator_t my_oloc = oloc; + my_oloc.pool = pool.info.tier_of; + start_copy(cb, obc, obc->obs.oi.soid, my_oloc, 0, CEPH_OSD_COPY_FROM_FLAG_IGNORE_OVERLAY | CEPH_OSD_COPY_FROM_FLAG_IGNORE_CACHE | CEPH_OSD_COPY_FROM_FLAG_MAP_SNAP_CLONE, obc->obs.oi.soid.snap == CEPH_NOSNAP); assert(obc->is_blocked()); - wait_for_blocked_object(obc->obs.oi.soid, op); + + if (op) + wait_for_blocked_object(obc->obs.oi.soid, op); } void ReplicatedPG::execute_ctx(OpContext *ctx) @@ -6470,16 +6476,18 @@ void ReplicatedPG::finish_promote(int r, OpRequestRef op, } if (r < 0 && !whiteout) { - // we need to get rid of the op in the blocked queue - map >::iterator blocked_iter = - waiting_for_blocked_object.find(soid); - assert(blocked_iter != waiting_for_blocked_object.end()); - assert(blocked_iter->second.begin()->get() == op.get()); - blocked_iter->second.pop_front(); - if (blocked_iter->second.empty()) { - waiting_for_blocked_object.erase(blocked_iter); + if (op) { + // we need to get rid of the op in the blocked queue + map >::iterator blocked_iter = + waiting_for_blocked_object.find(soid); + assert(blocked_iter != waiting_for_blocked_object.end()); + assert(blocked_iter->second.begin()->get() == op.get()); + blocked_iter->second.pop_front(); + if (blocked_iter->second.empty()) { + waiting_for_blocked_object.erase(blocked_iter); + } + osd->reply_op_error(op, r); } - osd->reply_op_error(op, r); return; } diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 53480e0271b9..39e50909638b 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -1103,8 +1103,10 @@ protected: /** * This function starts up a copy from */ - void promote_object(OpRequestRef op, ObjectContextRef obc, - const hobject_t& missing_object); + void promote_object(ObjectContextRef obc, ///< [optional] obc + const hobject_t& missing_object, ///< oid (if !obc) + const object_locator_t& oloc, ///< locator for obc|oid + OpRequestRef op); ///< [optional] client op /** * Check if the op is such that we can skip promote (e.g., DELETE)