]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: make pg merge an interval boundary
authorSage Weil <sage@redhat.com>
Fri, 16 Feb 2018 03:24:17 +0000 (21:24 -0600)
committerSage Weil <sage@redhat.com>
Fri, 7 Sep 2018 17:07:56 +0000 (12:07 -0500)
Both the merge itself *and* the pending merge are interval transitions.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/osd_types.cc
src/osd/osd_types.h
src/osdc/Objecter.cc
src/osdc/Objecter.h
src/test/osd/types.cc

index 7a5e7cfa3b8a35c58a3602fa75462d8190fe98a7..1b88cc6ff772e348867d69b63eede124b87a05e1 100644 (file)
@@ -3417,6 +3417,8 @@ bool PastIntervals::is_new_interval(
   int new_min_size,
   unsigned old_pg_num,
   unsigned new_pg_num,
+  unsigned old_pg_num_pending,
+  unsigned new_pg_num_pending,
   bool old_sort_bitwise,
   bool new_sort_bitwise,
   bool old_recovery_deletes,
@@ -3429,6 +3431,16 @@ bool PastIntervals::is_new_interval(
     old_min_size != new_min_size ||
     old_size != new_size ||
     pgid.is_split(old_pg_num, new_pg_num, 0) ||
+    // pre-merge source
+    pgid.is_merge(old_pg_num_pending, new_pg_num_pending, 0) ||
+    // merge source
+    pgid.is_merge(old_pg_num, new_pg_num, 0) ||
+    // pre-merge target
+    (pgid.ps() < new_pg_num_pending &&
+     pgid.is_split(new_pg_num_pending, old_pg_num_pending, 0)) ||
+    // merge target
+    (pgid.ps() < new_pg_num &&
+     pgid.is_split(new_pg_num, old_pg_num, 0)) ||
     old_sort_bitwise != new_sort_bitwise ||
     old_recovery_deletes != new_recovery_deletes;
 }
@@ -3469,6 +3481,8 @@ bool PastIntervals::is_new_interval(
                    pi->min_size,
                    plast->get_pg_num(),
                    pi->get_pg_num(),
+                   plast->get_pg_num_pending(),
+                   pi->get_pg_num_pending(),
                    lastmap->test_flag(CEPH_OSDMAP_SORTBITWISE),
                    osdmap->test_flag(CEPH_OSDMAP_SORTBITWISE),
                    lastmap->test_flag(CEPH_OSDMAP_RECOVERY_DELETES),
index 91fa9e31653ff59d965dbebb09c71c83b7e9c123..57b022cf6af2b6f700096fd86b1309669f00fc48 100644 (file)
@@ -2780,6 +2780,8 @@ public:
     int new_min_size,
     unsigned old_pg_num,
     unsigned new_pg_num,
+    unsigned old_pg_num_pending,
+    unsigned new_pg_num_pending,
     bool old_sort_bitwise,
     bool new_sort_bitwise,
     bool old_recovery_deletes,
index 9049bde3c65ac209a1ce79679760893f44cb2acf..f9178ab8afb066d73f8d4ed46e34eeb6a4f7b519 100644 (file)
@@ -2861,6 +2861,7 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change)
   int size = pi->size;
   int min_size = pi->min_size;
   unsigned pg_num = pi->get_pg_num();
+  unsigned pg_num_pending = pi->get_pg_num_pending();
   int up_primary, acting_primary;
   vector<int> up, acting;
   osdmap->pg_to_up_acting_osds(pgid, &up, &up_primary,
@@ -2884,6 +2885,8 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change)
        min_size,
        t->pg_num,
        pg_num,
+       t->pg_num_pending,
+       pg_num_pending,
        t->sort_bitwise,
        sort_bitwise,
        t->recovery_deletes,
@@ -2918,6 +2921,7 @@ int Objecter::_calc_target(op_target_t *t, Connection *con, bool any_change)
     t->min_size = min_size;
     t->pg_num = pg_num;
     t->pg_num_mask = pi->get_pg_num_mask();
+    t->pg_num_pending = pg_num_pending;
     osdmap->get_primary_shard(
       pg_t(ceph_stable_mod(pgid.ps(), t->pg_num, t->pg_num_mask), pgid.pool()),
       &t->actual_pgid);
index 8d215b91ada360da5effc4d085fca90305d86244..30b27930f72ca65e3f087119b490bcc64c32fb0a 100644 (file)
@@ -1298,6 +1298,7 @@ public:
     spg_t actual_pgid; ///< last (actual) spg_t we mapped to
     unsigned pg_num = 0; ///< last pg_num we mapped to
     unsigned pg_num_mask = 0; ///< last pg_num_mask we mapped to
+    unsigned pg_num_pending = 0; ///< 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 = -1; ///< last up_primary we mapped to
index 58bd183fa95925ad580967823ac5f3d717528a13..0c5ad7a3fccdabe0d656aa1a8e8d34d076a67d32 100644 (file)
@@ -149,6 +149,7 @@ for (unsigned i = 0; i < 4; ++i) {
     OSDMap::Incremental inc(epoch + 1);
     inc.new_pools[pool_id].min_size = min_size;
     inc.new_pools[pool_id].set_pg_num(pg_num);
+    inc.new_pools[pool_id].set_pg_num_pending(pg_num, 1);
     inc.new_up_thru[osd_id] = epoch + 1;
     osdmap->apply_incremental(inc);
     lastmap->apply_incremental(inc);
@@ -312,6 +313,139 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  &past_intervals));
   }
 
