From: Sage Weil Date: Mon, 2 Apr 2018 14:08:51 +0000 (-0500) Subject: osd: accessors for num_pgs X-Git-Tag: v13.1.0~390^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a01d2dfc87ba28b7d4719b66d34b88e8495500cd;p=ceph.git osd: accessors for num_pgs Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f0d7ee390fa..37f175d22e2 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 36cdec86a7d..53f20ef1b07 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1858,10 +1858,17 @@ public: vector shards; uint32_t num_shards = 0; + void inc_num_pgs() { + ++num_pgs; + } + void dec_num_pgs() { + --num_pgs; + } + +protected: // -- placement groups -- std::atomic num_pgs = {0}; -protected: std::mutex pending_creates_lock; using create_from_osd_t = std::pair; std::set pending_creates_from_osd;