From: Adam C. Emerson Date: Mon, 5 Dec 2022 22:10:51 +0000 (-0500) Subject: rgw: Remove `RGWSI_RADOS` from `RGWSI_SysObj*` X-Git-Tag: v19.0.0~21^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=34b8e9fb2228f7c8db6c63f928e8992dafb2de1b;p=ceph.git rgw: Remove `RGWSI_RADOS` from `RGWSI_SysObj*` Simply use the RADOS handle and `rgw_rados_ref` directly. Also make `rgw::AccessListFilter` a std::function. Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/driver/dbstore/common/dbstore.h b/src/rgw/driver/dbstore/common/dbstore.h index fc436d55df800..8cf6f70f75156 100644 --- a/src/rgw/driver/dbstore/common/dbstore.h +++ b/src/rgw/driver/dbstore/common/dbstore.h @@ -1771,14 +1771,13 @@ class DB { rgw_obj_key end_marker; std::string ns; bool enforce_ns; - RGWAccessListFilter* access_list_filter; + rgw::AccessListFilter access_list_filter; RGWBucketListNameFilter force_check_filter; bool list_versions; bool allow_unordered; Params() : enforce_ns(true), - access_list_filter(nullptr), list_versions(false), allow_unordered(false) {} diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 5fd174c3aff03..66d6b12338d14 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -1929,7 +1929,7 @@ int RGWRados::Bucket::List::list_objects_ordered( } if (params.access_list_filter && - ! params.access_list_filter->filter(obj.name, index_key.name)) { + !params.access_list_filter(obj.name, index_key.name)) { ldpp_dout(dpp, 20) << __func__ << ": skipping past namespaced objects, including \"" << entry.key << "\"" << dendl; @@ -2223,7 +2223,7 @@ int RGWRados::Bucket::List::list_objects_unordered(const DoutPrefixProvider *dpp } if (params.access_list_filter && - !params.access_list_filter->filter(obj.name, index_key.name)) { + !params.access_list_filter(obj.name, index_key.name)) { ldpp_dout(dpp, 20) << __func__ << ": skipping \"" << index_key << "\" because doesn't match filter" << dendl; @@ -8824,7 +8824,7 @@ string RGWRados::pool_iterate_get_cursor(RGWPoolIterCtx& ctx) static int do_pool_iterate(const DoutPrefixProvider *dpp, CephContext* cct, RGWPoolIterCtx& ctx, uint32_t num, vector& objs, - bool *is_truncated, RGWAccessListFilter *filter) + bool *is_truncated, const rgw::AccessListFilter& filter) { librados::IoCtx& io_ctx = ctx.io_ctx; librados::NObjectIterator& iter = ctx.iter; @@ -8841,7 +8841,7 @@ static int do_pool_iterate(const DoutPrefixProvider *dpp, CephContext* cct, RGWP ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl; // fill it in with initial values; we may correct later - if (filter && !filter->filter(oid, oid)) + if (filter && !filter(oid, oid)) continue; e.key = oid; @@ -8855,7 +8855,7 @@ static int do_pool_iterate(const DoutPrefixProvider *dpp, CephContext* cct, RGWP } int RGWRados::pool_iterate(const DoutPrefixProvider *dpp, RGWPoolIterCtx& ctx, uint32_t num, vector& objs, - bool *is_truncated, RGWAccessListFilter *filter) + bool *is_truncated, const rgw::AccessListFilter& filter) { // catch exceptions from NObjectIterator::operator++() try { @@ -8892,9 +8892,9 @@ int RGWRados::list_raw_objects_next(const DoutPrefixProvider *dpp, const string& if (!ctx.initialized) { return -EINVAL; } - RGWAccessListFilterPrefix filter(prefix_filter); + auto filter = rgw::AccessListFilterPrefix(prefix_filter); vector objs; - int r = pool_iterate(dpp, ctx.iter_ctx, max, objs, is_truncated, &filter); + int r = pool_iterate(dpp, ctx.iter_ctx, max, objs, is_truncated, filter); if (r < 0) { if(r != -ENOENT) ldpp_dout(dpp, 10) << "failed to list objects pool_iterate returned r=" << r << dendl; @@ -9660,7 +9660,6 @@ int RGWRados::cls_bucket_list_unordered(const DoutPrefixProvider *dpp, ldout_bitx(bitx, dpp, 25) << "BACKTRACE: " << __func__ << ": " << ClibBackTrace(0) << dendl_bitx; ent_list.clear(); - static MultipartMetaFilter multipart_meta_filter; *is_truncated = false; librados::IoCtx index_pool; @@ -10008,9 +10007,8 @@ int RGWRados::check_disk_state(const DoutPrefixProvider *dpp, rgw_obj obj(bucket_info.bucket, list_state.key); - MultipartMetaFilter multipart_meta_filter; string temp_key; - if (multipart_meta_filter.filter(list_state.key.name, temp_key)) { + if (MultipartMetaFilter(list_state.key.name, temp_key)) { obj.in_extra_data = true; } diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index 97528735417dc..f5d9b68b259e0 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -40,6 +40,7 @@ #include "rgw_cache.h" #include "rgw_sal_fwd.h" #include "rgw_pubsub.h" +#include "rgw_tools.h" struct D3nDataCache; @@ -1023,14 +1024,13 @@ public: rgw_obj_key end_marker; std::string ns; bool enforce_ns; - RGWAccessListFilter* access_list_filter; + rgw::AccessListFilter access_list_filter; RGWBucketListNameFilter force_check_filter; bool list_versions; bool allow_unordered; Params() : enforce_ns(true), - access_list_filter(nullptr), list_versions(false), allow_unordered(false) {} @@ -1638,7 +1638,7 @@ public: */ int pool_iterate(const DoutPrefixProvider *dpp, RGWPoolIterCtx& ctx, uint32_t num, std::vector& objs, - bool *is_truncated, RGWAccessListFilter *filter); + bool *is_truncated, const rgw::AccessListFilter& filter); uint64_t next_bucket_id(); diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 327980f4de6ec..0d7359ea90a7a 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -751,13 +751,12 @@ int RadosBucket::list_multiparts(const DoutPrefixProvider *dpp, { rgw::sal::Bucket::ListParams params; rgw::sal::Bucket::ListResults results; - MultipartMetaFilter mp_filter; params.prefix = prefix; params.delim = delim; params.marker = marker; params.ns = RGW_OBJ_NS_MULTIPART; - params.access_list_filter = &mp_filter; + params.access_list_filter = MultipartMetaFilter; int ret = list(dpp, params, max_uploads, results, y); diff --git a/src/rgw/driver/rados/rgw_service.cc b/src/rgw/driver/rados/rgw_service.cc index dfde5c85eab5a..12e9cd82aec5a 100644 --- a/src/rgw/driver/rados/rgw_service.cc +++ b/src/rgw/driver/rados/rgw_service.cc @@ -113,12 +113,12 @@ int RGWServices_Def::init(CephContext *cct, zone_utils->init(radoshandle, zone.get()); quota->init(zone.get()); sync_modules->init(zone.get()); - sysobj_core->core_init(rados.get(), zone.get()); + sysobj_core->core_init(radoshandle, zone.get()); if (have_cache) { - sysobj_cache->init(rados.get(), zone.get(), notify.get()); - sysobj->init(rados.get(), sysobj_cache.get()); + sysobj_cache->init(radoshandle, zone.get(), notify.get()); + sysobj->init(radoshandle, sysobj_cache.get()); } else { - sysobj->init(rados.get(), sysobj_core.get()); + sysobj->init(radoshandle, sysobj_core.get()); } user_rados->init(radoshandle, zone.get(), sysobj.get(), sysobj_cache.get(), meta.get(), meta_be_sobj.get(), sync_modules.get()); diff --git a/src/rgw/driver/rados/rgw_tools.cc b/src/rgw/driver/rados/rgw_tools.cc index 090c80aa1f717..aa387cb450d56 100644 --- a/src/rgw/driver/rados/rgw_tools.cc +++ b/src/rgw/driver/rados/rgw_tools.cc @@ -497,3 +497,42 @@ int rgw_clog_warn(librados::Rados* h, const string& msg) bufferlist inbl; return h->mon_command(cmd, inbl, nullptr, nullptr); } + +int rgw_list_pool(const DoutPrefixProvider *dpp, + librados::IoCtx& ioctx, + uint32_t max, + const rgw::AccessListFilter& filter, + std::string& marker, + std::vector *oids, + bool *is_truncated) +{ + librados::ObjectCursor oc; + if (!oc.from_str(marker)) { + ldpp_dout(dpp, 10) << "failed to parse cursor: " << marker << dendl; + return -EINVAL; + } + + auto iter = ioctx.nobjects_begin(oc); + /// Pool_iterate + if (iter == ioctx.nobjects_end()) + return -ENOENT; + + uint32_t i; + + for (i = 0; i < max && iter != ioctx.nobjects_end(); ++i, ++iter) { + string oid = iter->get_oid(); + ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl; + + // fill it in with initial values; we may correct later + if (filter && !filter(oid, oid)) + continue; + + oids->push_back(oid); + } + + marker = iter.get_cursor().to_str(); + if (is_truncated) + *is_truncated = (iter != ioctx.nobjects_end()); + + return oids->size(); +} diff --git a/src/rgw/driver/rados/rgw_tools.h b/src/rgw/driver/rados/rgw_tools.h index a7639acbb24c6..27a8b424ecce1 100644 --- a/src/rgw/driver/rados/rgw_tools.h +++ b/src/rgw/driver/rados/rgw_tools.h @@ -3,7 +3,9 @@ #pragma once +#include #include +#include #include "include/types.h" #include "include/ceph_hash.h" @@ -333,3 +335,11 @@ std::map* no_change_attrs(); bool rgw_check_secure_mon_conn(const DoutPrefixProvider *dpp); int rgw_clog_warn(librados::Rados* h, const std::string& msg); + +int rgw_list_pool(const DoutPrefixProvider *dpp, + librados::IoCtx& ioctx, + uint32_t max, + const rgw::AccessListFilter& filter, + std::string& marker, + std::vector *oids, + bool *is_truncated); diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 79b81270457d4..260ad1795bc02 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -814,7 +814,6 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, const multimap& prefix_map, LCWorker* worker, time_t stop_at, bool once) { - MultipartMetaFilter mp_filter; int ret; rgw::sal::Bucket::ListParams params; rgw::sal::Bucket::ListResults results; @@ -825,7 +824,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, * operating on one shard at a time */ params.allow_unordered = true; params.ns = RGW_OBJ_NS_MULTIPART; - params.access_list_filter = &mp_filter; + params.access_list_filter = MultipartMetaFilter; const auto event_type = rgw::notify::ObjectExpirationAbortMPU; @@ -1108,7 +1107,7 @@ public: return is_expired; } - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { auto& o = oc.o; int r; if (o.is_delete_marker()) { @@ -1172,7 +1171,7 @@ public: pass_object_lock_check(oc.driver, oc.obj.get(), dpp); } - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { auto& o = oc.o; int r = remove_expired_obj(oc.dpp, oc, true, rgw::notify::ObjectExpirationNoncurrent); @@ -1217,7 +1216,7 @@ public: return true; } - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { auto& o = oc.o; int r = remove_expired_obj(oc.dpp, oc, true, rgw::notify::ObjectExpirationDeleteMarker); @@ -1385,7 +1384,7 @@ public: return 0; } - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { auto& o = oc.o; int r; @@ -1460,7 +1459,7 @@ protected: public: LCOpAction_CurrentTransition(const transition_action& _transition) : LCOpAction_Transition(_transition) {} - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { int r = LCOpAction_Transition::process(oc); if (r == 0) { if (perfcounter) { @@ -1485,7 +1484,7 @@ public: const transition_action& _transition) : LCOpAction_Transition(_transition) {} - int process(lc_op_ctx& oc) { + int process(lc_op_ctx& oc) override { int r = LCOpAction_Transition::process(oc); if (r == 0) { if (perfcounter) { diff --git a/src/rgw/rgw_multipart_meta_filter.cc b/src/rgw/rgw_multipart_meta_filter.cc index c616cd480f75d..aeefc731f7341 100644 --- a/src/rgw/rgw_multipart_meta_filter.cc +++ b/src/rgw/rgw_multipart_meta_filter.cc @@ -3,11 +3,9 @@ #include "svc_tier_rados.h" -using namespace std; - const std::string MP_META_SUFFIX = ".meta"; -bool MultipartMetaFilter::filter(const string& name, string& key) { +bool MultipartMetaFilter(const std::string& name, std::string& key) { // the length of the suffix so we can skip past it static const size_t MP_META_SUFFIX_LEN = MP_META_SUFFIX.length(); @@ -19,11 +17,11 @@ bool MultipartMetaFilter::filter(const string& name, string& key) { return false; size_t pos = name.find(MP_META_SUFFIX, len - MP_META_SUFFIX_LEN); - if (pos == string::npos) + if (pos == std::string::npos) return false; pos = name.rfind('.', pos - 1); - if (pos == string::npos) + if (pos == std::string::npos) return false; key = name.substr(0, pos); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 7363db728a496..a290388efe0c7 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -102,8 +102,6 @@ static string shadow_ns = RGW_OBJ_NS_SHADOW; static void forward_req_info(const DoutPrefixProvider *dpp, CephContext *cct, req_info& info, const std::string& bucket_name); -static MultipartMetaFilter mp_filter; - // this probably should belong in the rgw_iam_policy_keywords, I'll get it to it // at some point static constexpr auto S3_EXISTING_OBJTAG = "s3:ExistingObjectTag"; diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 888c5ec20ed16..8771b74c87aa1 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -31,7 +31,6 @@ struct RGWBucketEnt; class RGWRESTMgr; -class RGWAccessListFilter; class RGWLC; struct rgw_user_bucket; class RGWUsageBatch; @@ -582,7 +581,7 @@ class Bucket { rgw_obj_key end_marker; std::string ns; bool enforce_ns{true}; - RGWAccessListFilter* access_list_filter{nullptr}; + rgw::AccessListFilter access_list_filter{}; RGWBucketListNameFilter force_check_filter; bool list_versions{false}; bool allow_unordered{false}; diff --git a/src/rgw/rgw_sal_fwd.h b/src/rgw/rgw_sal_fwd.h index ee7c100080b52..123d17a5162a0 100644 --- a/src/rgw/rgw_sal_fwd.h +++ b/src/rgw/rgw_sal_fwd.h @@ -15,8 +15,21 @@ #pragma once +#include +#include -namespace rgw { namespace sal { +namespace rgw { +using AccessListFilter = + std::function; + +inline auto AccessListFilterPrefix(std::string prefix) { + return [prefix = std::move(prefix)](const std::string& name, + std::string& key) { + return (prefix.compare(key.substr(0, prefix.size())) == 0); + }; +} + +namespace sal { class Driver; class User; diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 34de9857e19a8..c458533686804 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -71,7 +71,7 @@ int RGWSI_RADOS::pool_iterate(const DoutPrefixProvider *dpp, librados::IoCtx& io_ctx, librados::NObjectIterator& iter, uint32_t num, vector& objs, - RGWAccessListFilter *filter, + const rgw::AccessListFilter& filter, bool *is_truncated) { if (iter == io_ctx.nobjects_end()) @@ -86,7 +86,7 @@ int RGWSI_RADOS::pool_iterate(const DoutPrefixProvider *dpp, ldpp_dout(dpp, 20) << "RGWRados::pool_iterate: got " << oid << dendl; // fill it in with initial values; we may correct later - if (filter && !filter->filter(oid, oid)) + if (filter && filter(oid, oid)) continue; e.key = oid; @@ -296,7 +296,7 @@ int RGWSI_RADOS::Pool::open(const DoutPrefixProvider *dpp, const OpenParams& par return rados_svc->open_pool_ctx(dpp, pool, state.ioctx, params); } -int RGWSI_RADOS::Pool::List::init(const DoutPrefixProvider *dpp, const string& marker, RGWAccessListFilter *filter) +int RGWSI_RADOS::Pool::List::init(const DoutPrefixProvider *dpp, const string& marker, rgw::AccessListFilter filter) { if (ctx.initialized) { return -EINVAL; @@ -319,9 +319,6 @@ int RGWSI_RADOS::Pool::List::init(const DoutPrefixProvider *dpp, const string& m try { ctx.iter = ctx.ioctx.nobjects_begin(oc); - ctx.filter = filter; - ctx.initialized = true; - return 0; } catch (const std::system_error& e) { r = -e.code().value(); ldpp_dout(dpp, 10) << "nobjects_begin threw " << e.what() @@ -332,6 +329,10 @@ int RGWSI_RADOS::Pool::List::init(const DoutPrefixProvider *dpp, const string& m << ", returning -5" << dendl; return -EIO; } + ctx.filter = std::move(filter); + ctx.initialized = true; + + return 0; } int RGWSI_RADOS::Pool::List::get_next(const DoutPrefixProvider *dpp, diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index 2a3940a34d960..bed6522e2ae20 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -8,22 +8,9 @@ #include "include/rados/librados.hpp" #include "common/async/yield_context.h" -class RGWAsyncRadosProcessor; - -class RGWAccessListFilter { -public: - virtual ~RGWAccessListFilter() {} - virtual bool filter(const std::string& name, std::string& key) = 0; -}; +#include "rgw_tools.h" -struct RGWAccessListFilterPrefix : public RGWAccessListFilter { - std::string prefix; - - explicit RGWAccessListFilterPrefix(const std::string& _prefix) : prefix(_prefix) {} - bool filter(const std::string& name, std::string& key) override { - return (prefix.compare(key.substr(0, prefix.size())) == 0); - } -}; +class RGWAsyncRadosProcessor; class RGWSI_RADOS : public RGWServiceInstance { @@ -55,7 +42,7 @@ private: librados::IoCtx& ioctx, librados::NObjectIterator& iter, uint32_t num, std::vector& objs, - RGWAccessListFilter *filter, + const rgw::AccessListFilter& filter, bool *is_truncated); public: @@ -118,13 +105,14 @@ public: bool initialized{false}; librados::IoCtx ioctx; librados::NObjectIterator iter; - RGWAccessListFilter *filter{nullptr}; + rgw::AccessListFilter filter; } ctx; List() {} List(Pool *_pool) : pool(_pool) {} - int init(const DoutPrefixProvider *dpp, const std::string& marker, RGWAccessListFilter *filter = nullptr); + int init(const DoutPrefixProvider *dpp, const std::string& marker, + rgw::AccessListFilter filter); int get_next(const DoutPrefixProvider *dpp, int max, std::vector *oids, bool *is_truncated); diff --git a/src/rgw/services/svc_sys_obj.h b/src/rgw/services/svc_sys_obj.h index 292340dcbe32b..3739d68d150ee 100644 --- a/src/rgw/services/svc_sys_obj.h +++ b/src/rgw/services/svc_sys_obj.h @@ -246,12 +246,12 @@ public: friend class Pool::Op; protected: - RGWSI_RADOS *rados_svc{nullptr}; + librados::Rados* rados{nullptr}; RGWSI_SysObj_Core *core_svc{nullptr}; - void init(RGWSI_RADOS *_rados_svc, + void init(librados::Rados* rados_, RGWSI_SysObj_Core *_core_svc) { - rados_svc = _rados_svc; + rados = rados_; core_svc = _core_svc; } diff --git a/src/rgw/services/svc_sys_obj_cache.cc b/src/rgw/services/svc_sys_obj_cache.cc index d1b7a3dbb3e73..cd4e2c405abf6 100644 --- a/src/rgw/services/svc_sys_obj_cache.cc +++ b/src/rgw/services/svc_sys_obj_cache.cc @@ -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 diff --git a/src/rgw/services/svc_sys_obj_cache.h b/src/rgw/services/svc_sys_obj_cache.h index f7950843fa928..8e2f5845dc12f 100644 --- a/src/rgw/services/svc_sys_obj_cache.h +++ b/src/rgw/services/svc_sys_obj_cache.h @@ -17,7 +17,7 @@ class RGWSI_SysObj_Cache_ASocketHook; class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core { friend class RGWSI_SysObj_Cache_CB; - friend class RGWServices_Def; + friend RGWServices_Def; friend class ASocketHandler; RGWSI_Notify *notify_svc{nullptr}; @@ -27,10 +27,10 @@ class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core void normalize_pool_and_obj(const rgw_pool& src_pool, const std::string& src_obj, rgw_pool& dst_pool, std::string& dst_obj); protected: - void init(RGWSI_RADOS *_rados_svc, + void init(librados::Rados* rados_, RGWSI_Zone *_zone_svc, RGWSI_Notify *_notify_svc) { - core_init(_rados_svc, _zone_svc); + core_init(rados_, _zone_svc); notify_svc = _notify_svc; } @@ -80,12 +80,12 @@ protected: real_time set_mtime, optional_yield y) override; - int write_data(const DoutPrefixProvider *dpp, + int write_data(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, const bufferlist& bl, bool exclusive, RGWObjVersionTracker *objv_tracker, - optional_yield y); + optional_yield y) override; int distribute_cache(const DoutPrefixProvider *dpp, const std::string& normal_name, const rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op, diff --git a/src/rgw/services/svc_sys_obj_core.cc b/src/rgw/services/svc_sys_obj_core.cc index 30308969131d9..68878cdcceb2b 100644 --- a/src/rgw/services/svc_sys_obj_core.cc +++ b/src/rgw/services/svc_sys_obj_core.cc @@ -12,10 +12,10 @@ using namespace std; int RGWSI_SysObj_Core_GetObjState::get_rados_obj(const DoutPrefixProvider *dpp, - RGWSI_RADOS *rados_svc, + librados::Rados* rados, RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, - RGWSI_RADOS::Obj **pobj) + rgw_rados_ref** pobj) { if (!has_rados_obj) { if (obj.oid.empty()) { @@ -23,8 +23,7 @@ int RGWSI_SysObj_Core_GetObjState::get_rados_obj(const DoutPrefixProvider *dpp, return -EINVAL; } - rados_obj = rados_svc->obj(obj); - int r = rados_obj.open(dpp); + int r = rgw_get_rados_ref(dpp, rados, obj, &rados_obj); if (r < 0) { return r; } @@ -37,15 +36,14 @@ int RGWSI_SysObj_Core_GetObjState::get_rados_obj(const DoutPrefixProvider *dpp, int RGWSI_SysObj_Core::get_rados_obj(const DoutPrefixProvider *dpp, RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, - RGWSI_RADOS::Obj *pobj) + rgw_rados_ref* pobj) { if (obj.oid.empty()) { ldpp_dout(dpp, 0) << "ERROR: obj.oid is empty" << dendl; return -EINVAL; } - *pobj = rados_svc->obj(obj); - int r = pobj->open(dpp); + int r = rgw_get_rados_ref(dpp, rados, obj, pobj); if (r < 0) { return r; } @@ -59,7 +57,7 @@ int RGWSI_SysObj_Core::raw_stat(const DoutPrefixProvider *dpp, const rgw_raw_obj RGWObjVersionTracker *objv_tracker, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { return r; @@ -172,7 +170,7 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp, } } - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -185,7 +183,7 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp, } ldpp_dout(dpp, 20) << "rados_obj.operate() r=" << r << " bl.length=" << bl->length() << dendl; - uint64_t op_ver = rados_obj.get_last_version(); + uint64_t op_ver = rados_obj.ioctx.get_last_version(); if (read_state.last_ver > 0 && read_state.last_ver != op_ver) { @@ -218,7 +216,7 @@ int RGWSI_SysObj_Core::get_attr(const DoutPrefixProvider *dpp, bufferlist *dest, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -229,7 +227,7 @@ int RGWSI_SysObj_Core::get_attr(const DoutPrefixProvider *dpp, int rval; op.getxattr(name, dest, &rval); - + r = rados_obj.operate(dpp, &op, nullptr, y); if (r < 0) return r; @@ -244,7 +242,7 @@ int RGWSI_SysObj_Core::set_attrs(const DoutPrefixProvider *dpp, RGWObjVersionTracker *objv_tracker, bool exclusive, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -301,7 +299,7 @@ int RGWSI_SysObj_Core::omap_get_vals(const DoutPrefixProvider *dpp, bool *pmore, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -341,7 +339,7 @@ int RGWSI_SysObj_Core::omap_get_all(const DoutPrefixProvider *dpp, std::map *m, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -359,7 +357,7 @@ int RGWSI_SysObj_Core::omap_get_all(const DoutPrefixProvider *dpp, std::map t; int rval; op.omap_get_vals2(start_after, count, &t, &more, &rval); - + r = rados_obj.operate(dpp, &op, nullptr, y); if (r < 0) { return r; @@ -377,7 +375,7 @@ int RGWSI_SysObj_Core::omap_set(const DoutPrefixProvider *dpp, const rgw_raw_obj bufferlist& bl, bool must_exist, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -400,7 +398,7 @@ int RGWSI_SysObj_Core::omap_set(const DoutPrefixProvider *dpp, const rgw_raw_obj const std::map& m, bool must_exist, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -418,7 +416,7 @@ int RGWSI_SysObj_Core::omap_set(const DoutPrefixProvider *dpp, const rgw_raw_obj int RGWSI_SysObj_Core::omap_del(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, const std::string& key, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -440,7 +438,7 @@ int RGWSI_SysObj_Core::notify(const DoutPrefixProvider *dpp, const rgw_raw_obj& uint64_t timeout_ms, bufferlist *pbl, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -456,7 +454,7 @@ int RGWSI_SysObj_Core::remove(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -487,7 +485,7 @@ int RGWSI_SysObj_Core::write(const DoutPrefixProvider *dpp, real_time set_mtime, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -552,7 +550,7 @@ int RGWSI_SysObj_Core::write_data(const DoutPrefixProvider *dpp, RGWObjVersionTracker *objv_tracker, optional_yield y) { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; int r = get_rados_obj(dpp, zone_svc, obj, &rados_obj); if (r < 0) { ldpp_dout(dpp, 20) << "get_rados_obj() on obj=" << obj << " returned " << r << dendl; @@ -585,21 +583,17 @@ int RGWSI_SysObj_Core::pool_list_prefixed_objs(const DoutPrefixProvider *dpp, { bool is_truncated; - auto rados_pool = rados_svc->pool(pool); - - auto op = rados_pool.op(); + librados::IoCtx rados_pool; + rgw_init_ioctx(dpp, rados, pool, rados_pool, true, false); - RGWAccessListFilterPrefix filter(prefix); - - int r = op.init(dpp, string(), &filter); - if (r < 0) { - return r; - } + auto filter{rgw::AccessListFilterPrefix(prefix)}; + std::string marker; do { vector oids; -#define MAX_OBJS_DEFAULT 1000 - int r = op.get_next(dpp, MAX_OBJS_DEFAULT, &oids, &is_truncated); + static constexpr auto MAX_OBJS_DEFAULT = 1000u; + int r = rgw_list_pool(dpp, rados_pool, MAX_OBJS_DEFAULT, filter, marker, + &oids, &is_truncated); if (r < 0) { return r; } @@ -623,12 +617,9 @@ int RGWSI_SysObj_Core::pool_list_objects_init(const DoutPrefixProvider *dpp, auto& ctx = static_cast(*_ctx->impl); - ctx.pool = rados_svc->pool(pool); - ctx.op = ctx.pool.op(); - - int r = ctx.op.init(dpp, marker, &ctx.filter); + int r = rgw_init_ioctx(dpp, rados, pool, ctx.pool, true, false); if (r < 0) { - ldpp_dout(dpp, 10) << "failed to list objects pool_iterate_begin() returned r=" << r << dendl; + ldpp_dout(dpp, 10) << "failed to create IoCtx returned r=" << r << dendl; return r; } return 0; @@ -644,7 +635,8 @@ int RGWSI_SysObj_Core::pool_list_objects_next(const DoutPrefixProvider *dpp, return -EINVAL; } auto& ctx = static_cast(*_ctx.impl); - int r = ctx.op.get_next(dpp, max, oids, is_truncated); + int r = rgw_list_pool(dpp, ctx.pool, max, ctx.filter, ctx.marker, oids, + is_truncated); if (r < 0) { if(r != -ENOENT) ldpp_dout(dpp, 10) << "failed to list objects pool_iterate returned r=" << r << dendl; @@ -662,5 +654,6 @@ int RGWSI_SysObj_Core::pool_list_objects_get_marker(RGWSI_SysObj::Pool::ListCtx& } auto& ctx = static_cast(*_ctx.impl); - return ctx.op.get_marker(marker); + *marker = ctx.marker; + return 0; } diff --git a/src/rgw/services/svc_sys_obj_core.h b/src/rgw/services/svc_sys_obj_core.h index d02a37eee8af9..1b34d7078317d 100644 --- a/src/rgw/services/svc_sys_obj_core.h +++ b/src/rgw/services/svc_sys_obj_core.h @@ -16,22 +16,22 @@ struct rgw_cache_entry_info; class RGWSI_SysObj_Core : public RGWServiceInstance { - friend class RGWServices_Def; + friend struct RGWServices_Def; friend class RGWSI_SysObj; protected: - RGWSI_RADOS *rados_svc{nullptr}; + librados::Rados* rados{nullptr}; RGWSI_Zone *zone_svc{nullptr}; using GetObjState = RGWSI_SysObj_Core_GetObjState; using PoolListImplInfo = RGWSI_SysObj_Core_PoolListImplInfo; - void core_init(RGWSI_RADOS *_rados_svc, + void core_init(librados::Rados* rados_, RGWSI_Zone *_zone_svc) { - rados_svc = _rados_svc; + rados = rados_; zone_svc = _zone_svc; } - int get_rados_obj(const DoutPrefixProvider *dpp, RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, RGWSI_RADOS::Obj *pobj); + int get_rados_obj(const DoutPrefixProvider *dpp, RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, rgw_rados_ref* pobj); virtual int raw_stat(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, diff --git a/src/rgw/services/svc_sys_obj_core_types.h b/src/rgw/services/svc_sys_obj_core_types.h index 74f489d914e5c..7bec012f5c299 100644 --- a/src/rgw/services/svc_sys_obj_core_types.h +++ b/src/rgw/services/svc_sys_obj_core_types.h @@ -4,6 +4,7 @@ #pragma once +#include "rgw_tools.h" #include "rgw_service.h" #include "svc_rados.h" @@ -12,23 +13,24 @@ struct RGWSI_SysObj_Core_GetObjState : public RGWSI_SysObj_Obj_GetObjState { - RGWSI_RADOS::Obj rados_obj; + rgw_rados_ref rados_obj; bool has_rados_obj{false}; uint64_t last_ver{0}; RGWSI_SysObj_Core_GetObjState() {} int get_rados_obj(const DoutPrefixProvider *dpp, - RGWSI_RADOS *rados_svc, + librados::Rados* rados_svc, RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, - RGWSI_RADOS::Obj **pobj); + rgw_rados_ref** pobj); }; struct RGWSI_SysObj_Core_PoolListImplInfo : public RGWSI_SysObj_Pool_ListInfo { - RGWSI_RADOS::Pool pool; - RGWSI_RADOS::Pool::List op; - RGWAccessListFilterPrefix filter; + librados::IoCtx pool; + rgw::AccessListFilter filter; + std::string marker; - RGWSI_SysObj_Core_PoolListImplInfo(const std::string& prefix) : op(pool.op()), filter(prefix) {} + RGWSI_SysObj_Core_PoolListImplInfo(const std::string& prefix) + : filter(rgw::AccessListFilterPrefix(prefix)) {} }; diff --git a/src/rgw/services/svc_tier_rados.cc b/src/rgw/services/svc_tier_rados.cc index ca87e8aceb908..86ccb5eca56ec 100644 --- a/src/rgw/services/svc_tier_rados.cc +++ b/src/rgw/services/svc_tier_rados.cc @@ -7,9 +7,7 @@ using namespace std; const std::string MP_META_SUFFIX = ".meta"; -MultipartMetaFilter::~MultipartMetaFilter() {} - -bool MultipartMetaFilter::filter(const string& name, string& key) { +bool MultipartMetaFilter(const string& name, string& key) { // the length of the suffix so we can skip past it static const size_t MP_META_SUFFIX_LEN = MP_META_SUFFIX.length(); @@ -32,5 +30,3 @@ bool MultipartMetaFilter::filter(const string& name, string& key) { return true; } - - diff --git a/src/rgw/services/svc_tier_rados.h b/src/rgw/services/svc_tier_rados.h index a2036b9334734..f7424b4103873 100644 --- a/src/rgw/services/svc_tier_rados.h +++ b/src/rgw/services/svc_tier_rados.h @@ -110,21 +110,14 @@ public: * the name provided is such. It will also extract the key used for * bucket index shard calculation from the adorned name. */ -class MultipartMetaFilter : public RGWAccessListFilter { -public: - MultipartMetaFilter() {} - - virtual ~MultipartMetaFilter() override; - - /** - * @param name [in] The object name as it appears in the bucket index. - * @param key [out] An output parameter that will contain the bucket - * index key if this entry is in the form of a multipart meta object. - * @return true if the name provided is in the form of a multipart meta - * object, false otherwise - */ - bool filter(const std::string& name, std::string& key) override; -}; +/** + * @param name [in] The object name as it appears in the bucket index. + * @param key [out] An output parameter that will contain the bucket + * index key if this entry is in the form of a multipart meta object. + * @return true if the name provided is in the form of a multipart meta + * object, false otherwise + */ +bool MultipartMetaFilter(const std::string& name, std::string& key); class RGWSI_Tier_RADOS : public RGWServiceInstance {