From: Daniel Gryniewicz Date: Wed, 20 Jan 2021 17:04:26 +0000 (-0500) Subject: RGW Zipper - Meta list API X-Git-Tag: v17.1.0~2768^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26670586c0043de0580bb1197048d46438a5e3c6;p=ceph.git RGW Zipper - Meta list API Signed-off-by: Daniel Gryniewicz --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index dee4ae9ce2da..07f99f873e51 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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(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(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(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(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(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 keys; left = (max_entries_specified ? max_entries - count : max); - ret = static_cast(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(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(store)->ctl()->meta.mgr->list_keys_complete(handle); + store->meta_list_keys_complete(handle); } if (opt_cmd == OPT::MDLOG_LIST) { diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index bde80d5f70e2..fe499a46d488 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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 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::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(store)->ctl()->meta.mgr->list_keys_init("bucket", &handle); + ret = store->meta_list_keys_init("bucket", string(), &handle); while (ret == 0 && truncated) { std::list buckets; constexpr int max_keys = 1000; - ret = static_cast(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(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(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(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 keys; - ret = static_cast(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(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(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(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 keys; - ret = static_cast(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; diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 1d5b1872cf1e..54d960a58bee 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -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 diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index 1e2b2bd896e3..72e04b16606f 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -374,7 +374,7 @@ int RGWOrphanSearch::build_buckets_instance_index() void *handle; int max = 1000; string section = "bucket.instance"; - int ret = static_cast(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 keys; - ret = static_cast(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(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(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 buckets; - ret = static_cast(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); diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index c7981a56b9d2..8f442c93713d 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -691,7 +691,7 @@ int RGWUserStatsCache::sync_all_users(const DoutPrefixProvider *dpp, optional_yi string key = "user"; void *handle; - int ret = static_cast(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 keys; - ret = static_cast(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(store)->ctl()->meta.mgr->list_keys_complete(handle); + store->meta_list_keys_complete(handle); return ret; } diff --git a/src/rgw/rgw_rest_metadata.cc b/src/rgw/rgw_rest_metadata.cc index 226e649d56dd..38644280fca5 100644 --- a/src/rgw/rgw_rest_metadata.cc +++ b/src/rgw/rgw_rest_metadata.cc @@ -123,7 +123,7 @@ void RGWOp_Metadata_List::execute(optional_yield y) { marker = "3:bf885d8f:root::sorry_janefonda_665:head"; */ - op_ret = static_cast(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(store)->ctl()->meta.mgr; - uint64_t left; do { list 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; } diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index a0dcfce7f06e..b069487cd99b 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -217,6 +217,12 @@ class RGWStore { boost::optional 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& 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; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 6f0a18a6e941..bf33ba3a8d3f 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -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& 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) diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index ebe5eae0db20..e5f25ddd8a0d 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -433,6 +433,12 @@ class RGWRadosStore : public RGWStore { boost::optional 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& 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(); } diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 3051c0b2bb23..07822c48189a 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -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 *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 * 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 key_pair; RGWAccessKey new_key; - RGWUserInfo duplicate_check; + std::unique_ptr 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(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 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 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 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(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 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; diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index a6e374775907..c6a16fcd2dbb 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -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 *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 *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& 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 key_type_map; rgw_user user_id; rgw::sal::RGWStore *store{nullptr}; - RGWUserCtl *user_ctl{nullptr}; map *swift_keys{nullptr}; map *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 *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;