From e0acbe484a8356f6efe2780358c7f1e85bf18c6e Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Tue, 31 Aug 2021 11:59:45 -0400 Subject: [PATCH] RGW - Zipper add attr merge for User Signed-off-by: Daniel Gryniewicz --- src/rgw/rgw_sal.h | 15 ++++++++++----- src/rgw/rgw_sal_rados.cc | 6 ++++++ src/rgw/rgw_sal_rados.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index f138dea6a31..c815032164f 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -484,7 +484,14 @@ class User { static bool empty(std::unique_ptr& 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& 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; diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 85cf83b8f05..be602880d02 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -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, diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 34ed1aeecf4..981bb2335b2 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -72,6 +72,7 @@ class RadosUser : public User { std::unique_ptr* 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, -- 2.39.5