From 4a29b22e2b8b749af825bf115b11f39d5332caf0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 22 Oct 2013 15:04:44 -0700 Subject: [PATCH] osd/ReplicatedPG: move r<0 handling into finish_promote() Let logic in header, and will let us handle ENOENT with a whiteout. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 19 ++++++++++++++++++- src/osd/ReplicatedPG.h | 22 ++++------------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 9cc2673133a73..b0ecd046840ed 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4606,9 +4606,26 @@ void ReplicatedPG::finish_copyfrom(OpContext *ctx) ctx->delta_stats.num_wr_kb += SHIFT_ROUND_UP(obs.oi.size, 10); } -void ReplicatedPG::finish_promote(CopyResults *results, ObjectContextRef obc, +void ReplicatedPG::finish_promote(int r, OpRequestRef op, + CopyResults *results, ObjectContextRef obc, hobject_t& temp_obj) { + if (r < 0) { + // we need to get rid of the op in the blocked queue + map >::iterator blocked_iter = + waiting_for_blocked_object.find(obc->obs.oi.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 (r != -ECANCELED) { // on cancel the client will resend + osd->reply_op_error(op, r); + } + return; + } + vector ops; tid_t rep_tid = osd->get_tid(); osd_reqid_t reqid(osd->get_cluster_msgr_name(), 0, rep_tid); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 43c61b72e4176..35896d8fa62a4 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -222,24 +222,9 @@ public: op(op_), obc(obc_), temp_obj(temp_obj_), pg(pg_) {} virtual void finish(CopyCallbackResults results) { - CopyResults* results_data = results.get<1>(); + CopyResults *results_data = results.get<1>(); int r = results.get<0>(); - if (r >= 0) { - pg->finish_promote(results_data, obc, temp_obj); - } else { - // we need to get rid of the op in the blocked queue - map >::iterator blocked_iter; - blocked_iter = pg->waiting_for_blocked_object.find(obc->obs.oi.soid); - assert(blocked_iter != pg->waiting_for_blocked_object.end()); - assert(blocked_iter->second.begin()->get() == op.get()); - blocked_iter->second.pop_front(); - if (blocked_iter->second.empty()) { - pg->waiting_for_blocked_object.erase(blocked_iter); - } - if (r != -ECANCELED) { // on cancel the client will resend - pg->osd->reply_op_error(op, r); - } - } + pg->finish_promote(r, op, results_data, obc, temp_obj); delete results_data; } }; @@ -1000,7 +985,8 @@ protected: void _build_finish_copy_transaction(CopyOpRef cop, ObjectStore::Transaction& t); void finish_copyfrom(OpContext *ctx); - void finish_promote(CopyResults *results, ObjectContextRef obc, + void finish_promote(int r, OpRequestRef op, + CopyResults *results, ObjectContextRef obc, hobject_t& temp_obj); void cancel_copy(CopyOpRef cop, bool requeue); void cancel_copy_ops(bool requeue); -- 2.39.5