summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Farnum <greg@inktank.com>2013-10-01 12:48:48 -0700
committerGreg Farnum <greg@inktank.com>2013-10-01 16:29:46 -0700
commit1784ef96f474ccc9a7f2d8ea8d6ce90daddd1fdb (patch)
tree1df44c1d75d8208f7a6ae8f2b51a20d1f0299c23
parent010ff3759efc650d766348ab988c302996b8fc50 (diff)
downloadceph-1784ef96f474ccc9a7f2d8ea8d6ce90daddd1fdb.tar.gz
ReplicatedPG: copy: split up the transaction generation from the PG management
Signed-off-by: Greg Farnum <greg@inktank.com>
-rw-r--r--src/osd/ReplicatedPG.cc28
-rw-r--r--src/osd/ReplicatedPG.h2
2 files changed, 22 insertions, 8 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index c3a572509bc..efc1cf8f603 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<uint64_t> 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 e4f6848d6c0..c4384e34057 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();