+  //
+  // PG is pre-merge source
+  //
+  {
+    std::shared_ptr<OSDMap> osdmap(new OSDMap());
+    osdmap->set_max_osd(10);
+    osdmap->set_state(osd_id, CEPH_OSD_EXISTS);
+    osdmap->set_epoch(epoch);
+    OSDMap::Incremental inc(epoch + 1);
+    inc.new_pools[pool_id].min_size = min_size;
+    inc.new_pools[pool_id].set_pg_num(pg_num);
+    inc.new_pools[pool_id].set_pg_num_pending(pg_num - 1, epoch + 1);
+    osdmap->apply_incremental(inc);
+    cout << "pg_num " << pg_num << std::endl;
+    PastIntervals past_intervals;
+
+    ASSERT_TRUE(past_intervals.empty());
+    ASSERT_TRUE(PastIntervals::check_new_interval(old_primary,
+                                                 new_primary,
+                                                 old_acting,
+                                                 new_acting,
+                                                 old_up_primary,
+                                                 new_up_primary,
+                                                 old_up,
+                                                 new_up,
+                                                 same_interval_since,
+                                                 last_epoch_clean,
+                                                 osdmap,
+                                                 lastmap,
+                                                 pg_t(pg_num - 1, pool_id),
+                                                  recoverable.get(),
+                                                 &past_intervals));
+  }
+
+  //
+  // PG is merge source
+  //
+  {
+    std::shared_ptr<OSDMap> osdmap(new OSDMap());
+    osdmap->set_max_osd(10);
+    osdmap->set_state(osd_id, CEPH_OSD_EXISTS);
+    osdmap->set_epoch(epoch);
+    OSDMap::Incremental inc(epoch + 1);
+    inc.new_pools[pool_id].min_size = min_size;
+    inc.new_pools[pool_id].set_pg_num(pg_num - 1);
+    osdmap->apply_incremental(inc);
+
+    PastIntervals past_intervals;
+
+    ASSERT_TRUE(past_intervals.empty());
+    ASSERT_TRUE(PastIntervals::check_new_interval(old_primary,
+                                                 new_primary,
+                                                 old_acting,
+                                                 new_acting,
+                                                 old_up_primary,
+                                                 new_up_primary,
+                                                 old_up,
+                                                 new_up,
+                                                 same_interval_since,
+                                                 last_epoch_clean,
+                                                 osdmap,
+                                                 lastmap,
+                                                 pg_t(pg_num - 1, pool_id),
+                                                  recoverable.get(),
+                                                 &past_intervals));
+  }
+
+  //
+  // PG is pre-merge target
+  //
+  {
+    std::shared_ptr<OSDMap> osdmap(new OSDMap());
+    osdmap->set_max_osd(10);
+    osdmap->set_state(osd_id, CEPH_OSD_EXISTS);
+    osdmap->set_epoch(epoch);
+    OSDMap::Incremental inc(epoch + 1);
+    inc.new_pools[pool_id].min_size = min_size;
+    inc.new_pools[pool_id].set_pg_num_pending(pg_num - 1, epoch + 1);
+    osdmap->apply_incremental(inc);
+
+    PastIntervals past_intervals;
+
+    ASSERT_TRUE(past_intervals.empty());
+    ASSERT_TRUE(PastIntervals::check_new_interval(old_primary,
+                                                 new_primary,
+                                                 old_acting,
+                                                 new_acting,
+                                                 old_up_primary,
+                                                 new_up_primary,
+                                                 old_up,
+                                                 new_up,
+                                                 same_interval_since,
+                                                 last_epoch_clean,
+                                                 osdmap,
+                                                 lastmap,
+                                                 pg_t(pg_num / 2 - 1, pool_id),
+                                                  recoverable.get(),
+                                                 &past_intervals));
+  }
+
+  //
+  // PG is merge target
+  //
+  {
+    std::shared_ptr<OSDMap> osdmap(new OSDMap());
+    osdmap->set_max_osd(10);
+    osdmap->set_state(osd_id, CEPH_OSD_EXISTS);
+    osdmap->set_epoch(epoch);
+    OSDMap::Incremental inc(epoch + 1);
+    inc.new_pools[pool_id].min_size = min_size;
+    inc.new_pools[pool_id].set_pg_num(pg_num - 1);
+    osdmap->apply_incremental(inc);
+
+    PastIntervals past_intervals;
+
+    ASSERT_TRUE(past_intervals.empty());
+    ASSERT_TRUE(PastIntervals::check_new_interval(old_primary,
+                                                 new_primary,
+                                                 old_acting,
+                                                 new_acting,
+                                                 old_up_primary,
+                                                 new_up_primary,
+                                                 old_up,
+                                                 new_up,
+                                                 same_interval_since,
+                                                 last_epoch_clean,
+                                                 osdmap,
+                                                 lastmap,
+                                                 pg_t(pg_num / 2 - 1, pool_id),
+                                                  recoverable.get(),
+                                                 &past_intervals));
+  }
+
   //
   // PG size has changed
   //