osd: accessors for num_pgs

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-04-02 09:08:51 -05:00
parent bfbf2044b2
commit a01d2dfc87
2 changed files with 10 additions and 3 deletions

View File

@ -9290,7 +9290,7 @@ void OSDShard::_attach_pg(OSDShardPGSlot *slot, PG *pg)
slot->pg = pg;
pg->osd_shard = this;
pg->pg_slot = slot;
++osd->num_pgs;
osd->inc_num_pgs();
slot->epoch = pg->get_osdmap_epoch();
pg_slots_by_epoch.insert(*slot);
@ -9302,7 +9302,7 @@ void OSDShard::_detach_pg(OSDShardPGSlot *slot)
slot->pg->osd_shard = nullptr;
slot->pg->pg_slot = nullptr;
slot->pg = nullptr;
--osd->num_pgs;
osd->dec_num_pgs();
pg_slots_by_epoch.erase(pg_slots_by_epoch.iterator_to(*slot));
slot->epoch = 0;

View File

@ -1858,10 +1858,17 @@ public:
vector<OSDShard*> shards;
uint32_t num_shards = 0;
void inc_num_pgs() {
++num_pgs;
}
void dec_num_pgs() {
--num_pgs;
}
protected:
// -- placement groups --
std::atomic<size_t> num_pgs = {0};
protected:
std::mutex pending_creates_lock;
using create_from_osd_t = std::pair<pg_t, bool /* is primary*/>;
std::set<create_from_osd_t> pending_creates_from_osd;