co_return sources;
}
+void PG::merge_from(
+ merge_source_map_t& sources,
+ PeeringCtx &rctx,
+ unsigned split_bits,
+ const pg_merge_meta_t& last_pg_merge_meta)
+{
+ LOG_PREFIX(PG::merge_from);
+ DEBUG("target {}", get_pgid());
+
+ std::map<spg_t, PeeringState*> source_states;
+ for (auto& [pgid, entry] : sources) {
+ auto& src_pg = entry.second;
+ source_states.emplace(pgid, &src_pg->peering_state);
+ }
+
+ // Updates the target's PeeringState and stats (Synchronous)
+ peering_state.merge_from(source_states, rctx, split_bits, last_pg_merge_meta);
+
+ // We iterate through each source and move its objects into the target collection
+ for (auto& [pgid, entry] : sources) {
+ auto& src_pg = entry.second;
+ auto src_coll = src_pg->get_collection_ref()->get_cid();
+ auto dst_coll = coll_ref->get_cid();
+ DEBUG("merging source {}", pgid);
+
+ // Remove source-specific metadata objects that are no longer needed
+ // now that the collections are being collapsed.
+ rctx.transaction.remove(src_coll, src_pg->get_pgid().make_snapmapper_oid());
+ rctx.transaction.remove(src_coll, src_pg->pgmeta_oid);
+ // Move source collection into target collection.
+ rctx.transaction.merge_collection(src_coll, dst_coll, split_bits);
+ }
+
+ // Adjust the collection and snap_mapper to reflect the
+ // new, smaller PG count (reducing bitmask).
+ rctx.transaction.collection_set_bits(coll_ref->get_cid(), split_bits);
+ snap_mapper.update_bits(split_bits);
+}
}
// return them and clear the rendezvous state. Returns an empty map if
// reset_merge_rendezvous() breaks the wait (e.g. PG stop or merge cancel).
seastar::future<merge_source_map_t> collect_merge_sources(std::size_t n);
+ void merge_from(
+ merge_source_map_t& sources,
+ PeeringCtx &rctx,
+ unsigned split_bits,
+ const pg_merge_meta_t& last_pg_merge_meta);
// Drop in-flight handoffs and reset the semaphore. Call on PG stop or
// after Seastore cross-shard cancel so a failed try cannot leave stale