From: Kefu Chai Date: Tue, 5 May 2026 06:53:48 +0000 (+0800) Subject: crimson/os/cyanstore: implement OP_MERGE_COLLECTION X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=59dd31b71a5d045400133b3da3637fd0fa6f1123;p=ceph.git crimson/os/cyanstore: implement OP_MERGE_COLLECTION Add a handler for Transaction::OP_MERGE_COLLECTION in CyanStore's do_transaction_no_callbacks() and the corresponding _merge_collection() implementation. Moves all objects from the source collection into the destination, updates the destination's split_bits, and removes the source collection from the store's collection map. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index 7d5cfa46f5d7..be2649e52e70 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -675,6 +675,13 @@ seastar::future<> CyanStore::Shard::do_transaction_no_callbacks( r = _remove_collection(cid); } break; + case Transaction::OP_MERGE_COLLECTION: + { + coll_t cid = i.get_cid(op->cid); + coll_t dest_cid = i.get_cid(op->dest_cid); + r = _merge_collection(cid, dest_cid, op->split_bits); + } + break; case Transaction::OP_SETALLOCHINT: { r = 0; @@ -1044,6 +1051,29 @@ int CyanStore::Shard::_create_collection(const coll_t& cid, int bits) return 0; } +int CyanStore::Shard::_merge_collection( + const coll_t& cid, + const coll_t& dest_cid, + int bits) +{ + logger().debug("{} cid={} dest_cid={} bits={}", __func__, cid, dest_cid, bits); + auto src = _get_collection(cid); + if (!src) { + return -ENOENT; + } + auto dest = _get_collection(dest_cid); + if (!dest) { + return -ENOENT; + } + for (auto& [oid, obj] : src->object_map) { + dest->object_map.emplace(oid, obj); + dest->object_hash.emplace(oid, obj); + } + dest->bits = bits; + coll_map.erase(cid); + return 0; +} + int CyanStore::Shard::_remove_collection(const coll_t& cid) { logger().debug("{} cid={}", __func__, cid); diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 06e1b9fb77ca..e7f0f1b5d8a0 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -182,6 +182,7 @@ public: std::string_view name); int _rm_attrs(const coll_t& cid, const ghobject_t& oid); int _create_collection(const coll_t& cid, int bits); + int _merge_collection(const coll_t& cid, const coll_t& dest_cid, int bits); int _remove_collection(const coll_t& cid); boost::intrusive_ptr _get_collection(const coll_t& cid);