From bdef2b709133dca2ecb9d51a96640aa70c3dea3b Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 18 Jul 2019 16:14:21 -0400 Subject: [PATCH] rgw: simplify RGWUserCtl params with default arguments Params types needed to define a non-default constructor as a workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165 Signed-off-by: Casey Bodley --- src/rgw/rgw_user.cc | 44 ++++++++++++++++++++++---------------------- src/rgw/rgw_user.h | 28 ++++++++++++++++------------ 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 9da0785bf50..4b722db263e 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -2559,17 +2559,17 @@ public: int RGWUserCtl::get_info_by_uid(const rgw_user& uid, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params) + const GetParams& params) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->read_user_info(op->ctx(), uid, info, - params->objv_tracker, - params->mtime, - params->cache_info, - params->attrs, + params.objv_tracker, + params.mtime, + params.cache_info, + params.attrs, y); }); } @@ -2577,13 +2577,13 @@ int RGWUserCtl::get_info_by_uid(const rgw_user& uid, int RGWUserCtl::get_info_by_email(const string& email, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params) + const GetParams& params) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->get_user_info_by_email(op->ctx(), email, info, - params->objv_tracker, - params->mtime, + params.objv_tracker, + params.mtime, y); }); } @@ -2591,13 +2591,13 @@ int RGWUserCtl::get_info_by_email(const string& email, int RGWUserCtl::get_info_by_swift(const string& swift_name, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params) + const GetParams& params) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->get_user_info_by_swift(op->ctx(), swift_name, info, - params->objv_tracker, - params->mtime, + params.objv_tracker, + params.mtime, y); }); } @@ -2605,13 +2605,13 @@ int RGWUserCtl::get_info_by_swift(const string& swift_name, int RGWUserCtl::get_info_by_access_key(const string& access_key, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params) + const GetParams& params) { return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->get_user_info_by_access_key(op->ctx(), access_key, info, - params->objv_tracker, - params->mtime, + params.objv_tracker, + params.mtime, y); }); } @@ -2629,30 +2629,30 @@ int RGWUserCtl::get_attrs_by_uid(const rgw_user& user_id, } int RGWUserCtl::store_info(const RGWUserInfo& info, optional_yield y, - ceph::optional_ref_default params) + const PutParams& params) { string key = RGWSI_User::get_meta_key(info.user_id); return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->store_user_info(op->ctx(), info, - params->old_info, - params->objv_tracker, - params->mtime, - params->exclusive, - params->attrs, + params.old_info, + params.objv_tracker, + params.mtime, + params.exclusive, + params.attrs, y); }); } int RGWUserCtl::remove_info(const RGWUserInfo& info, optional_yield y, - ceph::optional_ref_default params) + const RemoveParams& params) { string key = RGWSI_User::get_meta_key(info.user_id); return be_handler->call([&](RGWSI_MetaBackend_Handler::Op *op) { return svc.user->remove_user_info(op->ctx(), info, - params->objv_tracker, + params.objv_tracker, y); }); } diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index 6f5a6823a5e..18a6ae9d753 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -18,8 +18,6 @@ #include "rgw_formats.h" #include "rgw_metadata.h" -#include "common/optional_ref_default.h" - #define RGW_USER_ANON_ID "anonymous" #define SECRET_KEY_LEN 40 @@ -827,6 +825,8 @@ public: rgw_cache_entry_info *cache_info{nullptr}; map *attrs{nullptr}; + GetParams() {} + GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { objv_tracker = _objv_tracker; return *this; @@ -855,6 +855,8 @@ public: bool exclusive{false}; map *attrs; + PutParams() {} + PutParams& set_old_info(RGWUserInfo *_info) { old_info = _info; return *this; @@ -884,20 +886,22 @@ public: struct RemoveParams { RGWObjVersionTracker *objv_tracker{nullptr}; + RemoveParams() {} + RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) { objv_tracker = _objv_tracker; return *this; } }; - int get_info_by_uid(const rgw_user& uid, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params = std::nullopt); - int get_info_by_email(const string& email, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params = std::nullopt); - int get_info_by_swift(const string& swift_name, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params = std::nullopt); - int get_info_by_access_key(const string& access_key, RGWUserInfo *info, optional_yield y, - ceph::optional_ref_default params = std::nullopt); + int get_info_by_uid(const rgw_user& uid, RGWUserInfo *info, + optional_yield y, const GetParams& params = {}); + int get_info_by_email(const string& email, RGWUserInfo *info, + optional_yield y, const GetParams& params = {}); + int get_info_by_swift(const string& swift_name, RGWUserInfo *info, + optional_yield y, const GetParams& params = {}); + int get_info_by_access_key(const string& access_key, RGWUserInfo *info, + optional_yield y, const GetParams& params = {}); int get_attrs_by_uid(const rgw_user& user_id, map *attrs, @@ -905,9 +909,9 @@ public: RGWObjVersionTracker *objv_tracker = nullptr); int store_info(const RGWUserInfo& info, optional_yield y, - ceph::optional_ref_default params); + const PutParams& params = {}); int remove_info(const RGWUserInfo& info, optional_yield y, - ceph::optional_ref_default params); + const RemoveParams& params = {}); int add_bucket(const rgw_user& user, const rgw_bucket& bucket, -- 2.39.5