From 1784ef96f474ccc9a7f2d8ea8d6ce90daddd1fdb Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 1 Oct 2013 12:48:48 -0700 Subject: [PATCH] ReplicatedPG: copy: split up the transaction generation from the PG management Signed-off-by: Greg Farnum --- src/osd/ReplicatedPG.cc | 28 ++++++++++++++++++++-------- src/osd/ReplicatedPG.h | 2 ++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index c3a572509bccb..efc1cf8f603a0 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4517,16 +4517,12 @@ void ReplicatedPG::_write_copy_chunk(CopyOpRef cop, ObjectStore::Transaction *t) cop->temp_cursor = cop->cursor; } -int ReplicatedPG::finish_copy(OpContext *ctx) +void ReplicatedPG::_build_finish_copy_transaction(CopyOpRef cop, + ObjectStore::Transaction& t) { - CopyOpRef cop = ctx->copy_op; - ObjectState& obs = ctx->new_obs; - ObjectStore::Transaction& t = ctx->op_t; + ObjectState& obs = cop->obc->obs; - if (!obs.exists) { - ctx->delta_stats.num_objects++; - obs.exists = true; - } else { + if (obs.exists) { t.remove(coll, obs.oi.soid); } @@ -4540,9 +4536,25 @@ int ReplicatedPG::finish_copy(OpContext *ctx) _write_copy_chunk(cop, &t); t.collection_move_rename(cop->temp_coll, cop->temp_oid, coll, obs.oi.soid); pgbackend->clear_temp_obj(cop->temp_oid); + } +} + +int ReplicatedPG::finish_copy(OpContext *ctx) +{ + CopyOpRef cop = ctx->copy_op; + ObjectState& obs = ctx->new_obs; + ObjectStore::Transaction& t = ctx->op_t; + + if (!ctx->obs->exists) { + ctx->delta_stats.num_objects++; + obs.exists = true; + } + if (cop->temp_cursor.is_initial()) { ctx->discard_temp_oid = cop->temp_oid; } + _build_finish_copy_transaction(cop, t); + interval_set ch; if (obs.oi.size > 0) ch.insert(0, obs.oi.size); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index e4f6848d6c03f..c4384e340579e 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -731,6 +731,8 @@ protected: void process_copy_chunk(hobject_t oid, tid_t tid, int r); void _write_copy_chunk(CopyOpRef cop, ObjectStore::Transaction *t); void _copy_some(ObjectContextRef obc, CopyOpRef cop); + void _build_finish_copy_transaction(CopyOpRef cop, + ObjectStore::Transaction& t); int finish_copy(OpContext *ctx); void cancel_copy(CopyOpRef cop); void cancel_copy_ops(); -- 2.39.5