From: Matt Benjamin Date: Tue, 29 Jun 2021 13:23:40 +0000 (-0400) Subject: rgw:sal: expose cluster fsid in RGWStore X-Git-Tag: v17.1.0~264^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cfe546991a5f6529a23a55110a19b824f3a49655;p=ceph.git 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 --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d8eb2d05a565..9cb1b9981506 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 0d173c029ca6..7ec229fee18d 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 6cdacfbfbf74..9e47bb592712 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 53c37e15680f..0a09a05ff9f8 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 887e9afc466d..c07315ddb336 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 217882f1919e..7cba3863a509 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 7e6e8fedc1dc..2792d748bc5b 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;