From e2eea3e594f5c0abf1027f36113b5f091fafeeaf Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 10 Oct 2018 15:09:50 -0700 Subject: [PATCH] rgw: copy_obj() inherit dest rule from default bucket rule Otherwise it can be empty, in which case we'll always copy data, even if rule doesn't change. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 7 ++++++- src/rgw/rgw_rados.h | 2 +- src/rgw/rgw_rest_s3.cc | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0efd2a598dd..9d2f1f63656 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4482,7 +4482,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, rgw_obj& src_obj, RGWBucketInfo& dest_bucket_info, RGWBucketInfo& src_bucket_info, - const rgw_placement_rule *ptail_rule, + rgw_placement_rule *ptail_rule, real_time *src_mtime, real_time *mtime, const real_time *mod_ptr, @@ -4600,6 +4600,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (astate->has_manifest) { src_rule = &astate->manifest.get_tail_placement().placement_rule; + ldout(cct, 20) << __func__ << "(): manifest src_rule=" << src_rule->to_str() << dendl; } if (!src_rule || src_rule->empty()) { @@ -4608,6 +4609,8 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (!ptail_rule) { ptail_rule = &dest_bucket_info.placement_rule; + } else { + ptail_rule->inherit_from(dest_bucket_info.placement_rule); } auto& dest_storage_class = ptail_rule->get_storage_class(); @@ -4625,6 +4628,8 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, return -EIO; } + ldout(cct, 20) << __func__ << "(): src_rule=" << src_rule->to_str() << " src_pool=" << src_pool + << " dest_rule=" << ptail_rule->to_str() << " dest_pool=" << dest_pool << dendl; bool copy_data = !astate->has_manifest || (src_pool != dest_pool); bool copy_first = false; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 06ca96ea68c..7c2baff625f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1941,7 +1941,7 @@ public: rgw_obj& src_obj, RGWBucketInfo& dest_bucket_info, RGWBucketInfo& src_bucket_info, - const rgw_placement_rule *ptail_rule, + rgw_placement_rule *ptail_rule, ceph::real_time *src_mtime, ceph::real_time *mtime, const ceph::real_time *mod_ptr, diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 737a99eca5b..75448748da2 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2194,6 +2194,7 @@ int RGWCopyObj_ObjStore_S3::get_params() (dest_bucket_name.compare(src_bucket_name) == 0) && (dest_object.compare(src_object.name) == 0) && src_object.instance.empty() && + s->info.storage_class.storage_class.empty() && (attrs_mod != RGWRados::ATTRSMOD_REPLACE)) { /* can only copy object into itself if replacing attrs */ s->err.message = "This copy request is illegal because it is trying to copy " -- 2.47.3