]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: propagate storage class to manifest generator
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 26 Jun 2018 01:29:14 +0000 (18:29 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 4 Jan 2019 02:04:18 +0000 (18:04 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_putobj_processor.cc
src/rgw/rgw_putobj_processor.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc

index 26ee460390dc324689726e268a60502b98c44dc4..0c946b63e86a0814811306e16082a5171b8dcfab 100644 (file)
@@ -664,6 +664,15 @@ struct rgw_placement_rule {
     return name.empty() && storage_class.empty();
   }
 
+  void inherit_from(const rgw_placement_rule& r) {
+    if (name.empty()) {
+      name = r.name;
+    }
+    if (storage_class.empty()) {
+      storage_class = r.storage_class;
+    }
+  }
+
   void clear() {
     name.clear();
     storage_class.clear();
@@ -1611,7 +1620,7 @@ struct req_info {
   string effective_uri;
   string request_params;
   string domain;
-  string storage_class;
+  rgw_placement_rule storage_class;
 
   req_info(CephContext *cct, const RGWEnv *env);
   void rebuild_from(req_info& src);
index 5a0476a737e8397a2eb5f009103cb19541650721..30a78542d0f38ea6d59b6f13b1c1228535297632 100644 (file)
@@ -3506,7 +3506,8 @@ void RGWPutObj::execute()
 
   if (multipart) {
     processor.emplace<MultipartObjectProcessor>(
-        &aio, store, s->bucket_info, s->owner.get_id(), obj_ctx, obj,
+        &aio, store, s->bucket_info, &s->info.storage_class,
+        s->owner.get_id(), obj_ctx, obj,
         multipart_upload_id, multipart_part_num, multipart_part_str);
   } else {
     if (s->bucket_info.versioning_enabled()) {
@@ -3518,8 +3519,8 @@ void RGWPutObj::execute()
       }
     }
     processor.emplace<AtomicObjectProcessor>(
-        &aio, store, s->bucket_info, s->bucket_owner.get_id(),
-        obj_ctx, obj, olh_epoch, s->req_id);
+        &aio, store, s->bucket_info, &s->info.storage_class,
+        s->bucket_owner.get_id(), obj_ctx, obj, olh_epoch, s->req_id);
   }
 
   op_ret = processor->prepare();
@@ -3835,16 +3836,17 @@ void RGWPostObj::execute()
       ldpp_dout(this, 15) << "supplied_md5=" << supplied_md5 << dendl;
     }
 
-
     rgw_obj obj(s->bucket, get_current_filename());
     if (s->bucket_info.versioning_enabled()) {
       store->gen_rand_obj_instance_name(&obj);
     }
 
     rgw::AioThrottle aio(s->cct->_conf->rgw_put_obj_min_window_size);
+    rgw_placement_rule& tail_placement = s->info.storage_class;
+
     using namespace rgw::putobj;
     AtomicObjectProcessor processor(&aio, store, s->bucket_info,
-                                    nullptr,
+                                    &tail_placement,
                                     s->bucket_owner.get_id(),
                                     *static_cast<RGWObjectCtx*>(s->obj_ctx),
                                     obj, 0, s->req_id);
@@ -6396,8 +6398,6 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
   }
 
 
