]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: account total number of metadata entries for sync
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 27 Oct 2015 00:00:46 +0000 (17:00 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:24 +0000 (16:13 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_meta_sync_status.h
src/rgw/rgw_sync.cc

index 13fc080baff47dd5f6e81b65023ab5b2cf7f1dd8..ddee27442501a1a2968850cf2cf1d16c26afeced 100644 (file)
@@ -137,7 +137,7 @@ RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWAioCompletionNotifier *c
 
 RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid)
                       : RGWConsumerCR<string>(_store->ctx()), async_rados(_async_rados),
-                        store(_store), pool(_pool), oid(_oid), going_down(false), num_pending_entries(0)
+                        store(_store), pool(_pool), oid(_oid), going_down(false), num_pending_entries(0), total_entries(0)
 {
 }
 
@@ -365,6 +365,7 @@ void RGWOmapAppend::flush_pending() {
 }
 
 void RGWOmapAppend::append(const string& s) {
+  ++total_entries;
   pending_entries.push_back(s);
   if (++num_pending_entries >= OMAP_APPEND_MAX_ENTRIES) {
     flush_pending();
index 38dddd2b90b6a84beb4647674aef3e55066d3c85..ee0e95941371fa84fb3eee016a89e691e48b5ef2 100644 (file)
@@ -430,12 +430,18 @@ class RGWOmapAppend : public RGWConsumerCR<string> {
   list<string> pending_entries;
 
   map<string, bufferlist> entries;
+
+  uint64_t total_entries;
 public:
   RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid);
   int operate();
   void flush_pending();
   void append(const string& s);
   void finish();
+
+  uint64_t get_total_entries() {
+    return total_entries;
+  }
 };
 
 class RGWAsyncWait : public RGWAsyncRadosRequest {
@@ -525,6 +531,10 @@ public:
       (*iter)->finish();
     }
   }
+
+  uint64_t get_total_entries(int shard_id) {
+    return shards[shard_id]->get_total_entries();
+  }
 };
 
 class RGWAsyncGetBucketInstanceInfo : public RGWAsyncRadosRequest {
index f13828b5c7572ee7af2725d2c2f06248e36d8e2a..0b6b2e0e4c3956cbb745fef35278e428921b5122 100644 (file)
@@ -1162,6 +1162,8 @@ void rgw_meta_sync_marker::decode_json(JSONObj *obj)
   state = s;
   JSONDecoder::decode_json("marker", marker, obj);
   JSONDecoder::decode_json("next_step_marker", next_step_marker, obj);
+  JSONDecoder::decode_json("total_entries", total_entries, obj);
+  JSONDecoder::decode_json("pos", pos, obj);
 }
 
 void rgw_meta_sync_marker::dump(Formatter *f) const
@@ -1169,6 +1171,8 @@ void rgw_meta_sync_marker::dump(Formatter *f) const
   encode_json("state", (int)state, f);
   encode_json("marker", marker, f);
   encode_json("next_step_marker", next_step_marker, f);
+  encode_json("total_entries", total_entries, f);
+  encode_json("pos", pos, f);
 }
 
 void rgw_meta_sync_status::decode_json(JSONObj *obj)
index ee6719a69a6394ea8aeb96f6a7947bb385dfab15..414994490f9b9a3fc05a49bf023ef469cf0e402c 100644 (file)
@@ -40,14 +40,18 @@ struct rgw_meta_sync_marker {
   uint16_t state;
   string marker;
   string next_step_marker;
+  uint64_t total_entries;
+  uint64_t pos;
 
-  rgw_meta_sync_marker() : state(FullSync) {}
+  rgw_meta_sync_marker() : state(FullSync), total_entries(0), pos(0) {}
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
     ::encode(state, bl);
     ::encode(marker, bl);
     ::encode(next_step_marker, bl);
+    ::encode(total_entries, bl);
+    ::encode(pos, bl);
     ENCODE_FINISH(bl);
   }
 
@@ -56,6 +60,8 @@ struct rgw_meta_sync_marker {
     ::decode(state, bl);
     ::decode(marker, bl);
     ::decode(next_step_marker, bl);
+    ::decode(total_entries, bl);
+    ::decode(pos, bl);
      DECODE_FINISH(bl);
   }
 
index b2183bcb72a0f0383395e578e41e9b81e099eb80..9d4b262bc78f7104feb58b3fe4ad845f06ebe63e 100644 (file)
@@ -549,12 +549,15 @@ class RGWFetchAllMetaCR : public RGWCoroutine {
   RGWContinuousLeaseCR *lease_cr;
   bool lost_lock;
 
+  map<uint32_t, rgw_meta_sync_marker>& markers;
+
 public:
-  RGWFetchAllMetaCR(RGWRados *_store, RGWHTTPManager *_mgr, RGWAsyncRadosProcessor *_async_rados, int _num_shards) : RGWCoroutine(_store->ctx()), store(_store),
+  RGWFetchAllMetaCR(RGWRados *_store, RGWHTTPManager *_mgr, RGWAsyncRadosProcessor *_async_rados, int _num_shards,
+                    map<uint32_t, rgw_meta_sync_marker>& _markers) : RGWCoroutine(_store->ctx()), store(_store),
                                                       http_manager(_mgr),
                                                      async_rados(_async_rados),
                                                      num_shards(_num_shards),
-                                                     req_ret(0), entries_index(NULL), lease_cr(NULL), lost_lock(false) {
+                                                     req_ret(0), entries_index(NULL), lease_cr(NULL), lost_lock(false), markers(_markers) {
   }
 
   ~RGWFetchAllMetaCR() {
@@ -647,6 +650,14 @@ public:
       }
       yield entries_index->finish();
 
+      for (map<uint32_t, rgw_meta_sync_marker>::iterator iter = markers.begin(); iter != markers.end(); ++iter) {
+        int shard_id = (int)iter->first;
+        rgw_meta_sync_marker& marker = iter->second;
+        marker.total_entries = entries_index->get_total_entries(shard_id);
+        spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(async_rados, store, store->get_zone_params().log_pool,
+                                                              RGWMetaSyncStatusManager::shard_obj_name(shard_id), marker), true);
+      }
+
       drain_all_but(1); /* the lease cr still needs to run */
 
       yield lease_cr->go_down();
@@ -1385,7 +1396,7 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status
     switch ((rgw_meta_sync_info::SyncState)sync_status.sync_info.state) {
       case rgw_meta_sync_info::StateBuildingFullSyncMaps:
         ldout(store->ctx(), 20) << __func__ << "(): building full sync maps" << dendl;
-        r = run(new RGWFetchAllMetaCR(store, &http_manager, async_rados, num_shards));
+        r = run(new RGWFetchAllMetaCR(store, &http_manager, async_rados, num_shards, sync_status.sync_markers));
         if (r == -EBUSY) {
           backoff.backoff_sleep();
           continue;