From: Adam C. Emerson Date: Sat, 21 Nov 2020 22:05:04 +0000 (-0500) Subject: rgw/datalog: Pass IoCtx in, don't have each backend make its own X-Git-Tag: v16.2.2~8^2~9^2~21 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=57a76a06c75f60a8bb6d570c599eb40e15f93df2;p=ceph.git rgw/datalog: Pass IoCtx in, don't have each backend make its own Also don't use svc_cls. Signed-off-by: Adam C. Emerson (cherry picked from commit 7f097cf8db433bb4c82a9bafc44e43b84f79bca4) Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/rgw_datalog.cc b/src/rgw/rgw_datalog.cc index d6a9d210d1b56..92ad1869d3f48 100644 --- a/src/rgw/rgw_datalog.cc +++ b/src/rgw/rgw_datalog.cc @@ -11,6 +11,7 @@ #include "common/async/librados_completion.h" #include "cls/fifo/cls_fifo_types.h" +#include "cls/log/cls_log_client.h" #include "cls_fifo_legacy.h" #include "rgw_datalog.h" @@ -21,6 +22,7 @@ static constexpr auto dout_subsys = ceph_subsys_rgw; namespace bs = boost::system; +namespace lr = librados; void rgw_data_change::dump(ceph::Formatter *f) const { @@ -70,12 +72,10 @@ void rgw_data_change_log_entry::decode_json(JSONObj *obj) { class RGWDataChangesOmap final : public RGWDataChangesBE { using centries = std::list; - RGWSI_Cls& cls; std::vector oids; public: - RGWDataChangesOmap(CephContext* cct, RGWSI_Cls& cls) - : RGWDataChangesBE(cct), cls(cls) { - auto num_shards = cct->_conf->rgw_data_log_num_shards; + RGWDataChangesOmap(lr::IoCtx& ioctx, int num_shards) + : RGWDataChangesBE(ioctx) { oids.reserve(num_shards); for (auto i = 0; i < num_shards; ++i) { oids.push_back(get_oid(i)); @@ -90,12 +90,13 @@ public: } cls_log_entry e; - cls.timelog.prepare_entry(e, ut, {}, key, entry); + cls_log_add_prepare_entry(e, utime_t(ut), {}, key, entry); std::get(out).push_back(std::move(e)); } int push(int index, entries&& items) override { - auto r = cls.timelog.add(oids[index], std::get(items), - nullptr, true, null_yield); + lr::ObjectWriteOperation op; + cls_log_add(op, std::get(items), true); + auto r = rgw_rados_operate(ioctx, oids[index], &op, null_yield); if (r < 0) { lderr(cct) << __PRETTY_FUNCTION__ << ": failed to push to " << oids[index] << cpp_strerror(-r) @@ -106,7 +107,9 @@ public: int push(int index, ceph::real_time now, const std::string& key, ceph::buffer::list&& bl) override { - auto r = cls.timelog.add(oids[index], now, {}, key, bl, null_yield); + lr::ObjectWriteOperation op; + cls_log_add(op, utime_t(now), {}, key, bl); + auto r = rgw_rados_operate(ioctx, oids[index], &op, null_yield); if (r < 0) { lderr(cct) << __PRETTY_FUNCTION__ << ": failed to push to " << oids[index] @@ -119,10 +122,10 @@ public: std::optional marker, std::string* out_marker, bool* truncated) override { std::list log_entries; - auto r = cls.timelog.list(oids[index], {}, {}, - max_entries, log_entries, - std::string(marker.value_or("")), - out_marker, truncated, null_yield); + lr::ObjectReadOperation op; + cls_log_list(op, {}, {}, std::string(marker.value_or("")), + max_entries, log_entries, out_marker, truncated); + auto r = rgw_rados_operate(ioctx, oids[index], &op, nullptr, null_yield); if (r == -ENOENT) { *truncated = false; return 0; @@ -153,7 +156,9 @@ public: } int get_info(int index, RGWDataChangesLogInfo *info) override { cls_log_header header; - auto r = cls.timelog.info(oids[index], &header, null_yield); + lr::ObjectReadOperation op; + cls_log_info(op, &header); + auto r = rgw_rados_operate(ioctx, oids[index], &op, nullptr, null_yield); if (r == -ENOENT) r = 0; if (r < 0) { lderr(cct) << __PRETTY_FUNCTION__ @@ -166,10 +171,9 @@ public: return r; } int trim(int index, std::string_view marker) override { - auto r = cls.timelog.trim(oids[index], {}, {}, - {}, std::string(marker), nullptr, - null_yield); - + lr::ObjectWriteOperation op; + cls_log_trim(op, {}, {}, {}, std::string(marker)); + auto r = rgw_rados_operate(ioctx, oids[index], &op, null_yield); if (r == -ENOENT) r = 0; if (r < 0) { lderr(cct) << __PRETTY_FUNCTION__ @@ -179,10 +183,10 @@ public: return r; } int trim(int index, std::string_view marker, - librados::AioCompletion* c) override { - auto r = cls.timelog.trim(oids[index], {}, {}, - {}, std::string(marker), c, null_yield); - + lr::AioCompletion* c) override { + lr::ObjectWriteOperation op; + cls_log_trim(op, {}, {}, {}, std::string(marker)); + auto r = ioctx.aio_operate(oids[index], c, &op, 0); if (r == -ENOENT) r = 0; if (r < 0) { lderr(cct) << __PRETTY_FUNCTION__ @@ -200,20 +204,12 @@ class RGWDataChangesFIFO final : public RGWDataChangesBE { using centries = std::vector; std::vector> fifos; public: - RGWDataChangesFIFO(CephContext* cct, librados::Rados* rados, - const rgw_pool& log_pool) - : RGWDataChangesBE(cct) { - librados::IoCtx ioctx; - auto shards = cct->_conf->rgw_data_log_num_shards; - auto r = rgw_init_ioctx(rados, log_pool.name, ioctx, - true, false); - if (r < 0) { - throw bs::system_error(ceph::to_error_code(r)); - } + RGWDataChangesFIFO(lr::IoCtx& ioctx, int shards) + : RGWDataChangesBE(ioctx) { fifos.resize(shards); for (auto i = 0; i < shards; ++i) { - r = rgw::cls::fifo::FIFO::create(ioctx, get_oid(i), - &fifos[i], null_yield); + auto r = rgw::cls::fifo::FIFO::create(ioctx, get_oid(i), + &fifos[i], null_yield); if (r < 0) { throw bs::system_error(ceph::to_error_code(r)); } @@ -370,7 +366,7 @@ RGWDataChangesLog::RGWDataChangesLog(CephContext* cct) int RGWDataChangesLog::start(const RGWZone* _zone, const RGWZoneParams& zoneparams, - RGWSI_Cls *cls, librados::Rados* lr) + librados::Rados* lr) { zone = _zone; ceph_assert(zone); @@ -400,10 +396,10 @@ int RGWDataChangesLog::start(const RGWZone* _zone, try { switch (*found) { case log_type::omap: - be = std::make_unique(cct, *cls); + be = std::make_unique(ioctx, num_shards); break; case log_type::fifo: - be = std::make_unique(cct, lr, log_pool); + be = std::make_unique(ioctx, num_shards); break; } } catch (bs::system_error& e) { diff --git a/src/rgw/rgw_datalog.h b/src/rgw/rgw_datalog.h index af5f4f0276a68..f6f52382f0947 100644 --- a/src/rgw/rgw_datalog.h +++ b/src/rgw/rgw_datalog.h @@ -37,8 +37,6 @@ #include "rgw_zone.h" #include "rgw_trim_bilog.h" -#include "services/svc_cls.h" - namespace bc = boost::container; enum DataLogEntityType { @@ -118,6 +116,7 @@ struct RGWDataChangesLogMarker { class RGWDataChangesBE { protected: + librados::IoCtx& ioctx; CephContext* const cct; private: std::string prefix; @@ -132,8 +131,9 @@ public: using entries = std::variant, std::vector>; - RGWDataChangesBE(CephContext* const cct) - : cct(cct), prefix(get_prefix(cct)) {} + RGWDataChangesBE(librados::IoCtx& ioctx) + : ioctx(ioctx), cct(static_cast(ioctx.cct())), + prefix(get_prefix(cct)) {} virtual ~RGWDataChangesBE() = default; static std::string get_oid(CephContext* cct, int i) { @@ -214,7 +214,7 @@ public: ~RGWDataChangesLog(); int start(const RGWZone* _zone, const RGWZoneParams& zoneparams, - RGWSI_Cls *cls_svc, librados::Rados* lr); + librados::Rados* lr); int add_entry(const RGWBucketInfo& bucket_info, int shard_id); int get_log_shard_id(rgw_bucket& bucket, int shard_id); diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 3fb4f2b0b6413..7c7d8a02675d4 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -141,7 +141,7 @@ int RGWServices_Def::init(CephContext *cct, } r = datalog_rados->start(&zone->get_zone(), - zone->get_zone_params(), cls.get(), + zone->get_zone_params(), rados->get_rados_handle()); if (r < 0) { ldout(cct, 0) << "ERROR: failed to start datalog_rados service (" << cpp_strerror(-r) << dendl;