From 9ed02f9d36058656588c78b56bab48a014e9785c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 27 Jan 2020 14:58:21 -0800 Subject: [PATCH] rgw: keep sync_policy as optional member inside RGWBucketInfo Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 2 +- src/rgw/rgw_common.cc | 13 ++----------- src/rgw/rgw_common.h | 4 ++-- src/rgw/rgw_sync_policy.h | 2 +- src/rgw/services/svc_bucket_sobj.cc | 5 ----- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 9a8c4eb0258..4d0c382d804 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2916,7 +2916,7 @@ public: bucket_info.set_sync_policy(std::move(new_policy)); } - policy = (rgw_sync_policy_info *)bucket_info.sync_policy.get(); + policy = &(*bucket_info.sync_policy); return 0; } diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 5288ee72841..d3c84343690 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -2085,15 +2085,7 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) { decode(obj_lock, bl); } if (struct_v >= 21) { - bool has_sync_policy; - decode(has_sync_policy, bl); - if (has_sync_policy) { - auto policy = make_shared(); - decode(*policy, bl); - sync_policy = std::const_pointer_cast(policy); - } else { - sync_policy.reset(); - } + decode(sync_policy, bl); } DECODE_FINISH(bl); @@ -2101,8 +2093,7 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) { void RGWBucketInfo::set_sync_policy(rgw_sync_policy_info&& policy) { - auto shared_policy = make_shared(policy); - sync_policy = std::const_pointer_cast(shared_policy); + sync_policy = std::move(policy); } bool RGWBucketInfo::empty_sync_policy() const diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 9627b70155a..4af59af8225 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -32,6 +32,7 @@ #include "rgw_website.h" #include "rgw_object_lock.h" #include "rgw_tag.h" +#include "rgw_sync_policy.h" #include "cls/version/cls_version_types.h" #include "cls/user/cls_user_types.h" #include "cls/rgw/cls_rgw_types.h" @@ -1097,7 +1098,6 @@ inline ostream& operator<<(ostream& out, const RGWBucketIndexType &index_type) } } -struct rgw_sync_policy_info; class RGWSI_Zone; struct RGWBucketInfo { @@ -1147,7 +1147,7 @@ struct RGWBucketInfo { RGWObjectLock obj_lock; - std::shared_ptr sync_policy; + std::optional sync_policy; void encode(bufferlist& bl) const; void decode(bufferlist::const_iterator& bl); diff --git a/src/rgw/rgw_sync_policy.h b/src/rgw/rgw_sync_policy.h index f177e6b9e30..0826c05c147 100644 --- a/src/rgw/rgw_sync_policy.h +++ b/src/rgw/rgw_sync_policy.h @@ -15,7 +15,7 @@ #pragma once -#include "rgw_common.h" +#include "rgw_basic_types.h" struct rgw_sync_symmetric_group { diff --git a/src/rgw/services/svc_bucket_sobj.cc b/src/rgw/services/svc_bucket_sobj.cc index 122a74d5dfe..9d77f5b430f 100644 --- a/src/rgw/services/svc_bucket_sobj.cc +++ b/src/rgw/services/svc_bucket_sobj.cc @@ -300,11 +300,6 @@ int RGWSI_Bucket_SObj::read_bucket_instance_info(RGWSI_Bucket_BI_Ctx& ctx, &ci, refresh_version, y); *info = e.info; - if (info->sync_policy) { /* fork policy off cache */ - auto policy = make_shared(*info->sync_policy); - info->sync_policy = std::const_pointer_cast(policy); - } - if (ret < 0) { if (ret != -ENOENT) { lderr(cct) << "ERROR: do_read_bucket_instance_info failed: " << ret << dendl; -- 2.39.5