-  rgw_placement_rule placement_rule;
-  placement_rule.storage_class = s->info.storage_class;
   if (bucket_exists) {
     rgw_placement_rule selected_placement_rule;
     rgw_bucket bucket;
@@ -6405,7 +6405,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
     bucket.name = s->bucket_name;
     op_ret = store->svc.zone->select_bucket_placement(*(s->user),
                                             store->svc.zone->get_zonegroup().get_id(),
-                                            placement_rule,
+                                            s->info.storage_class,
                                             &selected_placement_rule,
                                             nullptr);
     if (selected_placement_rule != binfo.placement_rule) {
@@ -6435,7 +6435,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
   op_ret = store->create_bucket(*(s->user),
                                 bucket,
                                 store->svc.zone->get_zonegroup().get_id(),
-                                placement_rule, binfo.swift_ver_location,
+                                s->info.storage_class, binfo.swift_ver_location,
                                 pquota_info, attrs,
                                 out_info, pobjv, &ep_objv, creation_time,
                                 pmaster_bucket, pmaster_num_shards, true);
@@ -6572,9 +6572,11 @@ int RGWBulkUploadOp::handle_file(const boost::string_ref path,
   }
 
   rgw::AioThrottle aio(store->ctx()->_conf->rgw_put_obj_min_window_size);
+  rgw_placement_rule& tail_placement = s->info.storage_class;
+
   using namespace rgw::putobj;
 
-  AtomicObjectProcessor processor(&aio, store, binfo, nullptr, bowner.get_id(),
+  AtomicObjectProcessor processor(&aio, store, binfo, &tail_placement, bowner.get_id(),
                                   obj_ctx, obj, 0, s->req_id);
 
   op_ret = processor.prepare();
index bb6bc82ff29c8ad162e7a6e8d438044c9c7d1d28..801419cbe73675819f69105ddc86e9b6c0dc096e 100644 (file)
@@ -211,7 +211,7 @@ int AtomicObjectProcessor::prepare()
 
   r = manifest_gen.create_begin(store->ctx(), &manifest,
                                 bucket_info.placement_rule,
-                                ptail_placement_rule,
+                                &tail_placement_rule,
                                 head_obj.bucket, head_obj);
   if (r < 0) {
     return r;
@@ -331,7 +331,7 @@ int MultipartObjectProcessor::prepare_head()
 {
   int r = manifest_gen.create_begin(store->ctx(), &manifest,
                                     bucket_info.placement_rule,
-                                    ptail_placement_rule,
+                                    &tail_placement_rule,
                                     target_obj.bucket, target_obj);
   if (r < 0) {
     return r;
index b7b6f809103ea55f8fffeab075ff6e1099e1768b..851d31c311b2e1be8df07f49448d4fcb5663f1f2 100644 (file)
@@ -114,7 +114,7 @@ class ManifestObjectProcessor : public HeadObjectProcessor,
  protected:
   RGWRados *const store;
   const RGWBucketInfo& bucket_info;
-  const rgw_placement_rule *ptail_placement_rule;
+  rgw_placement_rule tail_placement_rule;
   const rgw_user& owner;
   RGWObjectCtx& obj_ctx;
   rgw_obj head_obj;
@@ -136,11 +136,14 @@ class ManifestObjectProcessor : public HeadObjectProcessor,
                           const rgw_obj& head_obj)
     : HeadObjectProcessor(0),
       store(store), bucket_info(bucket_info),
-      ptail_placement_rule(ptail_placement_rule), owner(owner),
+      owner(owner),
       obj_ctx(obj_ctx), head_obj(head_obj),
       writer(aio, store, bucket_info, obj_ctx, head_obj),
-      chunk(&writer, 0), stripe(&chunk, this, 0)
-  {}
+      chunk(&writer, 0), stripe(&chunk, this, 0) {
+        if (ptail_placement_rule) {
+          tail_placement_rule = *ptail_placement_rule;
+        }
+      }
 };
 
 
index 799679481023aef229dee0e81d8fbbfef01e427e..6a1a5ed8bb6982c9ab49640a367377ff7ffb58e5 100644 (file)
@@ -313,10 +313,13 @@ int RGWObjManifest::generator::create_begin(CephContext *cct, RGWObjManifest *_m
   manifest = _m;
 
   if (!tail_placement_rule) {
-    tail_placement_rule = &head_placement_rule;
+    manifest->set_tail_placement(head_placement_rule, _b);
+  } else {
+    rgw_placement_rule new_tail_rule = *tail_placement_rule;
+    new_tail_rule.inherit_from(head_placement_rule);
+    manifest->set_tail_placement(new_tail_rule, _b);
   }
 
-  manifest->set_tail_placement(*tail_placement_rule, _b);
   manifest->set_head(head_placement_rule, _obj, 0);
   last_ofs = 0;
 
index a35a6a3be510017966c447d0afe834079bddd45a..737a99eca5b21f68ee52e113fcff6d602cb1f182 100644 (file)
@@ -1241,7 +1241,7 @@ int RGWCreateBucket_ObjStore_S3::get_params()
 
   size_t pos = location_constraint.find(':');
   if (pos != string::npos) {
-    placement_rule.init(location_constraint.substr(pos + 1), s->info.storage_class);
+    placement_rule.init(location_constraint.substr(pos + 1), s->info.storage_class.storage_class);
     location_constraint = location_constraint.substr(0, pos);
   }
 
@@ -3437,7 +3437,7 @@ int RGWHandler_REST_S3::init(RGWRados *store, struct req_state *s,
 
   const char *sc = s->info.env->get("HTTP_X_AMZ_STORAGE_CLASS");
   if (sc) {
-    s->info.storage_class = sc;
+    s->info.storage_class.storage_class = sc;
   }
 
   return RGWHandler_REST::init(store, s, cio);
index 702a435bd06394aeb87a2860022e2ebb16b1cb1f..8ef2ed4bd175b21d85c5fadba673dc0f2c4864ff 100644 (file)
@@ -711,7 +711,7 @@ int RGWCreateBucket_ObjStore_SWIFT::get_params()
   location_constraint = store->svc.zone->get_zonegroup().api_name;
   get_rmattrs_from_headers(s, CONT_PUT_ATTR_PREFIX,
                            CONT_REMOVE_ATTR_PREFIX, rmattr_names);
-  placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class);
+  placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class.storage_class);
 
   return get_swift_versioning_settings(s, swift_ver_location);
 }
@@ -1125,7 +1125,7 @@ int RGWPutMetadataBucket_ObjStore_SWIFT::get_params()
 
   get_rmattrs_from_headers(s, CONT_PUT_ATTR_PREFIX, CONT_REMOVE_ATTR_PREFIX,
                           rmattr_names);
-  placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class);
+  placement_rule.init(s->info.env->get("HTTP_X_STORAGE_POLICY", ""), s->info.storage_class.storage_class);
 
   return get_swift_versioning_settings(s, swift_ver_location);
 }
@@ -3050,7 +3050,7 @@ int RGWHandler_REST_SWIFT::init(RGWRados* store, struct req_state* s,
     s->op = OP_PUT;
   }
 
-  s->info.storage_class = s->info.env->get("HTTP_X_OBJECT_STORAGE_CLASS", "");
+  s->info.storage_class.storage_class = s->info.env->get("HTTP_X_OBJECT_STORAGE_CLASS", "");
 
   return RGWHandler_REST::init(store, s, cio);
 }