From cfe546991a5f6529a23a55110a19b824f3a49655 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 29 Jun 2021 09:23:40 -0400 Subject: [PATCH] rgw:sal: expose cluster fsid in RGWStore Adds a get_cluster_id() method to RGWStore, provided librados cluster_fsid in the RADOS implementation. Signed-off-by: Matt Benjamin --- src/rgw/rgw_rados.cc | 5 +++++ src/rgw/rgw_rados.h | 2 ++ src/rgw/rgw_sal.h | 2 ++ src/rgw/rgw_sal_rados.cc | 5 +++++ src/rgw/rgw_sal_rados.h | 1 + src/rgw/services/svc_rados.cc | 7 +++++++ src/rgw/services/svc_rados.h | 1 + 7 files changed, 23 insertions(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d8eb2d05a56..9cb1b998150 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2420,6 +2420,11 @@ bool RGWRados::obj_to_raw(const rgw_placement_rule& placement_rule, const rgw_ob return get_obj_data_pool(placement_rule, obj, &raw_obj->pool); } +std::string RGWRados::get_cluster_fsid(const DoutPrefixProvider *dpp, optional_yield y) +{ + return svc.rados->cluster_fsid(); +} + int RGWRados::get_obj_head_ioctx(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx) { string oid, key; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 0d173c029ca..7ec229fee18 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -395,6 +395,8 @@ class RGWRados // This field represents the number of bucket index object shards uint32_t bucket_index_max_shards; + std::string get_cluster_fsid(const DoutPrefixProvider *dpp, optional_yield y); + int get_obj_head_ref(const DoutPrefixProvider *dpp, const rgw_placement_rule& target_placement_rule, const rgw_obj& obj, rgw_rados_ref *ref); int get_obj_head_ref(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, rgw_rados_ref *ref); int get_system_obj_ref(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, rgw_rados_ref *ref); diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 6cdacfbfbf7..9e47bb59271 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -244,6 +244,8 @@ class Store { Store() {} virtual ~Store() = default; + /** Get cluster unique identifier */ + virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) = 0; /** Get a User from a rgw_user. Does not query store for user info, so quick */ virtual std::unique_ptr get_user(const rgw_user& u) = 0; /** Lookup a User by access key. Queries store for user info. */ diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 53c37e15680..0a09a05ff9f 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -977,6 +977,11 @@ std::unique_ptr RadosStore::get_user(const rgw_user &u) return std::make_unique(this, u); } +std::string RadosStore::get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) +{ + return getRados()->get_cluster_fsid(dpp, y); +} + int RadosStore::get_user_by_access_key(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y, std::unique_ptr* user) { RGWUserInfo uinfo; diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 887e9afc466..c07315ddb33 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -374,6 +374,7 @@ class RadosStore : public Store { } virtual std::unique_ptr get_user(const rgw_user& u) override; + virtual std::string get_cluster_id(const DoutPrefixProvider* dpp, optional_yield y) override; 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; diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 217882f1919..7cba3863a50 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -52,6 +52,13 @@ librados::Rados* RGWSI_RADOS::get_rados_handle() return &rados; } +std::string RGWSI_RADOS::cluster_fsid() +{ + std::string fsid; + (void) get_rados_handle()->cluster_fsid(&fsid); + return fsid; +} + uint64_t RGWSI_RADOS::instance_id() { return get_rados_handle()->get_instance_id(); diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index 7e6e8fedc1d..2792d748bc5 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -67,6 +67,7 @@ public: void init() {} void shutdown() override; + std::string cluster_fsid(); uint64_t instance_id(); bool check_secure_mon_conn(const DoutPrefixProvider *dpp) const; -- 2.39.5