From 2d5a7e2cad9a8a0c7e1753b7d822bf0a33e09326 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 12 Dec 2013 15:02:53 -0800 Subject: [PATCH] osd/ReplicatedPG: uninline CopyFromCallback, PromoteCallback Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 68 +++++++++++++++++++++++++++++++++++++++++ src/osd/ReplicatedPG.h | 55 ++------------------------------- 2 files changed, 71 insertions(+), 52 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 091d97690b6..82318137443 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -101,6 +101,52 @@ static void log_subop_stats( osd->logger->tinc(tag_lat, latency); } + +class CopyFromCallback: public ReplicatedPG::CopyCallback { +public: + ReplicatedPG::CopyResults *results; + int retval; + ReplicatedPG::OpContext *ctx; + hobject_t temp_obj; + CopyFromCallback(ReplicatedPG::OpContext *ctx_, const hobject_t& temp_obj_) + : results(NULL), + retval(0), + ctx(ctx_), + temp_obj(temp_obj_) {} + ~CopyFromCallback() {} + + virtual void finish(ReplicatedPG::CopyCallbackResults results_) { + results = results_.get<1>(); + int r = results_.get<0>(); + retval = r; + if (r >= 0) { + ctx->pg->execute_ctx(ctx); + } + ctx->copy_cb = NULL; + if (r < 0) { + if (r != -ECANCELED) { // on cancel just toss it out; client resends + ctx->pg->osd->reply_op_error(ctx->op, r); + } else if (results->should_requeue) { + ctx->pg->requeue_op(ctx->op); + } + ctx->pg->close_op_ctx(ctx); + } + delete results; + } + + bool is_temp_obj_used() { + return results->started_temp_obj; + } + uint64_t get_data_size() { + return results->object_size; + } + int get_result() { + return retval; + } +}; + + + // ====================== // PGBackend::Listener @@ -1319,6 +1365,28 @@ void ReplicatedPG::do_cache_redirect(OpRequestRef op, ObjectContextRef obc) return; } +class PromoteCallback: public ReplicatedPG::CopyCallback { + OpRequestRef op; + ObjectContextRef obc; + hobject_t temp_obj; + ReplicatedPG *pg; +public: + PromoteCallback(OpRequestRef op_, ObjectContextRef obc_, + const hobject_t& temp_obj_, + ReplicatedPG *pg_) + : op(op_), + obc(obc_), + temp_obj(temp_obj_), + pg(pg_) {} + + virtual void finish(ReplicatedPG::CopyCallbackResults results) { + ReplicatedPG::CopyResults *results_data = results.get<1>(); + int r = results.get<0>(); + pg->finish_promote(r, op, results_data, obc, temp_obj); + delete results_data; + } +}; + void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc) { MOSDOp *m = static_cast(op->get_req()); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index a718b6888a6..599f85d26df 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -40,6 +40,9 @@ class MOSDSubOpReply; +class CopyFromCallback; +class PromoteCallback; + class ReplicatedPG; void intrusive_ptr_add_ref(ReplicatedPG *pg); void intrusive_ptr_release(ReplicatedPG *pg); @@ -179,59 +182,7 @@ public: virtual ~CopyCallback() {}; }; - class CopyFromCallback: public CopyCallback { - public: - CopyResults *results; - int retval; - OpContext *ctx; - hobject_t temp_obj; - CopyFromCallback(OpContext *ctx_, const hobject_t& temp_obj_) : - results(NULL), retval(0), ctx(ctx_), temp_obj(temp_obj_) {} - ~CopyFromCallback() {} - - virtual void finish(CopyCallbackResults results_) { - results = results_.get<1>(); - int r = results_.get<0>(); - retval = r; - if (r >= 0) { - ctx->pg->execute_ctx(ctx); - } - ctx->copy_cb = NULL; - if (r < 0) { - if (r != -ECANCELED) { // on cancel just toss it out; client resends - ctx->pg->osd->reply_op_error(ctx->op, r); - } else if (results->should_requeue) { - ctx->pg->requeue_op(ctx->op); - } - ctx->pg->close_op_ctx(ctx); - } - delete results; - } - - bool is_temp_obj_used() { return results->started_temp_obj; } - uint64_t get_data_size() { return results->object_size; } - int get_result() { return retval; } - }; friend class CopyFromCallback; - - class PromoteCallback: public CopyCallback { - OpRequestRef op; - ObjectContextRef obc; - hobject_t temp_obj; - ReplicatedPG *pg; - public: - PromoteCallback(OpRequestRef op_, ObjectContextRef obc_, - const hobject_t& temp_obj_, - ReplicatedPG *pg_) : - op(op_), obc(obc_), temp_obj(temp_obj_), pg(pg_) {} - - virtual void finish(CopyCallbackResults results) { - CopyResults *results_data = results.get<1>(); - int r = results.get<0>(); - pg->finish_promote(r, op, results_data, obc, temp_obj); - delete results_data; - } - }; friend class PromoteCallback; struct FlushOp {