From: Adam C. Emerson Date: Fri, 2 Dec 2022 05:55:48 +0000 (-0500) Subject: rgw: Remove `RGWSI_RADOS` from `RGWSI_Cls` X-Git-Tag: v19.0.0~21^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=23120f7f8b3fc630b91f2cab21109695c41f519d;p=ceph.git rgw: Remove `RGWSI_RADOS` from `RGWSI_Cls` Simply use the RADOS handle and `rgw_rados_ref` directly. Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/driver/rados/rgw_service.cc b/src/rgw/driver/rados/rgw_service.cc index 8efc97b2e250..cec7cf22d985 100644 --- a/src/rgw/driver/rados/rgw_service.cc +++ b/src/rgw/driver/rados/rgw_service.cc @@ -95,7 +95,7 @@ int RGWServices_Def::init(CephContext *cct, sysobj.get(), sysobj_cache.get(), bucket_sobj.get()); - cls->init(zone.get(), rados.get()); + cls->init(zone.get(), radoshandle); config_key_rados->init(rados.get()); mdlog->init(rados.get(), zone.get(), sysobj.get(), cls.get()); meta->init(sysobj.get(), mdlog.get(), meta_bes); diff --git a/src/rgw/rgw_mdlog.h b/src/rgw/rgw_mdlog.h index 152126890b75..6c78fd384085 100644 --- a/src/rgw/rgw_mdlog.h +++ b/src/rgw/rgw_mdlog.h @@ -16,12 +16,13 @@ #pragma once +#include "include/rados/librados.hpp" + #include "common/RWLock.h" #include "rgw_metadata.h" #include "rgw_mdlog_types.h" - -#include "services/svc_rados.h" +#include "rgw_tools.h" #define META_LOG_OBJ_PREFIX "meta.log." @@ -40,7 +41,7 @@ class RGWMetadataLogInfoCompletion : public RefCountedObject { using info_callback_t = std::function; private: cls_log_header header; - RGWSI_RADOS::Obj io_obj; + rgw_rados_ref io_obj; librados::AioCompletion *completion; std::mutex mutex; //< protects callback between cancel/complete boost::optional callback; //< cleared on cancel @@ -48,7 +49,7 @@ class RGWMetadataLogInfoCompletion : public RefCountedObject { explicit RGWMetadataLogInfoCompletion(info_callback_t callback); ~RGWMetadataLogInfoCompletion() override; - RGWSI_RADOS::Obj& get_io_obj() { return io_obj; } + rgw_rados_ref& get_io_obj() { return io_obj; } cls_log_header& get_header() { return header; } librados::AioCompletion* get_completion() { return completion; } diff --git a/src/rgw/services/svc_cls.cc b/src/rgw/services/svc_cls.cc index 44788940330a..101108981c32 100644 --- a/src/rgw/services/svc_cls.cc +++ b/src/rgw/services/svc_cls.cc @@ -30,27 +30,12 @@ int RGWSI_Cls::do_start(optional_yield y, const DoutPrefixProvider *dpp) return 0; } -int RGWSI_Cls::MFA::get_mfa_obj(const DoutPrefixProvider *dpp, const rgw_user& user, std::optional *obj) -{ - string oid = get_mfa_oid(user); - rgw_raw_obj o(zone_svc->get_zone_params().otp_pool, oid); - - obj->emplace(rados_svc->obj(o)); - int r = (*obj)->open(dpp); - if (r < 0) { - ldpp_dout(dpp, 4) << "failed to open rados context for " << o << dendl; - return r; - } - - return 0; -} - int RGWSI_Cls::MFA::get_mfa_ref(const DoutPrefixProvider *dpp, const rgw_user& user, rgw_rados_ref *ref) { string oid = get_mfa_oid(user); - rgw_raw_obj o(zone_svc->get_zone_params().otp_pool, oid); + rgw_raw_obj o(cls->zone_svc->get_zone_params().otp_pool, oid); - auto r = rgw_get_rados_ref(dpp, rados_svc->get_rados_handle(), o, ref); + auto r = rgw_get_rados_ref(dpp, cls->rados, o, ref); if (r < 0) { ldpp_dout(dpp, 4) << "failed to open rados context for " << o << dendl; return r; @@ -105,8 +90,8 @@ void RGWSI_Cls::MFA::prepare_mfa_write(librados::ObjectWriteOperation *op, int RGWSI_Cls::MFA::create_mfa(const DoutPrefixProvider *dpp, const rgw_user& user, const rados::cls::otp::otp_info_t& config, RGWObjVersionTracker *objv_tracker, const ceph::real_time& mtime, optional_yield y) { - std::optional obj; - int r = get_mfa_obj(dpp, user, &obj); + rgw_rados_ref obj; + int r = get_mfa_ref(dpp, user, &obj); if (r < 0) { return r; } @@ -114,7 +99,7 @@ int RGWSI_Cls::MFA::create_mfa(const DoutPrefixProvider *dpp, const rgw_user& us librados::ObjectWriteOperation op; prepare_mfa_write(&op, objv_tracker, mtime); rados::cls::otp::OTP::create(&op, config); - r = obj->operate(dpp, &op, y); + r = obj.operate(dpp, &op, y); if (r < 0) { ldpp_dout(dpp, 20) << "OTP create, otp_id=" << config.id << " result=" << (int)r << dendl; return r; @@ -129,8 +114,8 @@ int RGWSI_Cls::MFA::remove_mfa(const DoutPrefixProvider *dpp, const ceph::real_time& mtime, optional_yield y) { - std::optional obj; - int r = get_mfa_obj(dpp, user, &obj); + rgw_rados_ref obj; + int r = get_mfa_ref(dpp, user, &obj); if (r < 0) { return r; } @@ -138,7 +123,7 @@ int RGWSI_Cls::MFA::remove_mfa(const DoutPrefixProvider *dpp, librados::ObjectWriteOperation op; prepare_mfa_write(&op, objv_tracker, mtime); rados::cls::otp::OTP::remove(&op, id); - r = obj->operate(dpp, &op, y); + r = obj.operate(dpp, &op, y); if (r < 0) { ldpp_dout(dpp, 20) << "OTP remove, otp_id=" << id << " result=" << (int)r << dendl; return r; @@ -206,11 +191,12 @@ int RGWSI_Cls::MFA::set_mfa(const DoutPrefixProvider *dpp, const string& oid, co const real_time& mtime, optional_yield y) { - rgw_raw_obj o(zone_svc->get_zone_params().otp_pool, oid); - auto obj = rados_svc->obj(o); - int r = obj.open(dpp); + rgw_rados_ref obj; + int r = rgw_get_rados_ref(dpp, cls->rados, + { cls->zone_svc->get_zone_params().otp_pool, oid }, + &obj); if (r < 0) { - ldpp_dout(dpp, 4) << "failed to open rados context for " << o << dendl; + ldpp_dout(dpp, 4) << "failed to open rados context for " << oid << dendl; return r; } librados::ObjectWriteOperation op; @@ -234,21 +220,21 @@ int RGWSI_Cls::MFA::list_mfa(const DoutPrefixProvider *dpp, const string& oid, l RGWObjVersionTracker *objv_tracker, ceph::real_time *pmtime, optional_yield y) { - rgw_raw_obj o(zone_svc->get_zone_params().otp_pool, oid); - auto obj = rados_svc->obj(o); - int r = obj.open(dpp); + rgw_rados_ref ref; + int r = rgw_get_rados_ref(dpp, cls->rados, + { cls->zone_svc->get_zone_params().otp_pool, oid }, + &ref); if (r < 0) { - ldpp_dout(dpp, 4) << "failed to open rados context for " << o << dendl; + ldpp_dout(dpp, 4) << "failed to open rados context for " << oid << dendl; return r; } - auto& ref = obj.get_ref(); librados::ObjectReadOperation op; struct timespec mtime_ts; if (pmtime) { op.stat2(nullptr, &mtime_ts, nullptr); } objv_tracker->prepare_op_for_read(&op); - r = rados::cls::otp::OTP::get_all(&op, ref.pool.ioctx(), ref.obj.oid, result); + r = rados::cls::otp::OTP::get_all(&op, ref.ioctx, ref.obj.oid, result); if (r < 0) { return r; } @@ -268,14 +254,13 @@ void RGWSI_Cls::TimeLog::prepare_entry(cls_log_entry& entry, cls_log_add_prepare_entry(entry, utime_t(ut), section, key, bl); } -int RGWSI_Cls::TimeLog::init_obj(const DoutPrefixProvider *dpp, const string& oid, RGWSI_RADOS::Obj& obj) +int RGWSI_Cls::TimeLog::init_obj(const DoutPrefixProvider *dpp, const string& oid, rgw_rados_ref& obj) { - rgw_raw_obj o(zone_svc->get_zone_params().log_pool, oid); - obj = rados_svc->obj(o); - return obj.open(dpp); - + rgw_raw_obj o(cls->zone_svc->get_zone_params().log_pool, oid); + return rgw_get_rados_ref(dpp, cls->rados, o, &obj); } -int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, + +int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, const string& oid, const real_time& ut, const string& section, @@ -283,8 +268,7 @@ int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, bufferlist& bl, optional_yield y) { - RGWSI_RADOS::Obj obj; - + rgw_rados_ref obj; int r = init_obj(dpp, oid, obj); if (r < 0) { return r; @@ -304,7 +288,7 @@ int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, bool monotonic_inc, optional_yield y) { - RGWSI_RADOS::Obj obj; + rgw_rados_ref obj; int r = init_obj(dpp, oid, obj); if (r < 0) { @@ -332,7 +316,7 @@ int RGWSI_Cls::TimeLog::list(const DoutPrefixProvider *dpp, bool *truncated, optional_yield y) { - RGWSI_RADOS::Obj obj; + rgw_rados_ref obj; int r = init_obj(dpp, oid, obj); if (r < 0) { @@ -361,7 +345,7 @@ int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp, cls_log_header *header, optional_yield y) { - RGWSI_RADOS::Obj obj; + rgw_rados_ref obj; int r = init_obj(dpp, oid, obj); if (r < 0) { @@ -382,7 +366,7 @@ int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp, } int RGWSI_Cls::TimeLog::info_async(const DoutPrefixProvider *dpp, - RGWSI_RADOS::Obj& obj, + rgw_rados_ref& obj, const string& oid, cls_log_header *header, librados::AioCompletion *completion) @@ -412,7 +396,7 @@ int RGWSI_Cls::TimeLog::trim(const DoutPrefixProvider *dpp, librados::AioCompletion *completion, optional_yield y) { - RGWSI_RADOS::Obj obj; + rgw_rados_ref obj; int r = init_obj(dpp, oid, obj); if (r < 0) { @@ -441,22 +425,23 @@ int RGWSI_Cls::Lock::lock_exclusive(const DoutPrefixProvider *dpp, string& owner_id, std::optional lock_name) { - auto p = rados_svc->pool(pool); - int r = p.open(dpp); + + librados::IoCtx p; + int r = rgw_init_ioctx(dpp, cls->rados, pool, p, true, false); if (r < 0) { return r; } uint64_t msec = std::chrono::duration_cast(duration).count(); utime_t ut(msec / 1000, msec % 1000); - + rados::cls::lock::Lock l(lock_name.value_or(log_lock_name)); l.set_duration(ut); l.set_cookie(owner_id); l.set_tag(zone_id); l.set_may_renew(true); - - return l.lock_exclusive(&p.ioctx(), oid); + + return l.lock_exclusive(&p, oid); } int RGWSI_Cls::Lock::unlock(const DoutPrefixProvider *dpp, @@ -466,16 +451,15 @@ int RGWSI_Cls::Lock::unlock(const DoutPrefixProvider *dpp, string& owner_id, std::optional lock_name) { - auto p = rados_svc->pool(pool); - int r = p.open(dpp); + librados::IoCtx p; + int r = rgw_init_ioctx(dpp, cls->rados, pool, p, true, false); if (r < 0) { return r; } - + rados::cls::lock::Lock l(lock_name.value_or(log_lock_name)); l.set_tag(zone_id); l.set_cookie(owner_id); - - return l.unlock(&p.ioctx(), oid); -} + return l.unlock(&p, oid); +} diff --git a/src/rgw/services/svc_cls.h b/src/rgw/services/svc_cls.h index 08d7cfffec6f..c5ee361fc56d 100644 --- a/src/rgw/services/svc_cls.h +++ b/src/rgw/services/svc_cls.h @@ -29,19 +29,15 @@ class RGWSI_Cls : public RGWServiceInstance { RGWSI_Zone *zone_svc{nullptr}; - RGWSI_RADOS *rados_svc{nullptr}; + librados::Rados* rados{nullptr}; class ClsSubService : public RGWServiceInstance { friend class RGWSI_Cls; - RGWSI_Cls *cls_svc{nullptr}; - RGWSI_Zone *zone_svc{nullptr}; - RGWSI_RADOS *rados_svc{nullptr}; + RGWSI_Cls *cls{nullptr}; - void init(RGWSI_Cls *_cls_svc, RGWSI_Zone *_zone_svc, RGWSI_RADOS *_rados_svc) { - cls_svc = _cls_svc; - zone_svc = _cls_svc->zone_svc; - rados_svc = _cls_svc->rados_svc; + void init(RGWSI_Cls *cls_) { + cls = cls_; } public: @@ -50,7 +46,6 @@ class RGWSI_Cls : public RGWServiceInstance public: class MFA : public ClsSubService { - int get_mfa_obj(const DoutPrefixProvider *dpp, const rgw_user& user, std::optional *obj); int get_mfa_ref(const DoutPrefixProvider *dpp, const rgw_user& user, rgw_rados_ref *ref); void prepare_mfa_write(librados::ObjectWriteOperation *op, @@ -83,7 +78,7 @@ public: } mfa; class TimeLog : public ClsSubService { - int init_obj(const DoutPrefixProvider *dpp, const std::string& oid, RGWSI_RADOS::Obj& obj); + int init_obj(const DoutPrefixProvider *dpp, const std::string& oid, rgw_rados_ref& obj); public: TimeLog(CephContext *cct): ClsSubService(cct) {} @@ -119,7 +114,7 @@ public: cls_log_header *header, optional_yield y); int info_async(const DoutPrefixProvider *dpp, - RGWSI_RADOS::Obj& obj, + rgw_rados_ref& obj, const std::string& oid, cls_log_header *header, librados::AioCompletion *completion); @@ -134,7 +129,7 @@ public: } timelog; class Lock : public ClsSubService { - int init_obj(const std::string& oid, RGWSI_RADOS::Obj& obj); + int init_obj(const std::string& oid, rgw_rados_ref& obj); public: Lock(CephContext *cct): ClsSubService(cct) {} int lock_exclusive(const DoutPrefixProvider *dpp, @@ -154,15 +149,14 @@ public: RGWSI_Cls(CephContext *cct): RGWServiceInstance(cct), mfa(cct), timelog(cct), lock(cct) {} - void init(RGWSI_Zone *_zone_svc, RGWSI_RADOS *_rados_svc) { - rados_svc = _rados_svc; + void init(RGWSI_Zone *_zone_svc, librados::Rados* rados_) { + rados = rados_; zone_svc = _zone_svc; - mfa.init(this, zone_svc, rados_svc); - timelog.init(this, zone_svc, rados_svc); - lock.init(this, zone_svc, rados_svc); + mfa.init(this); + timelog.init(this); + lock.init(this); } int do_start(optional_yield, const DoutPrefixProvider *dpp) override; }; -