]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Remove superfluous wrapper around datalog
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 12 May 2020 23:59:17 +0000 (19:59 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Wed, 9 Sep 2020 02:09:40 +0000 (22:09 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
12 files changed:
src/rgw/CMakeLists.txt
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_data_sync.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_log.cc
src/rgw/rgw_service.cc
src/rgw/rgw_service.h
src/rgw/rgw_trim_datalog.cc
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_bi_rados.h

index 8303f790e279f197eb78870fcb4d0d80cf7790bc..5d4ab489d103a52a5c9c787e47aebf1a53b6b310 100644 (file)
@@ -28,7 +28,6 @@ set(librgw_common_srcs
   services/svc_bucket_sync_sobj.cc
   services/svc_cls.cc
   services/svc_config_key_rados.cc
-  services/svc_datalog_rados.cc
   services/svc_mdlog.cc
   services/svc_meta.cc
   services/svc_meta_be.cc
index c16899f4426b2908f31d4f496141168a3db73218..73008201e838990969fa0b02536b93ac7a98e969 100644 (file)
@@ -62,7 +62,6 @@ extern "C" {
 #include "services/svc_sync_modules.h"
 #include "services/svc_cls.h"
 #include "services/svc_bilog_rados.h"
-#include "services/svc_datalog_rados.h"
 #include "services/svc_mdlog.h"
 #include "services/svc_meta_be_otp.h"
 #include "services/svc_zone.h"
index e1120a291eba32d100b1803c16662f5f1786d384..32f299efbc164f4db22ff4703352de942e6054e2 100644 (file)
@@ -41,7 +41,6 @@
 #include "services/svc_user.h"
 #include "services/svc_cls.h"
 #include "services/svc_bilog_rados.h"
-#include "services/svc_datalog_rados.h"
 
 #include "include/rados/librados.hpp"
 // until everything is moved from rgw_common
@@ -2024,28 +2023,29 @@ void rgw_data_change_log_entry::decode_json(JSONObj *obj) {
 }
 
 
-RGWDataChangesLog::RGWDataChangesLog(RGWSI_Zone *zone_svc, RGWSI_Cls *cls_svc)
-  : cct(zone_svc->ctx()), changes(cct->_conf->rgw_data_log_changes_size)
+RGWDataChangesLog::RGWDataChangesLog(CephContext* cct)
+  : cct(cct),
+    num_shards(cct->_conf->rgw_data_log_num_shards),
+    changes(cct->_conf->rgw_data_log_changes_size) {}
+
+void RGWDataChangesLog::init(RGWSI_Cls *cls_svc)
 {
-  svc.zone = zone_svc;
   svc.cls = cls_svc;
-
-  num_shards = cct->_conf->rgw_data_log_num_shards;
+  assert(svc.cls);
 
   oids = new string[num_shards];
-
-  string prefix = cct->_conf->rgw_data_log_obj_prefix;
-
-  if (prefix.empty()) {
-    prefix = "data_log";
-  }
-
   for (int i = 0; i < num_shards; i++) {
     oids[i] = get_oid(i);
   }
+}
 
-  renew_thread = new ChangesRenewThread(cct, this);
-  renew_thread->create("rgw_dt_lg_renew");
+int RGWDataChangesLog::start(const RGWZone* _zone)
+{
+  zone = _zone;
+  assert(zone);
+  renew_thread = make_named_thread("rgw_dt_lg_renew",
+                                  &RGWDataChangesLog::renew_run, this);
+  return 0;
 }
 
 int RGWDataChangesLog::choose_oid(const rgw_bucket_shard& bs) {
@@ -2058,7 +2058,7 @@ int RGWDataChangesLog::choose_oid(const rgw_bucket_shard& bs) {
 
 int RGWDataChangesLog::renew_entries()
 {
-  if (!svc.zone->need_to_log_data())
+  if (!zone->log_data)
     return 0;
 
   /* we can't keep the bucket name as part of the cls_log_entry, and we need
@@ -2374,35 +2374,34 @@ bool RGWDataChangesLog::going_down()
 
 RGWDataChangesLog::~RGWDataChangesLog() {
   down_flag = true;
-  renew_thread->stop();
-  renew_thread->join();
-  delete renew_thread;
+  if (renew_thread.joinable()) {
+    renew_stop();
+    renew_thread.join();
+  }
   delete[] oids;
 }
 
-void *RGWDataChangesLog::ChangesRenewThread::entry() {
+void RGWDataChangesLog::renew_run() {
   for (;;) {
     dout(2) << "RGWDataChangesLog::ChangesRenewThread: start" << dendl;
-    int r = log->renew_entries();
+    int r = renew_entries();
     if (r < 0) {
       dout(0) << "ERROR: RGWDataChangesLog::renew_entries returned error r=" << r << dendl;
     }
 
-    if (log->going_down())
+    if (going_down())
       break;
 
     int interval = cct->_conf->rgw_data_log_window * 3 / 4;
-    std::unique_lock locker{lock};
-    cond.wait_for(locker, std::chrono::seconds(interval));
+    std::unique_lock locker{renew_lock};
+    renew_cond.wait_for(locker, std::chrono::seconds(interval));
   }
-
-  return NULL;
 }
 
-void RGWDataChangesLog::ChangesRenewThread::stop()
+void RGWDataChangesLog::renew_stop()
 {
-  std::lock_guard l{lock};
-  cond.notify_all();
+  std::lock_guard l{renew_lock};
+  renew_cond.notify_all();
 }
 
 void RGWDataChangesLog::mark_modified(int shard_id, const rgw_bucket_shard& bs)
index 5e862bcf46bcd4a4a09ae124fea4275e81f77af0..127643187cecce4ddfec9a76f6b22bdd5b313781 100644 (file)
@@ -32,6 +32,7 @@ class RGWBucketMetadataHandler;
 class RGWBucketInstanceMetadataHandler;
 class RGWUserCtl;
 class RGWBucketCtl;
+class RGWZone;
 
 namespace rgw { namespace sal {
   class RGWRadosStore;
@@ -492,9 +493,9 @@ struct RGWDataChangesLogMarker {
 class RGWDataChangesLog {
   CephContext *cct;
   rgw::BucketChangeObserver *observer = nullptr;
+  const RGWZone* zone;
 
   struct Svc {
-    RGWSI_Zone *zone{nullptr};
     RGWSI_Cls *cls{nullptr};
   } svc;
 
@@ -528,27 +529,22 @@ class RGWDataChangesLog {
   void register_renew(rgw_bucket_shard& bs);
   void update_renewed(rgw_bucket_shard& bs, ceph::real_time& expiration);
 
-  class ChangesRenewThread : public Thread {
-    CephContext *cct;
-    RGWDataChangesLog *log;
-    ceph::mutex lock = ceph::make_mutex("ChangesRenewThread::lock");
-    ceph::condition_variable cond;
-
-  public:
-    ChangesRenewThread(CephContext *_cct, RGWDataChangesLog *_log) : cct(_cct), log(_log) {}
-    void *entry() override;
-    void stop();
-  };
-
-  ChangesRenewThread* renew_thread;
+  ceph::mutex renew_lock = ceph::make_mutex("ChangesRenewThread::lock");
+  ceph::condition_variable renew_cond;
+  void renew_run();
+  void renew_stop();
+  std::thread renew_thread;
 
   std::function<bool(const rgw_bucket& bucket, optional_yield y)> bucket_filter;
 
 public:
 
-  RGWDataChangesLog(RGWSI_Zone *zone_svc, RGWSI_Cls *cls_svc);
+  RGWDataChangesLog(CephContext* cct);
   ~RGWDataChangesLog();
 
+  void init(RGWSI_Cls *cls_svc);
+  int start(const RGWZone* _zone);
+
   int choose_oid(const rgw_bucket_shard& bs);
   std::string get_oid(int shard_id) const;
   int add_entry(const RGWBucketInfo& bucket_info, int shard_id);
index 42d35f746e3fb36b1da4ce855836830bd2702795..94000fd5a1801e90f31d9b9cea242eb2d089d6c8 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "services/svc_zone.h"
 #include "services/svc_sync_modules.h"
-#include "services/svc_datalog_rados.h"
+#include "rgw_bucket.h"
 
 #include "include/common_fwd.h"
 #include "include/random.h"
index 7ef9f755e724bd6f30e7b4c06af85a97debef0e9..edd506f3a7dea311a232aae7a71b390e75ac6ee6 100644 (file)
@@ -82,7 +82,6 @@ using namespace librados;
 #include "services/svc_sys_obj_cache.h"
 #include "services/svc_bucket.h"
 #include "services/svc_mdlog.h"
-#include "services/svc_datalog_rados.h"
 
 #include "compressor/Compressor.h"
 
@@ -455,7 +454,7 @@ public:
 
 int RGWDataNotifier::process()
 {
-  auto data_log = store->svc.datalog_rados->get_log();
+  auto data_log = store->svc.datalog_rados;
   if (!data_log) {
     return 0;
   }
index c3ed31b4f582cf3e5a88356cb058cb1ec02442b8..f67b2c032b2e3efd86f883fad84b3b02956a3fdc 100644 (file)
@@ -29,7 +29,6 @@
 #include "services/svc_zone.h"
 #include "services/svc_mdlog.h"
 #include "services/svc_bilog_rados.h"
-#include "services/svc_datalog_rados.h"
 
 #include "common/errno.h"
 #include "include/ceph_assert.h"
index b86290fbb0341334f47033f6b6f9fe8216133a07..6980b0403071cefb4be77c6b7a99cea281a9e917 100644 (file)
@@ -10,7 +10,6 @@
 #include "services/svc_bucket_sync_sobj.h"
 #include "services/svc_cls.h"
 #include "services/svc_config_key_rados.h"
-#include "services/svc_datalog_rados.h"
 #include "services/svc_mdlog.h"
 #include "services/svc_meta.h"
 #include "services/svc_meta_be.h"
@@ -56,7 +55,7 @@ int RGWServices_Def::init(CephContext *cct,
   bilog_rados = std::make_unique<RGWSI_BILog_RADOS>(cct);
   cls = std::make_unique<RGWSI_Cls>(cct);
   config_key_rados = std::make_unique<RGWSI_ConfigKey_RADOS>(cct);
-  datalog_rados = std::make_unique<RGWSI_DataLog_RADOS>(cct);
+  datalog_rados = std::make_unique<RGWDataChangesLog>(cct);
   mdlog = std::make_unique<RGWSI_MDLog>(cct, run_sync);
   meta = std::make_unique<RGWSI_Meta>(cct);
   meta_be_sobj = std::make_unique<RGWSI_MetaBackend_SObj>(cct);
@@ -90,7 +89,7 @@ int RGWServices_Def::init(CephContext *cct,
                          bucket_sobj.get());
   cls->init(zone.get(), rados.get());
   config_key_rados->init(rados.get());
-  datalog_rados->init(zone.get(), cls.get());
+  datalog_rados->init(cls.get());
   mdlog->init(rados.get(), zone.get(), sysobj.get(), cls.get());
   meta->init(sysobj.get(), mdlog.get(), meta_bes);
   meta_be_sobj->init(sysobj.get(), mdlog.get());
@@ -141,6 +140,12 @@ int RGWServices_Def::init(CephContext *cct,
       return r;
     }
 
+    r = datalog_rados->start(&zone->get_zone());
+    if (r < 0) {
+      ldout(cct, 0) << "ERROR: failed to start datalog service (" << cpp_strerror(-r) << dendl;
+      return r;
+    }
+
     r = mdlog->start();
     if (r < 0) {
       ldout(cct, 0) << "ERROR: failed to start mdlog service (" << cpp_strerror(-r) << dendl;
@@ -199,12 +204,6 @@ int RGWServices_Def::init(CephContext *cct,
   }
 
   if (!raw) {
-    r = datalog_rados->start();
-    if (r < 0) {
-      ldout(cct, 0) << "ERROR: failed to start datalog_rados service (" << cpp_strerror(-r) << dendl;
-      return r;
-    }
-
     r = meta_be_sobj->start();
     if (r < 0) {
       ldout(cct, 0) << "ERROR: failed to start meta_be_sobj service (" << cpp_strerror(-r) << dendl;
@@ -257,8 +256,6 @@ void RGWServices_Def::shutdown()
     return;
   }
 
-  datalog_rados->shutdown();
-
   sysobj->shutdown();
   sysobj_core->shutdown();
   notify->shutdown();
@@ -377,7 +374,7 @@ int RGWCtlDef::init(RGWServices& svc)
   bucket->init(user.get(),
                (RGWBucketMetadataHandler *)bucket_meta_handler,
                (RGWBucketInstanceMetadataHandler *)bi_meta_handler,
-              svc.datalog_rados->get_log());
+              svc.datalog_rados);
 
   otp->init((RGWOTPMetadataHandler *)meta.otp.get());
 
index 02cf7ddea6af16bf8e0937fefbfeb60e94aa9c65..fc3fbe7266b49ed5e86d91fe3f94957b488ea554 100644 (file)
@@ -55,7 +55,6 @@ class RGWSI_BILog_RADOS;
 class RGWSI_Cls;
 class RGWSI_ConfigKey;
 class RGWSI_ConfigKey_RADOS;
-class RGWSI_DataLog_RADOS;
 class RGWSI_MDLog;
 class RGWSI_Meta;
 class RGWSI_MetaBackend;
@@ -73,6 +72,7 @@ class RGWSI_SysObj_Core;
 class RGWSI_SysObj_Cache;
 class RGWSI_User;
 class RGWSI_User_RADOS;
+class RGWDataChangesLog;
 
 struct RGWServices_Def
 {
@@ -86,7 +86,6 @@ struct RGWServices_Def
   std::unique_ptr<RGWSI_BILog_RADOS> bilog_rados;
   std::unique_ptr<RGWSI_Cls> cls;
   std::unique_ptr<RGWSI_ConfigKey_RADOS> config_key_rados;
-  std::unique_ptr<RGWSI_DataLog_RADOS> datalog_rados;
   std::unique_ptr<RGWSI_MDLog> mdlog;
   std::unique_ptr<RGWSI_Meta> meta;
   std::unique_ptr<RGWSI_MetaBackend_SObj> meta_be_sobj;
@@ -102,6 +101,7 @@ struct RGWServices_Def
   std::unique_ptr<RGWSI_SysObj_Core> sysobj_core;
   std::unique_ptr<RGWSI_SysObj_Cache> sysobj_cache;
   std::unique_ptr<RGWSI_User_RADOS> user_rados;
+  std::unique_ptr<RGWDataChangesLog> datalog_rados;
 
   RGWServices_Def();
   ~RGWServices_Def();
@@ -128,7 +128,7 @@ struct RGWServices
   RGWSI_Cls *cls{nullptr};
   RGWSI_ConfigKey_RADOS *config_key_rados{nullptr};
   RGWSI_ConfigKey *config_key{nullptr};
-  RGWSI_DataLog_RADOS *datalog_rados{nullptr};
+  RGWDataChangesLog *datalog_rados{nullptr};
   RGWSI_MDLog *mdlog{nullptr};
   RGWSI_Meta *meta{nullptr};
   RGWSI_MetaBackend *meta_be_sobj{nullptr};
index a4c16169ae4bd253e3027b18391947d7f1ddeb95..f5ab685e8147a059a93634df27699d5262a49968 100644 (file)
@@ -12,7 +12,6 @@
 #include "rgw_bucket.h"
 
 #include "services/svc_zone.h"
-#include "services/svc_datalog_rados.h"
 
 #include <boost/asio/yield.hpp>
 
index b5f324729160a8ed21c27ebfc376cbdd42540682..6a154f7a4d1b9ee07116da1f28f3b15c1aff8945 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "svc_bi_rados.h"
 #include "svc_bilog_rados.h"
-#include "svc_datalog_rados.h"
 #include "svc_zone.h"
 
+#include "rgw/rgw_bucket.h"
 #include "rgw/rgw_zone.h"
 
 #include "cls/rgw/cls_rgw_client.h"
@@ -21,7 +21,7 @@ RGWSI_BucketIndex_RADOS::RGWSI_BucketIndex_RADOS(CephContext *cct) : RGWSI_Bucke
 void RGWSI_BucketIndex_RADOS::init(RGWSI_Zone *zone_svc,
                                    RGWSI_RADOS *rados_svc,
                                    RGWSI_BILog_RADOS *bilog_svc,
-                                   RGWSI_DataLog_RADOS *datalog_rados_svc)
+                                   RGWDataChangesLog *datalog_rados_svc)
 {
   svc.zone = zone_svc;
   svc.rados = rados_svc;
index 09ec645aa969c01c2c5f4c16eeb385627ab58721..932affc74e7ed85db947c3df808838fe9d05c6b5 100644 (file)
@@ -1,4 +1,3 @@
-
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab ft=cpp
 
@@ -26,7 +25,7 @@
 struct rgw_bucket_dir_header;
 
 class RGWSI_BILog_RADOS;
-class RGWSI_DataLog_RADOS;
+class RGWDataChangesLog;
 
 #define RGW_NO_SHARD -1
 
@@ -68,7 +67,7 @@ public:
     RGWSI_Zone *zone{nullptr};
     RGWSI_RADOS *rados{nullptr};
     RGWSI_BILog_RADOS *bilog{nullptr};
-    RGWSI_DataLog_RADOS *datalog_rados{nullptr};
+    RGWDataChangesLog *datalog_rados{nullptr};
   } svc;
 
   RGWSI_BucketIndex_RADOS(CephContext *cct);
@@ -76,7 +75,7 @@ public:
   void init(RGWSI_Zone *zone_svc,
             RGWSI_RADOS *rados_svc,
             RGWSI_BILog_RADOS *bilog_svc,
-            RGWSI_DataLog_RADOS *datalog_rados_svc);
+            RGWDataChangesLog *datalog_rados_svc);
 
   static int shards_max() {
     return RGW_SHARDS_PRIME_1;