]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW Zipper - Meta list API
authorDaniel Gryniewicz <dang@redhat.com>
Wed, 20 Jan 2021 17:04:26 +0000 (12:04 -0500)
committerDaniel Gryniewicz <dang@redhat.com>
Tue, 2 Mar 2021 12:35:05 +0000 (07:35 -0500)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_orphan.cc
src/rgw/rgw_quota.cc
src/rgw/rgw_rest_metadata.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h
src/rgw/rgw_user.cc
src/rgw/rgw_user.h

index dee4ae9ce2da8cf5f2619efd6b6cfcad8c854da6..07f99f873e5122a64fb144b44644c6fee8be04e2 100644 (file)
@@ -5989,7 +5989,7 @@ int main(int argc, const char **argv)
     } else {
       /* list users in groups of max-keys, then perform user-bucket
        * limit-check on each group */
-     ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, &handle);
+     ret = store->meta_list_keys_init(metadata_key, string(), &handle);
       if (ret < 0) {
        cerr << "ERROR: buckets limit check can't get user metadata_key: "
             << cpp_strerror(-ret) << std::endl;
@@ -5997,7 +5997,7 @@ int main(int argc, const char **argv)
       }
 
       do {
-       ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, user_ids,
+       ret = store->meta_list_keys_next(handle, max, user_ids,
                                              &truncated);
        if (ret < 0 && ret != -ENOENT) {
          cerr << "ERROR: buckets limit check lists_keys_next(): "
@@ -6013,7 +6013,7 @@ int main(int argc, const char **argv)
        }
        user_ids.clear();
       } while (truncated);
-      static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+      store->meta_list_keys_complete(handle);
     }
     return -ret;
   } /* OPT::BUCKET_LIMIT_CHECK */
