]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Remove `RGWSI_RADOS` from `RGWSI_SysObj*`
authorAdam C. Emerson <aemerson@redhat.com>
Mon, 5 Dec 2022 22:10:51 +0000 (17:10 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 29 Nov 2023 18:15:27 +0000 (13:15 -0500)
Simply use the RADOS handle and `rgw_rados_ref` directly.

Also make `rgw::AccessListFilter` a std::function.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
22 files changed:
src/rgw/driver/dbstore/common/dbstore.h
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_sal_rados.cc
src/rgw/driver/rados/rgw_service.cc
src/rgw/driver/rados/rgw_tools.cc
src/rgw/driver/rados/rgw_tools.h
src/rgw/rgw_lc.cc
src/rgw/rgw_multipart_meta_filter.cc
src/rgw/rgw_op.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_fwd.h
src/rgw/services/svc_rados.cc
src/rgw/services/svc_rados.h
src/rgw/services/svc_sys_obj.h
src/rgw/services/svc_sys_obj_cache.cc
src/rgw/services/svc_sys_obj_cache.h
src/rgw/services/svc_sys_obj_core.cc
src/rgw/services/svc_sys_obj_core.h
src/rgw/services/svc_sys_obj_core_types.h
src/rgw/services/svc_tier_rados.cc
src/rgw/services/svc_tier_rados.h

index fc436d55df800a94cfbe04d97c7026e084728bb2..8cf6f70f751568e52f49f8dace89e01025e44a1e 100644 (file)
@@ -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)
                {}
index 5fd174c3aff039c45b3368a87a38b817f629fcc5..66d6b12338d148b6fa0708138beee3315293e35a 100644 (file)
@@ -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<rgw_bucket_dir_entry>& 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<rgw_bucket_dir_entry>& 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<rgw_bucket_dir_entry> 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;
   }
 
index 97528735417dc0a5f4ad5096bd77834043c4c326..f5d9b68b259e0642d054cf2c44128aa33379bc8c 100644 (file)
@@ -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<rgw_bucket_dir_entry>& objs,
-                   bool *is_truncated, RGWAccessListFilter *filter);
+                   bool *is_truncated, const rgw::AccessListFilter& filter);
 
   uint64_t next_bucket_id();
 
index 327980f4de6ec1c52f0b0b14f3ba17ad19c596dd..0d7359ea90a7ae61c211eee92dda40649cda94d4 100644 (file)
@@ -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);
 
index dfde5c85eab5a678fd041fcec42579882df45b72..12e9cd82aec5a9f1e1da02dcd41f7e738c1e2c8f 100644 (file)
@@ -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());
index 090c80aa1f717628585205aecd4199a68c652819..aa387cb450d56bb5502bb575d57feb3922f8bf50 100644 (file)
@@ -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<string> *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();
+}
index a7639acbb24c6a92e9b8fa2a1a9dcf74506c5926..27a8b424ecce16917846726144c3644bf2e84f73 100644 (file)
@@ -3,7 +3,9 @@
 
 #pragma once
 
+#include <functional>
 #include <string>
+#include <string_view>
 
 #include "include/types.h"
 #include "include/ceph_hash.h"
@@ -333,3 +335,11 @@ std::map<std::string, ceph::buffer::list>* 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<std::string> *oids,
+                 bool *is_truncated);
index 79b81270457d4160941829c3b2fbc773e2a703ba..260ad1795bc02cc5432fae6341d9896a14e13fdc 100644 (file)
@@ -814,7 +814,6 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
                                       const multimap<string, lc_op>& 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) {
index c616cd480f75dc36581deb2ac05d94959c8fd733..aeefc731f73419b90d40f8a4debb6645c9cb14f6 100644 (file)
@@ -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);
index 7363db728a4964ae5348f1769277603ebb652c81..a290388efe0c74a43ffdfd7993d0804d075ae364 100644 (file)
@@ -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";
index 888c5ec20ed168610049a2e30c1da42b9e5a4213..8771b74c87aa1408f82f0f93239aeae3b4c09bb2 100644 (file)
@@ -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};
index ee7c100080b52f8c17451f996dfe6b782f44082c..123d17a5162a09f2d5de39e17c6be77d0f9a6b9d 100644 (file)
 
 #pragma once
 
+#include <functional>
+#include <string>
 
-namespace rgw { namespace sal {
+namespace rgw {
+using AccessListFilter =
+  std::function<bool(const std::string&, std::string&)>;
+
+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;
index 34de9857e19a842ec2ac4b44f14153ff0be35aa6..c4585336868042df50946c45fba6b971bfdd0155 100644 (file)
@@ -71,7 +71,7 @@ int RGWSI_RADOS::pool_iterate(const DoutPrefixProvider *dpp,
                               librados::IoCtx& io_ctx,
                               librados::NObjectIterator& iter,
                               uint32_t num, vector<rgw_bucket_dir_entry>& 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,
index 2a3940a34d9603215be44f464ebbc0f61a3520b0..bed6522e2ae20bcd9a2272349508e748fa2fc401 100644 (file)
@@ -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<rgw_bucket_dir_entry>& 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<std::string> *oids,
                    bool *is_truncated);
index 292340dcbe32b95dc6840a339f906b9bd641c21d..3739d68d150ee52badd038ba952b85923c4876fc 100644 (file)
@@ -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;
   }
 
index d1b7a3dbb3e730d2d6542c1592e77bc7f3dd2bf7..cd4e2c405abf67422f25ddb90f1817f7fd39715b 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
 
index f7950843fa928a247e634e3d461a8a0252c86ad3..8e2f5845dc12f4a550c7137253160c08594fab2a 100644 (file)
@@ -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,
index 30308969131d9231dd19164e66ae08037b7161a8..68878cdcceb2bcef6454503208eecff320171a8b 100644 (file)
 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<string, bufferlist> *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<string, bufferlist> 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<std::string, bufferlist>& 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<string> 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<PoolListImplInfo&>(*_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<PoolListImplInfo&>(*_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<PoolListImplInfo&>(*_ctx.impl);
-  return ctx.op.get_marker(marker);
+  *marker = ctx.marker;
+  return 0;
 }
index d02a37eee8af9f8f45444768826dbd6cbfe7e546..1b34d7078317d4bb6387e3fc7ad4db144f5f0567 100644 (file)
@@ -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,
index 74f489d914e5c74f7d3e2263024563b1a4ff9f6d..7bec012f5c299c34237ec41b547a0459329f7bc3 100644 (file)
@@ -4,6 +4,7 @@
 #pragma once
 
 
+#include "rgw_tools.h"
 #include "rgw_service.h"
 
 #include "svc_rados.h"
 
 
 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)) {}
 };
index ca87e8aceb90818f07a597c7cbaea4508bce3e14..86ccb5eca56eca1d94469813b96cb43985a5e494 100644 (file)
@@ -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;
 }
-
-
index a2036b93347349ccb93e6ab7849579356e5088f9..f7424b41038736bebc81474b84ae675c247230fa 100644 (file)
@@ -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
 {