From ad3aab364b83d33ba50161c6b929a15f03633334 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Feb 2018 22:43:18 -0600 Subject: [PATCH] os/ObjectStore: add merge_collection operation to Transaction Signed-off-by: Sage Weil --- src/os/ObjectStore.h | 22 ++++++++++++++++++++++ src/os/Transaction.cc | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 2ef00640f24e0..129b366ea8b29 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -349,6 +349,8 @@ public: OP_TRY_RENAME = 41, // oldcid, oldoid, newoid OP_COLL_SET_BITS = 42, // cid, bits + + OP_MERGE_COLLECTION = 43, // cid, destination }; // Transaction hint type @@ -682,6 +684,13 @@ public: op->dest_cid = cm[op->dest_cid]; break; + case OP_MERGE_COLLECTION: + ceph_assert(op->cid < cm.size()); + ceph_assert(op->dest_cid < cm.size()); + op->cid = cm[op->cid]; + op->dest_cid = cm[op->dest_cid]; + break; + default: ceph_abort_msg("Unknown OP"); } @@ -1367,6 +1376,19 @@ public: data.ops++; } + /// Merge collection into another. + void merge_collection( + coll_t cid, + coll_t destination, + uint32_t bits) { + Op* _op = _get_next_op(); + _op->op = OP_MERGE_COLLECTION; + _op->cid = _get_coll_id(cid); + _op->dest_cid = _get_coll_id(destination); + _op->split_bits = bits; + data.ops++; + } + void collection_set_bits( const coll_t &cid, int bits) { diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index 69f82cc2b1f5f..ad390a1c3eeeb 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -387,6 +387,18 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f) } break; + case Transaction::OP_MERGE_COLLECTION: + { + coll_t cid = i.get_cid(op->cid); + uint32_t bits = op->split_bits; + coll_t dest = i.get_cid(op->dest_cid); + f->dump_string("op_name", "op_merge_collection"); + f->dump_stream("collection") << cid; + f->dump_stream("dest") << dest; + f->dump_stream("bits") << bits; + } + break; + case Transaction::OP_OMAP_RMKEYRANGE: { coll_t cid = i.get_cid(op->cid); -- 2.39.5