@@ -6112,7 +6112,7 @@ int main(int argc, const char **argv)
   if (opt_cmd == OPT::BUCKET_STATS) {
     if (bucket_name.empty() && !bucket_id.empty()) {
       rgw_bucket bucket;
-      if (!rgw_find_bucket_by_id(store->ctx(), static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr, marker, bucket_id, &bucket)) {
+      if (!rgw_find_bucket_by_id(store->ctx(), store, marker, bucket_id, &bucket)) {
         cerr << "failure: no such bucket id" << std::endl;
         return -ENOENT;
       }
@@ -7496,7 +7496,7 @@ next:
     }
     void *handle;
     int max = 1000;
-    int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
+    int ret = store->meta_list_keys_init(metadata_key, marker, &handle);
     if (ret < 0) {
       cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
       return -ret;
@@ -7514,7 +7514,7 @@ next:
     do {
       list<string> keys;
       left = (max_entries_specified ? max_entries - count : max);
-      ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, left, keys, &truncated);
+      ret = store->meta_list_keys_next(handle, left, keys, &truncated);
       if (ret < 0 && ret != -ENOENT) {
         cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
         return -ret;
@@ -7533,13 +7533,13 @@ next:
       encode_json("truncated", truncated, formatter.get());
       encode_json("count", count, formatter.get());
       if (truncated) {
-        encode_json("marker", static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->get_marker(handle), formatter.get());
+        encode_json("marker", store->meta_get_marker(handle), formatter.get());
       }
       formatter->close_section();
     }
     formatter->flush(cout);
 
-    static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+    store->meta_list_keys_complete(handle);
   }
 
   if (opt_cmd == OPT::MDLOG_LIST) {
index bde80d5f70e2139fd1ea646dabae4e2fce808db1..fe499a46d488c26a1ed99eb6d07fc2fa3deee06a 100644 (file)
@@ -500,25 +500,25 @@ int RGWBucket::init(rgw::sal::RGWStore *_store, RGWBucketAdminOpState& op_state,
   return 0;
 }
 
-bool rgw_find_bucket_by_id(CephContext *cct, RGWMetadataManager *mgr,
+bool rgw_find_bucket_by_id(CephContext *cct, rgw::sal::RGWStore* store,
                            const string& marker, const string& bucket_id, rgw_bucket* bucket_out)
 {
   void *handle = NULL;
   bool truncated = false;
   string s;
 
-  int ret = mgr->list_keys_init("bucket.instance", marker, &handle);
+  int ret = store->meta_list_keys_init("bucket.instance", marker, &handle);
   if (ret < 0) {
     cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
-    mgr->list_keys_complete(handle);
+    store->meta_list_keys_complete(handle);
     return -ret;
   }
   do {
       list<string> keys;
-      ret = mgr->list_keys_next(handle, 1000, keys, &truncated);
+      ret = store->meta_list_keys_next(handle, 1000, keys, &truncated);
       if (ret < 0) {
         cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
-        mgr->list_keys_complete(handle);
+        store->meta_list_keys_complete(handle);
         return -ret;
       }
       for (list<string>::iterator iter = keys.begin(); iter != keys.end(); ++iter) {
@@ -528,12 +528,12 @@ bool rgw_find_bucket_by_id(CephContext *cct, RGWMetadataManager *mgr,
           continue;
         }
         if (bucket_id == bucket_out->bucket_id) {
-          mgr->list_keys_complete(handle);
+          store->meta_list_keys_complete(handle);
           return true;
         }
       }
   } while (truncated);
-  mgr->list_keys_complete(handle);
+  store->meta_list_keys_complete(handle);
   return false;
 }
 
@@ -1457,11 +1457,11 @@ int RGWBucketAdminOp::info(rgw::sal::RGWStore *store,
     bool truncated = true;
 
     formatter->open_array_section("buckets");
-    ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", &handle);
+    ret = store->meta_list_keys_init("bucket", string(), &handle);
     while (ret == 0 && truncated) {
       std::list<std::string> buckets;
       constexpr int max_keys = 1000;
-      ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max_keys, buckets,
+      ret = store->meta_list_keys_next(handle, max_keys, buckets,
                                                   &truncated);
       for (auto& bucket_name : buckets) {
         if (show_stats) {
@@ -1471,7 +1471,7 @@ int RGWBucketAdminOp::info(rgw::sal::RGWStore *store,
        }
       }
     }
-    static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+    store->meta_list_keys_complete(handle);
 
     formatter->close_section();
   }
@@ -1612,7 +1612,7 @@ static int process_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpSt
   Formatter *formatter = flusher.get_formatter();
   static constexpr auto default_max_keys = 1000;
 
-  int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket.instance", marker, &handle);
+  int ret = store->meta_list_keys_init("bucket.instance", marker, &handle);
   if (ret < 0) {
     cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
     return ret;
@@ -1622,7 +1622,7 @@ static int process_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpSt
 
   formatter->open_array_section("keys");
   auto g = make_scope_guard([&store, &handle, &formatter]() {
-                              static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+                              store->meta_list_keys_complete(handle);
                               formatter->close_section(); // keys
                               formatter->flush(cout);
                             });
@@ -1630,7 +1630,7 @@ static int process_stale_instances(rgw::sal::RGWStore *store, RGWBucketAdminOpSt
   do {
     list<std::string> keys;
 
-    ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
+    ret = store->meta_list_keys_next(handle, default_max_keys, keys, &truncated);
     if (ret < 0 && ret != -ENOENT) {
       cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
       return ret;
@@ -1681,7 +1681,7 @@ int RGWBucketAdminOp::clear_stale_instances(rgw::sal::RGWStore *store,
                        int ret = purge_bucket_instance(store, binfo, dpp);
                        if (ret == 0){
                          auto md_key = "bucket.instance:" + binfo.bucket.get_key();
-                         ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->remove(md_key, null_yield, dpp);
+                         ret = store->meta_remove(dpp, md_key, null_yield);
                        }
                        formatter->open_object_section("delete_status");
                        formatter->dump_string("bucket_instance", binfo.bucket.get_key());
@@ -1748,7 +1748,7 @@ int RGWBucketAdminOp::fix_lc_shards(rgw::sal::RGWStore *store,
     process_single_lc_entry(store, formatter, user_id.tenant, bucket_name, dpp);
     formatter->flush(cout);
   } else {
-    int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", marker, &handle);
+    int ret = store->meta_list_keys_init("bucket", marker, &handle);
     if (ret < 0) {
       std::cerr << "ERROR: can't get key: " << cpp_strerror(-ret) << std::endl;
       return ret;
@@ -1757,13 +1757,13 @@ int RGWBucketAdminOp::fix_lc_shards(rgw::sal::RGWStore *store,
     {
       formatter->open_array_section("lc_fix_status");
       auto sg = make_scope_guard([&store, &handle, &formatter](){
-                                   static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+                                   store->meta_list_keys_complete(handle);
                                    formatter->close_section(); // lc_fix_status
                                    formatter->flush(cout);
                                  });
       do {
         list<std::string> keys;
-        ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, default_max_keys, keys, &truncated);
+        ret = store->meta_list_keys_next(handle, default_max_keys, keys, &truncated);
         if (ret < 0 && ret != -ENOENT) {
           std::cerr << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << std::endl;
           return ret;
index 1d5b1872cf1e82ec4369f878b73f498b8c8447b8..54d960a58bee3a2e9183bf55906b9117e8af48c9 100644 (file)
@@ -766,7 +766,7 @@ private:
 
 };
 
-bool rgw_find_bucket_by_id(CephContext *cct, RGWMetadataManager *mgr, const string& marker,
+bool rgw_find_bucket_by_id(CephContext *cct, rgw::sal::RGWStore* store, const string& marker,
                            const string& bucket_id, rgw_bucket* bucket_out);
 
 #endif
index 1e2b2bd896e302e00d5917c312de5a8ff9a7e5fe..72e04b16606f82d86ba79ec361e1e39c55196675 100644 (file)
@@ -374,7 +374,7 @@ int RGWOrphanSearch::build_buckets_instance_index()
   void *handle;
   int max = 1000;
   string section = "bucket.instance";
-  int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(section, &handle);
+  int ret = store->meta_list_keys_init(section, string(), &handle);
   if (ret < 0) {
     lderr(store->ctx()) << "ERROR: can't get key: " << cpp_strerror(-ret) << dendl;
     return ret;
@@ -391,7 +391,7 @@ int RGWOrphanSearch::build_buckets_instance_index()
 
   do {
     list<string> keys;
-    ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
+    ret = store->meta_list_keys_next(handle, max, keys, &truncated);
     if (ret < 0) {
       lderr(store->ctx()) << "ERROR: lists_keys_next(): " << cpp_strerror(-ret) << dendl;
       return ret;
@@ -416,12 +416,13 @@ int RGWOrphanSearch::build_buckets_instance_index()
 
   } while (truncated);
 
+  store->meta_list_keys_complete(handle);
+
   ret = log_oids(buckets_instance_index, instances);
   if (ret < 0) {
     lderr(store->ctx()) << __func__ << ": ERROR: log_oids() returned ret=" << ret << dendl;
     return ret;
   }
-  static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
 
   return 0;
 }
@@ -1308,7 +1309,7 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp)
   int ret;
   void* handle = nullptr;
 
-  ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init("bucket", &handle);
+  ret = store->meta_list_keys_init("bucket", string(), &handle);
   if (ret < 0) {
     lderr(store->ctx()) << "RGWRadosList::" << __func__ <<
       " ERROR: list_keys_init returned " <<
@@ -1321,8 +1322,7 @@ int RGWRadosList::run(const DoutPrefixProvider *dpp)
 
   do {
     std::list<std::string> buckets;
-    ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max_keys,
-                                                buckets, &truncated);
+    ret = store->meta_list_keys_next(handle, max_keys, buckets, &truncated);
 
     for (std::string& bucket_id : buckets) {
       ret = run(dpp, bucket_id);
index c7981a56b9d2b845cc69bcbb3c2ed2e5160a0002..8f442c93713da89d82d216a7246853d67dc125fb 100644 (file)
@@ -691,7 +691,7 @@ int RGWUserStatsCache::sync_all_users(const DoutPrefixProvider *dpp, optional_yi
   string key = "user";
   void *handle;
 
-  int ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(key, &handle);
+  int ret = store->meta_list_keys_init(key, string(), &handle);
   if (ret < 0) {
     ldout(store->ctx(), 10) << "ERROR: can't get key: ret=" << ret << dendl;
     return ret;
@@ -702,7 +702,7 @@ int RGWUserStatsCache::sync_all_users(const DoutPrefixProvider *dpp, optional_yi
 
   do {
     list<string> keys;
-    ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_next(handle, max, keys, &truncated);
+    ret = store->meta_list_keys_next(handle, max, keys, &truncated);
     if (ret < 0) {
       ldout(store->ctx(), 0) << "ERROR: lists_keys_next(): ret=" << ret << dendl;
       goto done;
@@ -724,7 +724,7 @@ int RGWUserStatsCache::sync_all_users(const DoutPrefixProvider *dpp, optional_yi
 
   ret = 0;
 done:
-  static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_complete(handle);
+  store->meta_list_keys_complete(handle);
   return ret;
 }
 
index 226e649d56dd4bcb2acf38b6796fed4ea1ae4152..38644280fca5be4797fbb4c9e686cd9b6c0210f3 100644 (file)
@@ -123,7 +123,7 @@ void RGWOp_Metadata_List::execute(optional_yield y) {
      marker = "3:bf885d8f:root::sorry_janefonda_665:head";
   */
 
-  op_ret = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr->list_keys_init(metadata_key, marker, &handle);
+  op_ret = store->meta_list_keys_init(metadata_key, marker, &handle);
   if (op_ret < 0) {
     dout(5) << "ERROR: can't get key: " << cpp_strerror(op_ret) << dendl;
     return;
@@ -138,13 +138,11 @@ void RGWOp_Metadata_List::execute(optional_yield y) {
 
   s->formatter->open_array_section("keys");
 
-  auto meta_mgr = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr;
-
   uint64_t left;
   do {
     list<string> keys;
     left = (max_entries_specified ? max_entries - count : max);
-    op_ret = meta_mgr->list_keys_next(handle, left, keys, &truncated);
+    op_ret = store->meta_list_keys_next(handle, left, keys, &truncated);
     if (op_ret < 0) {
       dout(5) << "ERROR: lists_keys_next(): " << cpp_strerror(op_ret)
              << dendl;
@@ -166,12 +164,12 @@ void RGWOp_Metadata_List::execute(optional_yield y) {
     encode_json("count", count, s->formatter);
     if (truncated) {
       string esc_marker =
-       rgw::to_base64(meta_mgr->get_marker(handle));
+       rgw::to_base64(store->meta_get_marker(handle));
       encode_json("marker", esc_marker, s->formatter);
     }
     s->formatter->close_section();
   }
-  meta_mgr->list_keys_complete(handle);
+  store->meta_list_keys_complete(handle);
 
   op_ret = 0;
 }
index a0dcfce7f06e104cdae98a58626e45d14e57704e..b069487cd99b4bb2b409b38022d834ff6ac828db 100644 (file)
@@ -217,6 +217,12 @@ class RGWStore {
                               boost::optional<obj_version> refresh_version = boost::none) = 0;
     virtual int delete_system_obj(const rgw_pool& pool, const string& oid,
                                  RGWObjVersionTracker *objv_tracker, optional_yield y) = 0;
+    virtual int meta_list_keys_init(const string& section, const string& marker, void** phandle) = 0;
+    virtual int meta_list_keys_next(void* handle, int max, list<string>& keys, bool* truncated) = 0;
+    virtual void meta_list_keys_complete(void* handle) = 0;
+    virtual std::string meta_get_marker(void *handle) = 0;
+    virtual int meta_remove(const DoutPrefixProvider *dpp, string& metadata_key, optional_yield y) = 0;
+
     virtual void finalize(void) = 0;
 
     virtual CephContext *ctx(void) = 0;
index 6f0a18a6e941c83816d126cc441ab4b571596ef9..bf33ba3a8d3f41332ac7983012af12bf50d44e7a 100644 (file)
@@ -1043,6 +1043,32 @@ int RGWRadosStore::delete_system_obj(const rgw_pool& pool, const string& oid,
 {
     return rgw_delete_system_obj(svc()->sysobj, pool, oid, objv_tracker, y);
 }
+
+int RGWRadosStore::meta_list_keys_init(const string& section, const string& marker, void** phandle)
+{
+  return ctl()->meta.mgr->list_keys_init(section, marker, phandle);
+}
+
+int RGWRadosStore::meta_list_keys_next(void* handle, int max, list<string>& keys, bool* truncated)
+{
+  return ctl()->meta.mgr->list_keys_next(handle, max, keys, truncated);
+}
+
+void RGWRadosStore::meta_list_keys_complete(void* handle)
+{
+  ctl()->meta.mgr->list_keys_complete(handle);
+}
+
+std::string RGWRadosStore::meta_get_marker(void* handle)
+{
+  return ctl()->meta.mgr->get_marker(handle);
+}
+
+int RGWRadosStore::meta_remove(const DoutPrefixProvider *dpp, string& metadata_key, optional_yield y)
+{
+  return ctl()->meta.mgr->remove(metadata_key, y, dpp);
+}
+
 void RGWRadosStore::finalize(void)
 {
   if (rados)
index ebe5eae0db20444beccfffb717e1c6325358393e..e5f25ddd8a0d3b5cd515fc19d88864d72da962b5 100644 (file)
@@ -433,6 +433,12 @@ class RGWRadosStore : public RGWStore {
                               boost::optional<obj_version> refresh_version = boost::none) override;
     virtual int delete_system_obj(const rgw_pool& pool, const string& oid,
                                  RGWObjVersionTracker *objv_tracker, optional_yield y) override;
+    virtual int meta_list_keys_init(const string& section, const string& marker, void** phandle) override;
+    virtual int meta_list_keys_next(void* handle, int max, list<string>& keys, bool* truncated) override;
+    virtual void meta_list_keys_complete(void* handle) override;
+    virtual std::string meta_get_marker(void *handle) override;
+    virtual int meta_remove(const DoutPrefixProvider *dpp, string& metadata_key, optional_yield y) override;
+
     virtual void finalize(void) override;
 
     virtual CephContext *ctx(void) override { return rados->ctx(); }
index 3051c0b2bb2342285abf409b9da42ffb6aef9541..07822c48189aa87dcc5554ebb25206549fdfeab2 100644 (file)
@@ -134,103 +134,6 @@ int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
   return 0;
 }
 
-/**
- * Save the given user information to storage.
- * Returns: 0 on success, -ERR# on failure.
- */
-int rgw_store_user_info(const DoutPrefixProvider *dpp, 
-                        RGWUserCtl *user_ctl,
-                        RGWUserInfo& info,
-                        RGWUserInfo *old_info,
-                        RGWObjVersionTracker *objv_tracker,
-                        real_time mtime,
-                        bool exclusive,
-                       optional_yield y,
-                        map<string, bufferlist> *pattrs)
-{
-  return user_ctl->store_info(dpp, info, y,
-                              RGWUserCtl::PutParams()
-                              .set_old_info(old_info)
-                              .set_objv_tracker(objv_tracker)
-                              .set_mtime(mtime)
-                              .set_exclusive(exclusive)
-                              .set_attrs(pattrs));
-}
-
-/**
- * Given a uid, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-int rgw_get_user_info_by_uid(const DoutPrefixProvider *dpp, 
-                             RGWUserCtl *user_ctl,
-                             const rgw_user& uid,
-                             RGWUserInfo& info,
-                            optional_yield y,
-                             RGWObjVersionTracker * const objv_tracker,
-                             real_time * const pmtime,
-                             rgw_cache_entry_info * const cache_info,
-                             map<string, bufferlist> * const pattrs)
-{
-  return user_ctl->get_info_by_uid(dpp, uid, &info, y,
-                                   RGWUserCtl::GetParams()
-                                   .set_objv_tracker(objv_tracker)
-                                   .set_mtime(pmtime)
-                                   .set_cache_info(cache_info)
-                                   .set_attrs(pattrs));
-}
-
-/**
- * Given an email, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-int rgw_get_user_info_by_email(const DoutPrefixProvider *dpp, 
-                               RGWUserCtl *user_ctl, string& email,
-                              RGWUserInfo& info, optional_yield y,
-                               RGWObjVersionTracker *objv_tracker,
-                              real_time *pmtime)
-{
-  return user_ctl->get_info_by_email(dpp, email, &info, y,
-                                     RGWUserCtl::GetParams()
-                                     .set_objv_tracker(objv_tracker)
-                                     .set_mtime(pmtime));
-}
-
-/**
- * Given an swift username, finds the user_info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-int rgw_get_user_info_by_swift(const DoutPrefixProvider *dpp, 
-                               RGWUserCtl *user_ctl,
-                              const string& swift_name,
-                              RGWUserInfo& info,        /* out */
-                              optional_yield y,
-                              RGWObjVersionTracker * const objv_tracker,
-                              real_time * const pmtime)
-{
-  return user_ctl->get_info_by_swift(dpp, swift_name, &info, y,
-                                     RGWUserCtl::GetParams()
-                                     .set_objv_tracker(objv_tracker)
-                                     .set_mtime(pmtime));
-}
-
-/**
- * Given an access key, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_access_key(const DoutPrefixProvider *dpp, 
-                                           RGWUserCtl *user_ctl,
-                                           const std::string& access_key,
-                                           RGWUserInfo& info,
-                                          optional_yield y,
-                                          RGWObjVersionTracker* objv_tracker,
-                                           real_time *pmtime)
-{
-  return user_ctl->get_info_by_access_key(dpp, access_key, &info, y,
-                                          RGWUserCtl::GetParams()
-                                          .set_objv_tracker(objv_tracker)
-                                          .set_mtime(pmtime));
-}
-
 static bool char_is_unreserved_url(char c)
 {
   if (isalnum(c))
@@ -462,7 +365,6 @@ RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr)
   user = usr;
 
   store = user->get_store();
-  user_ctl = user->get_user_ctl();
 }
 
 int RGWAccessKeyPool::init(RGWUserAdminOpState& op_state)
@@ -712,7 +614,7 @@ int RGWAccessKeyPool::generate_key(const DoutPrefixProvider *dpp, RGWUserAdminOp
 
   std::pair<std::string, RGWAccessKey> key_pair;
   RGWAccessKey new_key;
-  RGWUserInfo duplicate_check;
+  std::unique_ptr<rgw::sal::RGWUser> duplicate_check;
 
   int key_type = op_state.get_key_type();
   bool gen_access = op_state.will_gen_access();
@@ -735,13 +637,13 @@ int RGWAccessKeyPool::generate_key(const DoutPrefixProvider *dpp, RGWUserAdminOp
   if (!id.empty()) {
     switch (key_type) {
     case KEY_TYPE_SWIFT:
-      if (rgw_get_user_info_by_swift(dpp, user_ctl, id, duplicate_check, y) >= 0) {
+      if (store->get_user_by_swift(dpp, id, y, &duplicate_check) >= 0) {
         set_err_msg(err_msg, "existing swift key in RGW system:" + id);
         return -ERR_KEY_EXIST;
       }
       break;
     case KEY_TYPE_S3:
-      if (rgw_get_user_info_by_access_key(dpp, user_ctl, id, duplicate_check, y) >= 0) {
+      if (store->get_user_by_access_key(dpp, id, y, &duplicate_check) >= 0) {
         set_err_msg(err_msg, "existing S3 key in RGW system:" + id);
         return -ERR_KEY_EXIST;
       }
@@ -781,7 +683,7 @@ int RGWAccessKeyPool::generate_key(const DoutPrefixProvider *dpp, RGWUserAdminOp
       if (!validate_access_key(id))
         continue;
 
-    } while (!rgw_get_user_info_by_access_key(dpp, user_ctl, id, duplicate_check, y));
+    } while (!store->get_user_by_access_key(dpp, id, y, &duplicate_check));
   }
 
   if (key_type == KEY_TYPE_SWIFT) {
@@ -792,7 +694,7 @@ int RGWAccessKeyPool::generate_key(const DoutPrefixProvider *dpp, RGWUserAdminOp
     }
 
     // check that the access key doesn't exist
-    if (rgw_get_user_info_by_swift(dpp, user_ctl, id, duplicate_check, y) >= 0) {
+    if (store->get_user_by_swift(dpp, id, y, &duplicate_check) >= 0) {
       set_err_msg(err_msg, "cannot create existing swift key");
       return -ERR_KEY_EXIST;
     }
@@ -1100,7 +1002,6 @@ RGWSubUserPool::RGWSubUserPool(RGWUser *usr)
 
   subusers_allowed = true;
   store = user->get_store();
-  user_ctl = user->get_user_ctl();
 }
 
 int RGWSubUserPool::init(RGWUserAdminOpState& op_state)
@@ -1551,7 +1452,6 @@ int RGWUser::init_storage(rgw::sal::RGWStore *storage)
   }
 
   store = storage;
-  user_ctl = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->user;
 
   clear_populated();
 
@@ -1657,7 +1557,7 @@ int RGWUser::update(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state
 {
   int ret;
   std::string subprocess_msg;
-  RGWUserInfo user_info = op_state.get_user_info();
+  rgw::sal::RGWUser* user = op_state.get_user();
 
   if (!store) {
     set_err_msg(err_msg, "couldn't initialize storage");
@@ -1666,14 +1566,15 @@ int RGWUser::update(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state
 
   RGWUserInfo *pold_info = (is_populated() ? &old_info : nullptr);
 
-  ret = rgw_store_user_info(dpp, user_ctl, user_info, pold_info, &op_state.objv,
-                           real_time(), false, y);
+  ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
+                        .set_old_info(pold_info)
+                        .set_objv_tracker(&op_state.objv));
   if (ret < 0) {
     set_err_msg(err_msg, "unable to store user info");
     return ret;
   }
 
-  old_info = user_info;
+  old_info = user->get_info();
   set_populated();
 
   return 0;
@@ -1760,16 +1661,15 @@ int RGWUser::execute_rename(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
   }
 
   // create a stub user and write only the uid index and buckets object
-  RGWUserInfo stub_user_info;
-  stub_user_info.user_id = new_user->get_id();
+  std::unique_ptr<rgw::sal::RGWUser> user;
+  user = store->get_user(new_user->get_id());
 
   RGWObjVersionTracker objv;
   const bool exclusive = !op_state.get_overwrite_new_user(); // overwrite if requested
 
-  ret = user_ctl->store_info(dpp, stub_user_info, y,
-                             RGWUserCtl::PutParams()
-                             .set_objv_tracker(&objv)
-                             .set_exclusive(exclusive));
+  ret = user->store_info(dpp, y, RGWUserCtl::PutParams()
+                           .set_objv_tracker(&objv)
+                           .set_exclusive(exclusive));
   if (ret == -EEXIST) {
     set_err_msg(err_msg, "user name given by --new-uid already exists");
     return ret;
@@ -2015,8 +1915,7 @@ int RGWUser::execute_remove(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
   int ret;
 
   bool purge_data = op_state.will_purge_data();
-  std::unique_ptr<rgw::sal::RGWUser> user = store->get_user(op_state.get_user_id());
-  RGWUserInfo user_info = op_state.get_user_info();
+  rgw::sal::RGWUser* user = op_state.get_user();
 
   if (!op_state.has_existing_user()) {
     set_err_msg(err_msg, "user does not exist");
@@ -2053,8 +1952,7 @@ int RGWUser::execute_remove(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
 
   } while (buckets.is_truncated());
 
-  ret = user_ctl->remove_info(dpp, user_info, y, RGWUserCtl::RemoveParams()
-                                            .set_objv_tracker(&op_state.objv));
+  ret = user->remove_info(dpp, y, RGWUserCtl::RemoveParams().set_objv_tracker(&op_state.objv));
   if (ret < 0) {
     set_err_msg(err_msg, "unable to remove user from RADOS");
     return ret;
@@ -2095,7 +1993,7 @@ int RGWUser::execute_modify(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
   std::string display_name = op_state.get_display_name();
 
   RGWUserInfo user_info;
-  RGWUserInfo duplicate_check;
+  std::unique_ptr<rgw::sal::RGWUser> duplicate_check;
 
   // ensure that the user info has been populated or is populate-able
   if (!op_state.has_existing_user() && !populated) {
@@ -2124,8 +2022,8 @@ int RGWUser::execute_modify(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
   if (!op_email.empty()) {
     // make sure we are not adding a duplicate email
     if (old_email != op_email) {
-      ret = rgw_get_user_info_by_email(dpp, user_ctl, op_email, duplicate_check,y );
-      if (ret >= 0 && duplicate_check.user_id.compare(user_id) != 0) {
+      ret = store->get_user_by_email(dpp, op_email, y, &duplicate_check);
+      if (ret >= 0 && duplicate_check->get_id().compare(user_id) != 0) {
         set_err_msg(err_msg, "cannot add duplicate email");
         return -ERR_EMAIL_EXIST;
       }
@@ -2300,9 +2198,7 @@ int RGWUser::list(RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher)
     op_state.max_entries = 1000;
   }
 
-  auto meta_mgr = static_cast<rgw::sal::RGWRadosStore*>(store)->ctl()->meta.mgr;
-
-  int ret = meta_mgr->list_keys_init(metadata_key, op_state.marker, &handle);
+  int ret = store->meta_list_keys_init(metadata_key, op_state.marker, &handle);
   if (ret < 0) {
     return ret;
   }
@@ -2320,7 +2216,7 @@ int RGWUser::list(RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher)
   do {
     std::list<std::string> keys;
     left = op_state.max_entries - count;
-    ret = meta_mgr->list_keys_next(handle, left, keys, &truncated);
+    ret = store->meta_list_keys_next(handle, left, keys, &truncated);
     if (ret < 0 && ret != -ENOENT) {
       return ret;
     } if (ret != -ENOENT) {
@@ -2336,13 +2232,13 @@ int RGWUser::list(RGWUserAdminOpState& op_state, RGWFormatterFlusher& flusher)
   formatter->dump_bool("truncated", truncated);
   formatter->dump_int("count", count);
   if (truncated) {
-    formatter->dump_string("marker", meta_mgr->get_marker(handle));
+    formatter->dump_string("marker", store->meta_get_marker(handle));
   }
 
   // close result object section
   formatter->close_section();
 
-  meta_mgr->list_keys_complete(handle);
+  store->meta_list_keys_complete(handle);
 
   flusher.flush();
   return 0;
index a6e374775907bbcc103406865d3b702344e2cebe..c6a16fcd2dbb863de4b68e8f3d614482f778cf9b 100644 (file)
@@ -67,66 +67,6 @@ extern int rgw_user_get_all_buckets_stats(const DoutPrefixProvider *dpp,
  */
 extern void rgw_get_anon_user(RGWUserInfo& info);
 
-/**
- * Save the given user information to storage.
- * Returns: 0 on success, -ERR# on failure.
- */
-extern int rgw_store_user_info(const DoutPrefixProvider *dpp, 
-                               RGWUserCtl *user_ctl,
-                               RGWUserInfo& info,
-                               RGWUserInfo *old_info,
-                               RGWObjVersionTracker *objv_tracker,
-                               real_time mtime,
-                               bool exclusive,
-                              optional_yield y,
-                               map<string, bufferlist> *pattrs = nullptr);
-
-/**
- * Given an user_id, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_uid(const DoutPrefixProvider *dpp, 
-                                    RGWUserCtl *user_ctl,
-                                    const rgw_user& user_id,
-                                    RGWUserInfo& info,
-                                   optional_yield y,
-                                    RGWObjVersionTracker *objv_tracker = nullptr,
-                                    real_time *pmtime                  = nullptr,
-                                    rgw_cache_entry_info *cache_info   = nullptr,
-                                    map<string, bufferlist> *pattrs    = nullptr);
-/**
- * Given an email, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_email(const DoutPrefixProvider *dpp, 
-                                      RGWUserCtl *user_ctl,
-                                      string& email, RGWUserInfo& info,
-                                     optional_yield y,
-                                      RGWObjVersionTracker *objv_tracker = NULL,
-                                      real_time *pmtime = nullptr);
-/**
- * Given an swift username, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_swift(const DoutPrefixProvider *dpp, 
-                                      RGWUserCtl *user_ctl,
-                                      const string& swift_name,
-                                      RGWUserInfo& info,        /* out */
-                                     optional_yield y,
-                                      RGWObjVersionTracker *objv_tracker = nullptr,
-                                      real_time *pmtime = nullptr);
-/**
- * Given an access key, finds the user info associated with it.
- * returns: 0 on success, -ERR# on failure (including nonexistence)
- */
-extern int rgw_get_user_info_by_access_key(const DoutPrefixProvider *dpp, 
-                                           RGWUserCtl *user_ctl,
-                                           const std::string& access_key,
-                                           RGWUserInfo& info,
-                                          optional_yield y,
-                                          RGWObjVersionTracker* objv_tracker = nullptr,
-                                           real_time* pmtime = nullptr);
-
 extern void rgw_perm_to_str(uint32_t mask, char *buf, int len);
 extern uint32_t rgw_str_to_perm(const char *str);
 
@@ -439,6 +379,7 @@ struct RGWUserAdminOpState {
   RGWQuotaInfo& get_user_quota() { return user_quota; }
   set<string>& get_mfa_ids() { return mfa_ids; }
 
+  rgw::sal::RGWUser* get_user() { return user.get(); }
   const rgw_user& get_user_id();
   std::string get_subuser() { return subuser; }
   std::string get_access_key() { return id; }
@@ -474,7 +415,6 @@ class RGWAccessKeyPool
   std::map<std::string, int, ltstr_nocase> key_type_map;
   rgw_user user_id;
   rgw::sal::RGWStore *store{nullptr};
-  RGWUserCtl *user_ctl{nullptr};
 
   map<std::string, RGWAccessKey> *swift_keys{nullptr};
   map<std::string, RGWAccessKey> *access_keys{nullptr};
@@ -528,7 +468,6 @@ class RGWSubUserPool
 
   rgw_user user_id;
   rgw::sal::RGWStore *store{nullptr};
-  RGWUserCtl *user_ctl{nullptr};
   bool subusers_allowed{false};
 
   map<string, RGWSubUser> *subuser_map{nullptr};
@@ -591,7 +530,6 @@ class RGWUser
 private:
   RGWUserInfo old_info;
   rgw::sal::RGWStore *store{nullptr};
-  RGWUserCtl *user_ctl{nullptr};
 
   rgw_user user_id;
   bool info_stored{false};
@@ -625,7 +563,6 @@ public:
   int init_members(RGWUserAdminOpState& op_state);
 
   rgw::sal::RGWStore *get_store() { return store; }
-  RGWUserCtl *get_user_ctl() { return user_ctl; }
 
   /* API Contracted Members */
   RGWUserCapPool caps;