]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:sal: expose cluster fsid in RGWStore
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 29 Jun 2021 13:23:40 +0000 (09:23 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 9 Dec 2021 15:47:36 +0000 (10:47 -0500)
Adds a get_cluster_id() method to RGWStore, provided librados
cluster_fsid in the RADOS implementation.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sal.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h
src/rgw/services/svc_rados.cc
src/rgw/services/svc_rados.h

index d8eb2d05a565567fae22bdc2a342fd9d8fe8845b..9cb1b9981506e88c9426defe9d0ca4d015a48b6d 100644 (file)
@@ -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;
index 0d173c029ca6dc449c392c5d1036d49f8606ad91..7ec229fee18d91afa77e07c08f31a1b5be4b8ae4 100644 (file)
@@ -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);
index 6cdacfbfbf7485053ba3d2d4a037499091e5df8f..9e47bb592712751c181aad24d20ce326064d8a19 100644 (file)
@@ -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<User> get_user(const rgw_user& u) = 0;
     /** Lookup a User by access key.  Queries store for user info. */
index 53c37e15680f4f9b45da5f6e70b241bf6594dd7f..0a09a05ff9f8198d905d8ddf7230fbb075ba9e94 100644 (file)
@@ -977,6 +977,11 @@ std::unique_ptr<User> RadosStore::get_user(const rgw_user &u)
   return std::make_unique<RadosUser>(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>* user)
 {
   RGWUserInfo uinfo;
index 887e9afc466da5e98cb6ab0e9404c28b8b00794b..c07315ddb3364eea32dc1cfc9283cf497418e46f 100644 (file)
@@ -374,6 +374,7 @@ class RadosStore : public Store {
     }
 
     virtual std::unique_ptr<User> 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>* user) override;
     virtual int get_user_by_email(const DoutPrefixProvider* dpp, const std::string& email, optional_yield y, std::unique_ptr<User>* user) override;
     virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const std::string& user_str, optional_yield y, std::unique_ptr<User>* user) override;
index 217882f1919e20c61a63a4ce8a5007e51ca73946..7cba3863a50944c58762255c605bf1a541998648 100644 (file)
@@ -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();
index 7e6e8fedc1dcd32a62977050a18caff59e5342c7..2792d748bc5b6c8e894c0fef180459e78bae46c1 100644 (file)
@@ -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;