]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: resend linger ops on any interval change
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 20 Oct 2014 20:29:13 +0000 (13:29 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 23 Oct 2014 20:57:27 +0000 (13:57 -0700)
Watch/notify ops need to be resent after a pg split occurs, as well as
a few other circumstances that the existing objecter checks did not
catch.

Refactor the check the OSD uses for this to add a version taking the
more basic types instead of the whole OSD map, and stash the needed
info when an op is sent.

Fixes: #9806
Backport: giant, firefly, dumpling
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/osd/osd_types.cc
src/osd/osd_types.h
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 47cb37bc084724afbf64fb12f07b3d2d865cf6b4..ed06c4fd6e13064060fe590408531ca027d02df8 100644 (file)
@@ -2329,18 +2329,45 @@ bool pg_interval_t::is_new_interval(
   int new_up_primary,
   const vector<int> &old_up,
   const vector<int> &new_up,
-  OSDMapRef osdmap,
-  OSDMapRef lastmap,
+  int old_min_size,
+  int new_min_size,
+  unsigned old_pg_num,
+  unsigned new_pg_num,
   pg_t pgid) {
   return old_acting_primary != new_acting_primary ||
     new_acting != old_acting ||
     old_up_primary != new_up_primary ||
     new_up != old_up ||
-    (!(lastmap->get_pools().count(pgid.pool()))) ||
-    (lastmap->get_pools().find(pgid.pool())->second.min_size !=
-     osdmap->get_pools().find(pgid.pool())->second.min_size)  ||
-    pgid.is_split(lastmap->get_pg_num(pgid.pool()),
-                 osdmap->get_pg_num(pgid.pool()), 0);
+    old_min_size != new_min_size ||
+    pgid.is_split(old_pg_num, new_pg_num, 0);
+}
+
+bool pg_interval_t::is_new_interval(
+  int old_acting_primary,
+  int new_acting_primary,
+  const vector<int> &old_acting,
+  const vector<int> &new_acting,
+  int old_up_primary,
+  int new_up_primary,
+  const vector<int> &old_up,
+  const vector<int> &new_up,
+  OSDMapRef osdmap,
+  OSDMapRef lastmap,
+  pg_t pgid) {
+  return !(lastmap->get_pools().count(pgid.pool())) ||
+    is_new_interval(old_acting_primary,
+                   new_acting_primary,
+                   old_acting,
+                   new_acting,
+                   old_up_primary,
+                   new_up_primary,
+                   old_up,
+                   new_up,
+                   lastmap->get_pools().find(pgid.pool())->second.min_size,
+                   osdmap->get_pools().find(pgid.pool())->second.min_size,
+                   lastmap->get_pg_num(pgid.pool()),
+                   osdmap->get_pg_num(pgid.pool()),
+                   pgid);
 }
 
 bool pg_interval_t::check_new_interval(
index 9840bf16cfed5e9761663cdcead01b4d5a0b1abf..988cebe69597f9f0b7a8c390f889c1ebf0d0a3c7 100644 (file)
@@ -1773,6 +1773,25 @@ struct pg_interval_t {
   void dump(Formatter *f) const;
   static void generate_test_instances(list<pg_interval_t*>& o);
 
+  /**
+   * Determines whether there is an interval change
+   */
+  static bool is_new_interval(
+    int old_acting_primary,
+    int new_acting_primary,
+    const vector<int> &old_acting,
+    const vector<int> &new_acting,
+    int old_up_primary,
+    int new_up_primary,
+    const vector<int> &old_up,
+    const vector<int> &new_up,
+    int old_min_size,
+    int new_min_size,
+    unsigned old_pg_num,
+    unsigned new_pg_num,
+    pg_t pgid
+    );
+
   /**
    * Determines whether there is an interval change
    */
index 035127acc99ce1f89d96231ad38fd372c4baffb8..048ecc7f9dfa2127fd7ef30028b937afee767085 100644 (file)
@@ -2050,9 +2050,29 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
       return RECALC_OP_TARGET_POOL_DNE;
     }
   }
-  int primary;
-  vector<int> acting;
-  osdmap->pg_to_acting_osds(pgid, &acting, &primary);
+
+  int min_size = pi->min_size;
+  unsigned pg_num = pi->get_pg_num();
+  int up_primary, acting_primary;
+  vector<int> up, acting;
+  osdmap->pg_to_up_acting_osds(pgid, &up, &up_primary,
+                              &acting, &acting_primary);
+  if (any_change && pg_interval_t::is_new_interval(
+          t->acting_primary,
+         acting_primary,
+         t->acting,
+         acting,
+         t->up_primary,
+         up_primary,
+         t->up,
+         up,
+         t->min_size,
+         min_size,
+         t->pg_num,
+         pg_num,
+         pi->raw_pg_to_pg(pgid))) {
+    force_resend = true;
+  }
 
   bool need_resend = false;
 
@@ -2064,15 +2084,20 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
 
   if (t->pgid != pgid ||
       is_pg_changed(
-       t->primary, t->acting, primary, acting, t->used_replica || any_change) ||
+       t->acting_primary, t->acting, acting_primary, acting,
+       t->used_replica || any_change) ||
       force_resend) {
     t->pgid = pgid;
     t->acting = acting;
-    t->primary = primary;
+    t->acting_primary = acting_primary;
+    t->up_primary = up_primary;
+    t->up = up;
+    t->min_size = min_size;
+    t->pg_num = pg_num;
     ldout(cct, 10) << __func__ << " "
                   << " pgid " << pgid << " acting " << acting << dendl;
     t->used_replica = false;
-    if (primary == -1) {
+    if (acting_primary == -1) {
       t->osd = -1;
     } else {
       int osd;
@@ -2108,7 +2133,7 @@ int Objecter::_calc_target(op_target_t *t, bool any_change)
        assert(best >= 0);
        osd = acting[best];
       } else {
-       osd = primary;
+       osd = acting_primary;
       }
       t->osd = osd;
     }
index b45f40615b25a861c52acc11b782dd06e89a1d5f..8bf1350cd3f00e6f041c06d2749a1b238e2b5aab 100644 (file)
@@ -1078,8 +1078,12 @@ public:
     pg_t base_pgid;      ///< explciti pg target, if any
 
     pg_t pgid;           ///< last pg we mapped to
-    vector<int> acting;  ///< acting for last pg we mapped to
-    int primary;         ///< primary for last pg we mapped to
+    unsigned pg_num;     ///< last pg_num we mapped to
+    vector<int> up;      ///< set of up osds for last pg we mapped to
+    vector<int> acting;  ///< set of acting osds for last pg we mapped to
+    int up_primary;      ///< primary for last pg we mapped to based on the up set
+    int acting_primary;  ///< primary for last pg we mapped to based on the acting set
+    int min_size;        ///< the min size of the pool when were were last mapped
 
     bool used_replica;
     bool paused;
@@ -1091,7 +1095,10 @@ public:
        base_oid(oid),
        base_oloc(oloc),
        precalc_pgid(false),
-       primary(-1),
+       pg_num(0),
+       up_primary(-1),
+       acting_primary(-1),
+       min_size(-1),
        used_replica(false),
        paused(false),
        osd(-1)