]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: add PG::is_{acting,up}()
authorKefu Chai <kchai@redhat.com>
Sat, 2 Mar 2019 05:18:28 +0000 (13:18 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Mar 2019 05:21:32 +0000 (13:21 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index f1a6590e4c0067d7419a1cd4f3a02044b2fbbb45..c76a986ff5d12b01c2e4060eb080ce3339924f87 100644 (file)
@@ -155,6 +155,29 @@ bool PG::is_primary() const
   return whoami == primary;
 }
 
+
+namespace {
+  bool has_shard(bool ec, const vector<int>& osds, pg_shard_t pg_shard)
+  {
+    if (ec) {
+      return (osds.size() > static_cast<unsigned>(pg_shard.shard) &&
+              osds[pg_shard.shard] == pg_shard.osd);
+    } else {
+      return std::find(osds.begin(), osds.end(), pg_shard.osd) != osds.end();
+    }
+  }
+}
+
+bool PG::is_acting(pg_shard_t pg_shard) const
+{
+  return has_shard(pool.is_erasure(), acting, pg_shard);
+}
+
+bool PG::is_up(pg_shard_t pg_shard) const
+{
+  return has_shard(pool.is_erasure(), up, pg_shard);
+}
+
 epoch_t PG::get_last_peering_reset() const
 {
   return last_peering_reset;
index 4c293d707e0d6ee281f92ea85de19d9d818517fa..d2fb3535dd4e5e6dde46f9e66df9e77c77d74d67 100644 (file)
@@ -47,6 +47,8 @@ public:
   const PastIntervals& get_past_intervals() const;
   pg_shard_t get_primary() const;
   bool is_primary() const;
+  bool is_acting(pg_shard_t pg_shard) const;
+  bool is_up(pg_shard_t pg_shard) const;
   pg_shard_t get_whoami() const;
   epoch_t get_last_peering_reset() const;
   void update_last_peering_reset();