From 91a58853a6265f19175586c4543a41109dc3a791 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 1 Nov 2023 18:15:06 -0400 Subject: [PATCH] rgw/sal: add account interfaces to Driver Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_sal_rados.cc | 66 +++++++++++++++++++++++++++ src/rgw/driver/rados/rgw_sal_rados.h | 39 ++++++++++++++++ src/rgw/rgw_sal.h | 48 +++++++++++++++++++ src/rgw/rgw_sal_dbstore.cc | 65 ++++++++++++++++++++++++++ src/rgw/rgw_sal_dbstore.h | 39 ++++++++++++++++ src/rgw/rgw_sal_filter.cc | 65 ++++++++++++++++++++++++++ src/rgw/rgw_sal_filter.h | 39 ++++++++++++++++ 7 files changed, 361 insertions(+) diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index dfc7a608642..3f652950380 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -1002,6 +1002,72 @@ int RadosStore::get_user_by_swift(const DoutPrefixProvider* dpp, const std::stri return 0; } + +int RadosStore::load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return -ENOTSUP; +} + +int RadosStore::load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return -ENOTSUP; +} + +int RadosStore::load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return -ENOTSUP; +} + +int RadosStore::store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return -ENOTSUP; +} + +int RadosStore::delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) +{ + return -ENOTSUP; +} + +int RadosStore::load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) +{ + return -ENOTSUP; +} + +int RadosStore::load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) +{ + return -ENOTSUP; +} + std::unique_ptr RadosStore::get_object(const rgw_obj_key& k) { return std::make_unique(this, k); diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 732898272ef..95297998828 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -144,6 +144,45 @@ class RadosStore : public StoreDriver { virtual int get_user_by_access_key(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y, std::unique_ptr* user) override; virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr* user) override; virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr* user) override; + + int load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) override; + int delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) override; + int load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) override; + int load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) override; + virtual std::unique_ptr get_object(const rgw_obj_key& k) override; std::unique_ptr get_bucket(const RGWBucketInfo& i) override; int load_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 10f3997f7fd..02c7b3c9048 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -268,6 +268,54 @@ class Driver { virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr* user) = 0; /** Lookup a User by swift username. Queries driver for user info. */ virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr* user) = 0; + + /** Lookup RGWAccountInfo by id */ + virtual int load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) = 0; + /** Lookup RGWAccountInfo by name */ + virtual int load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) = 0; + /** Lookup RGWAccountInfo by email address */ + virtual int load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) = 0; + /** Write or overwrite an account */ + virtual int store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) = 0; + /** Delete an account */ + virtual int delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) = 0; + + /** Load account storage stats */ + virtual int load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) = 0; + /** Load account storage stats asynchronously */ + virtual int load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) = 0; + + /** Get a basic Object. This Object is not looked up, and is incomplete, since is * does not have a bucket. This should only be used when an Object is needed before * there is a Bucket, otherwise use the get_object() in the Bucket class. */ diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index b10caec40d2..ee5f5a1f2eb 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -1541,6 +1541,71 @@ namespace rgw::sal { return -ENOTSUP; } + int DBStore::load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) + { + return -ENOTSUP; + } + + int DBStore::load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) + { + return -ENOTSUP; + } + + int DBStore::load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) + { + return -ENOTSUP; + } + + int DBStore::store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) + { + return -ENOTSUP; + } + + int DBStore::delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) + { + return -ENOTSUP; + } + + int DBStore::load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) + { + return -ENOTSUP; + } + + int DBStore::load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) + { + return -ENOTSUP; + } + std::string DBStore::get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) { return "PLACEHOLDER"; // for instance unique identifier diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index bb869a5cde4..aa971d1cdf0 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -748,6 +748,45 @@ public: virtual int get_user_by_access_key(const DoutPrefixProvider *dpp, const std::string& key, optional_yield y, std::unique_ptr* user) override; virtual int get_user_by_email(const DoutPrefixProvider *dpp, const std::string& email, optional_yield y, std::unique_ptr* user) override; virtual int get_user_by_swift(const DoutPrefixProvider *dpp, const std::string& user_str, optional_yield y, std::unique_ptr* user) override; + + int load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) override; + int delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) override; + int load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) override; + int load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) override; + virtual std::unique_ptr get_object(const rgw_obj_key& k) override; virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y); std::unique_ptr get_bucket(const RGWBucketInfo& i) override; diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index a4dc43a1373..78dfc9f28aa 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -155,6 +155,71 @@ int FilterDriver::get_user_by_swift(const DoutPrefixProvider* dpp, const std::st return 0; } +int FilterDriver::load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return next->load_account_by_id(dpp, y, id, info, attrs, objv); +} + +int FilterDriver::load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return next->load_account_by_name(dpp, y, tenant, name, info, attrs, objv); +} + +int FilterDriver::load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return next->load_account_by_email(dpp, y, email, info, attrs, objv); +} + +int FilterDriver::store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) +{ + return next->store_account(dpp, y, exclusive, info, old_info, attrs, objv); +} + +int FilterDriver::delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) +{ + return next->delete_account(dpp, y, info, objv); +} + +int FilterDriver::load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) +{ + return next->load_account_stats(dpp, y, id, stats, last_synced, last_updated); +} + +int FilterDriver::load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) +{ + return next->load_account_stats_async(dpp, id, std::move(cb)); +} + std::unique_ptr FilterDriver::get_object(const rgw_obj_key& k) { std::unique_ptr o = next->get_object(k); diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index edc8e86b940..5c4e6327245 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -156,6 +156,45 @@ public: virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr* user) override; + + int load_account_by_id(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view id, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_name(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view tenant, + std::string_view name, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int load_account_by_email(const DoutPrefixProvider* dpp, + optional_yield y, + std::string_view email, + RGWAccountInfo& info, + Attrs& attrs, + RGWObjVersionTracker& objv) override; + int store_account(const DoutPrefixProvider* dpp, + optional_yield y, bool exclusive, + const RGWAccountInfo& info, + const RGWAccountInfo* old_info, + const Attrs& attrs, + RGWObjVersionTracker& objv) override; + int delete_account(const DoutPrefixProvider* dpp, + optional_yield y, + const RGWAccountInfo& info, + RGWObjVersionTracker& objv) override; + int load_account_stats(const DoutPrefixProvider* dpp, + optional_yield y, std::string_view id, + RGWStorageStats& stats, + ceph::real_time& last_synced, + ceph::real_time& last_updated) override; + int load_account_stats_async(const DoutPrefixProvider* dpp, + std::string_view id, + boost::intrusive_ptr cb) override; + virtual std::unique_ptr get_object(const rgw_obj_key& k) override; std::unique_ptr get_bucket(const RGWBucketInfo& i) override; int load_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, -- 2.39.5