]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: peer trims mdlog shards up to master's oldest entry
authorCasey Bodley <cbodley@redhat.com>
Mon, 23 Jan 2017 21:34:42 +0000 (16:34 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 27 Apr 2017 14:39:22 +0000 (10:39 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_sync.cc

index e9c748eb59b2c72f1c4c7e0ce3a64d98c3d5beec..2112f7d0155b167fe2b57df8ca7f4d5a8be45c97 100644 (file)
@@ -2522,7 +2522,20 @@ struct MasterTrimEnv : public TrimEnv {
   }
 };
 
-using PeerTrimEnv = TrimEnv;
+struct PeerTrimEnv : public TrimEnv {
+  /// last trim timestamp for each shard, only applies to current period's mdlog
+  std::vector<ceph::real_time> last_trim_timestamps;
+
+  PeerTrimEnv(RGWRados *store, RGWHTTPManager *http, int num_shards)
+    : TrimEnv(store, http, num_shards),
+      last_trim_timestamps(num_shards)
+  {}
+
+  void set_num_shards(int num_shards) {
+    this->num_shards = num_shards;
+    last_trim_timestamps.resize(num_shards);
+  }
+};
 
 } // anonymous namespace
 
@@ -2838,6 +2851,8 @@ int MetaPeerTrimCR::operate()
       ldout(cct, 4) << "failed to read mdlog info from master" << dendl;
       return set_cr_error(retcode);
     }
+    // use master's shard count instead
+    env.set_num_shards(mdlog_info.num_shards);
 
     if (mdlog_info.realm_epoch > env.last_trim_epoch + 1) {
       // delete any prior mdlog periods
@@ -2847,6 +2862,16 @@ int MetaPeerTrimCR::operate()
       ldout(cct, 10) << "mdlogs already purged through realm_epoch "
           << env.last_trim_epoch << dendl;
     }
+
+    // if realm_epoch == current, trim mdlog based on master's markers
+    if (mdlog_info.realm_epoch == env.current.get_epoch()) {
+      yield {
+        auto meta_mgr = env.store->meta_mgr;
+        auto mdlog = meta_mgr->get_log(env.current.get_period().get_id());
+        spawn(new MetaPeerTrimShardCollectCR(env, mdlog), true);
+        // ignore any errors during purge/trim because we want to hold the lock open
+      }
+    }
     return set_cr_done();
   }
   return 0;