From: Yehuda Sadeh Date: Tue, 26 Jun 2018 01:29:14 +0000 (-0700) Subject: rgw: propagate storage class to manifest generator X-Git-Tag: v14.1.0~314^2~55 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5a08d063ea4878023d5f1b2eb65d683e30a8dc43;p=ceph.git rgw: propagate storage class to manifest generator Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 26ee460390dc..0c946b63e86a 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 5a0476a737e8..30a78542d0f3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3506,7 +3506,8 @@ void RGWPutObj::execute() if (multipart) { processor.emplace( - &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( - &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(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(); diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index bb6bc82ff29c..801419cbe736 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -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; diff --git a/src/rgw/rgw_putobj_processor.h b/src/rgw/rgw_putobj_processor.h index b7b6f809103e..851d31c311b2 100644 --- a/src/rgw/rgw_putobj_processor.h +++ b/src/rgw/rgw_putobj_processor.h @@ -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; + } + } }; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 799679481023..6a1a5ed8bb69 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index a35a6a3be510..737a99eca5b2 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 702a435bd063..8ef2ed4bd175 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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); }