]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Zipper add attr merge for User
authorDaniel Gryniewicz <dang@redhat.com>
Tue, 31 Aug 2021 15:59:45 +0000 (11:59 -0400)
committerOr Friedmann <ofriedma@redhat.com>
Wed, 5 Jan 2022 15:22:07 +0000 (15:22 +0000)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_sal.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index f138dea6a3137a174b5517c21fc407d717eed1f5..c815032164f11f2573407d8b5abc2a74f06a4dd9 100644 (file)
@@ -484,7 +484,14 @@ class User {
     static bool empty(std::unique_ptr<User>& u) { return (!u || u->info.user_id.id.empty()); }
     /** Read the User attributes from the backing Store */
     virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) = 0;
-    /** Read the User stats from the backing Store, synchronous */
+    /** Set the attributes in attrs, leaving any other existing attrs set, and
+     * write them to the backing store; a merge operation */
+    virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) {
+      for(auto& it : new_attrs) {
+       attrs[it.first] = it.second;
+      }
+      return 0;
+    }
     virtual int read_stats(const DoutPrefixProvider *dpp,
                            optional_yield y, RGWStorageStats* stats,
                           ceph::real_time* last_stats_sync = nullptr,
@@ -500,10 +507,8 @@ class User {
                           std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) = 0;
     /** Trim User usage stats to the given epoch range */
     virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) = 0;
-
-    /** Load this User from the backing store.  requires ID to be set, fills all other fields. */
-    virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
-    /** Store this User to the backing store */
+    virtual RGWObjVersionTracker& get_version_tracker() { return objv_tracker; }
+    virtual Attrs& get_attrs() { return attrs; }
     virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) = 0;
     /** Remove this User from the backing store */
     virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) = 0;
index 85cf83b8f05be9a22d84c1948d5aa654e4aa74c2..be602880d0228469e1f7e2592639c62206046228 100644 (file)
@@ -283,6 +283,12 @@ int RadosUser::read_attrs(const DoutPrefixProvider* dpp, optional_yield y)
   return store->ctl()->user->get_attrs_by_uid(dpp, get_id(), &attrs, y, &objv_tracker);
 }
 
+int RadosUser::merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y)
+{
+  User::merge_and_store_attrs(dpp, new_attrs, y);
+  return store_user(dpp, y, false);
+}
+
 int RadosUser::read_stats(const DoutPrefixProvider *dpp,
                              optional_yield y, RGWStorageStats* stats,
                             ceph::real_time* last_stats_sync,
index 34ed1aeecf4ee6ea867774d66981c70294f67aa0..981bb2335b21fb5e524706378a1f8d43f60b03d9 100644 (file)
@@ -72,6 +72,7 @@ class RadosUser : public User {
                            std::unique_ptr<Bucket>* bucket,
                            optional_yield y) override;
     virtual int read_attrs(const DoutPrefixProvider* dpp, optional_yield y) override;
+    virtual int merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new_attrs, optional_yield y) override;
     virtual int read_stats(const DoutPrefixProvider *dpp,
                            optional_yield y, RGWStorageStats* stats,
                           ceph::real_time* last_stats_sync = nullptr,