]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: make is_acting_osd_shard an explicit spg_t check
authorSage Weil <sage@redhat.com>
Fri, 10 Feb 2017 04:08:19 +0000 (23:08 -0500)
committerSage Weil <sage@redhat.com>
Tue, 14 Feb 2017 04:03:51 +0000 (23:03 -0500)
Ensure that the ps value is < the pool pg_num.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 9078808e0d55d8b454009f5c0db349f4972989ef..92db3419e8cd467713f3700587b26b8421f43a83 100644 (file)
@@ -7534,7 +7534,7 @@ void OSD::consume_map()
   for (set<spg_t>::iterator p = pgs_to_check.begin();
        p != pgs_to_check.end();
        ++p) {
-    if (!(osdmap->is_acting_osd_shard(p->pgid, whoami, p->shard))) {
+    if (!(osdmap->is_acting_osd_shard(spg_t(p->pgid, p->shard), whoami))) {
       set<Session*> concerned_sessions;
       get_sessions_possibly_interested_in_pg(*p, &concerned_sessions);
       for (set<Session*>::iterator i = concerned_sessions.begin();
index 89bda09f2907020395f8c54a070298f6845b452c..29b063a171c8bf8d8f9d2f419456cc32a5664db7 100644 (file)
@@ -1725,11 +1725,14 @@ void OSDMap::pg_to_raw_up(pg_t pg, vector<int> *up, int *primary) const
   _apply_primary_affinity(pps, *pool, up, primary);
 }
   
-void OSDMap::_pg_to_up_acting_osds(const pg_t& pg, vector<int> *up, int *up_primary,
-                                   vector<int> *acting, int *acting_primary) const
+void OSDMap::_pg_to_up_acting_osds(
+  const pg_t& pg, vector<int> *up, int *up_primary,
+  vector<int> *acting, int *acting_primary,
+  bool raw_pg_to_pg) const
 {
   const pg_pool_t *pool = get_pg_pool(pg.pool());
-  if (!pool) {
+  if (!pool ||
+      (!raw_pg_to_pg && pg.ps() >= pool->get_pg_num())) {
     if (up)
       up->clear();
     if (up_primary)
index b33c7ab748efa72119ef3e81de169b1b2b14a5d3..e7bcb46aa676df1b3a5a899db54cda836dbf9690 100644 (file)
@@ -655,7 +655,8 @@ private:
    *  map to up and acting. Fills in whatever fields are non-NULL.
    */
   void _pg_to_up_acting_osds(const pg_t& pg, vector<int> *up, int *up_primary,
-                             vector<int> *acting, int *acting_primary) const;
+                             vector<int> *acting, int *acting_primary,
+                            bool raw_pg_to_pg = true) const;
 
 public:
   /***
@@ -777,17 +778,17 @@ public:
     return -1;  // we fail!
   }
 
-  bool is_acting_osd_shard(pg_t pg, int osd, shard_id_t shard) const {
+  /*
+   * check whether an spg_t maps to a particular osd
+   */
+  bool is_acting_osd_shard(spg_t pg, int osd) const {
     vector<int> acting;
-    int nrep = pg_to_acting_osds(pg, acting);
-    if (shard == shard_id_t::NO_SHARD)
-      return calc_pg_role(osd, acting, nrep) >= 0;
-    if (shard >= (int)acting.size())
+    _pg_to_up_acting_osds(pg.pgid, NULL, NULL, &acting, NULL, false);
+    if (pg.shard == shard_id_t::NO_SHARD)
+      return calc_pg_role(osd, acting, acting.size()) >= 0;
+    if (pg.shard >= (int)acting.size())
       return false;
-    return acting[shard] == osd;
-  }
-  bool is_acting_osd_shard(spg_t pgid, int osd) const {
-    return is_acting_osd_shard(pgid.pgid, osd, pgid.shard);
+    return acting[pg.shard] == osd;
   }