// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #pragma once #include #include #include #include "include/types.h" #include "crimson/common/type_helpers.h" #include "crimson/osd/osd_operation.h" #include "crimson/osd/pg.h" #include "osd/osd_types.h" namespace crimson::osd { class PG; class PGMap { struct PGCreationState : BlockerT { static constexpr const char * type_name = "PGCreation"; void dump_detail(Formatter *f) const final; spg_t pgid; seastar::shared_promise> promise; bool creating = false; PGCreationState(spg_t pgid); PGCreationState(const PGCreationState &) = delete; PGCreationState(PGCreationState &&) = delete; PGCreationState &operator=(const PGCreationState &) = delete; PGCreationState &operator=(PGCreationState &&) = delete; ~PGCreationState(); }; std::map pgs_creating; using pgs_t = std::map>; pgs_t pgs; public: /** * Get future for pg with a bool indicating whether it's already being * created. */ std::pair>, bool> wait_for_pg(spg_t pgid); /** * get PG in non-blocking manner */ Ref get_pg(spg_t pgid); /** * Set creating */ void set_creating(spg_t pgid); /** * Set newly created pg */ void pg_created(spg_t pgid, Ref pg); /** * Add newly loaded pg */ void pg_loaded(spg_t pgid, Ref pg); pgs_t& get_pgs() { return pgs; } const pgs_t& get_pgs() const { return pgs; } PGMap() = default; ~PGMap(); }; }