]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: async-recovery should respect historical missing objects
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 7 Sep 2018 03:05:02 +0000 (11:05 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 19 Sep 2018 04:06:01 +0000 (12:06 +0800)
Peers with async-recovery enabled are usually having a update-to-date
last-update iterator and hence might be moved out from the __async_recovery_targets__
set during the next peering circles.

7de35629f562436d2bdb85788bdf97b10db3f556 makes num_objects_missing
trace historical missing objects correctly, hence we could take
num_objects_missing into account when determing __async_recovery_targets__.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/common/options.cc
src/osd/PG.cc

index d1c295d3fb3f35337cb08a8fbfb3c125f4a16719..2bd33f07bdd20dd963cb79c1750dcdefc95ac664 100644 (file)
@@ -3227,9 +3227,11 @@ std::vector<Option> get_global_options() {
     .set_default(100)
     .set_description("Approximate missing objects above which to force auth_log_shard to be primary temporarily"),
 
-    Option("osd_async_recovery_min_pg_log_entries", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
+    Option("osd_async_recovery_min_cost", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(100)
-    .set_description("Number of entries difference above which to use asynchronous recovery when appropriate"),
+    .set_description("A mixture measure of number of current log entries difference "
+                     "and historical missing objects,  above which we switch to use "
+                     "asynchronous recovery when appropriate"),
 
     Option("osd_max_pg_per_osd_hard_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
     .set_default(3)
index 8e192ca4c3f626b3917fb5da8063e6b5f3fe80f0..612ec6c583ca55a60d828887795f63e33fe4ab4d 100644 (file)
@@ -1564,9 +1564,14 @@ void PG::choose_async_recovery_ec(const map<pg_shard_t, pg_info_t> &all_info,
     // past the authoritative last_update the same as those equal to it.
     version_t auth_version = auth_info.last_update.version;
     version_t candidate_version = shard_info.last_update.version;
-    if (auth_version > candidate_version &&
-        (auth_version - candidate_version) > cct->_conf.get_val<uint64_t>("osd_async_recovery_min_pg_log_entries")) {
-      candidates_by_cost.insert(make_pair(auth_version - candidate_version, shard_i));
+    auto approx_missing_objects =
+      shard_info.stats.stats.sum.num_objects_missing;
+    if (auth_version > candidate_version) {
+      approx_missing_objects += auth_version - candidate_version;
+    }
+    if (approx_missing_objects > cct->_conf.get_val<uint64_t>(
+        "osd_async_recovery_min_cost")) {
+      candidates_by_cost.insert(make_pair(approx_missing_objects, shard_i));
     }
   }
 
@@ -1607,17 +1612,19 @@ void PG::choose_async_recovery_replicated(const map<pg_shard_t, pg_info_t> &all_
       continue;
     auto shard_info = all_info.find(shard_i)->second;
     // use the approximate magnitude of the difference in length of
-    // logs as the cost of recovery
+    // logs plus historical missing objects as the cost of recovery
     version_t auth_version = auth_info.last_update.version;
     version_t candidate_version = shard_info.last_update.version;
-    size_t approx_entries;
+    auto approx_missing_objects =
+      shard_info.stats.stats.sum.num_objects_missing;
     if (auth_version > candidate_version) {
-      approx_entries = auth_version - candidate_version;
+      approx_missing_objects += auth_version - candidate_version;
     } else {
-      approx_entries = candidate_version - auth_version;
+      approx_missing_objects += candidate_version - auth_version;
     }
-    if (approx_entries > cct->_conf.get_val<uint64_t>("osd_async_recovery_min_pg_log_entries")) {
-      candidates_by_cost.insert(make_pair(approx_entries, shard_i));
+    if (approx_missing_objects  > cct->_conf.get_val<uint64_t>(
+        "osd_async_recovery_min_cost")) {
+      candidates_by_cost.insert(make_pair(approx_missing_objects, shard_i));
     }
   }