]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: copy_obj() inherit dest rule from default bucket rule
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 10 Oct 2018 22:09:50 +0000 (15:09 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Jan 2019 03:00:21 +0000 (19:00 -0800)
Otherwise it can be empty, in which case we'll always copy data, even
if rule doesn't change.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_s3.cc

index 0efd2a598ddd9ba6a95e79b88b42a9218ca72621..9d2f1f636566f3eff6837731408da45d94ce2099 100644 (file)
@@ -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;
index 06ca96ea68cec69e982dfc3c73bb13ddf8d68eef..7c2baff625f5dd61c83e74ce6dd4c41a69f6062b 100644 (file)
@@ -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,
index 737a99eca5b21f68ee52e113fcff6d602cb1f182..75448748da2cd6e742222795f14c5501b10f5e8c 100644 (file)
@@ -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 "