From 0242d7400e2f8cf48f71600ea66b59e7025ac0f8 Mon Sep 17 00:00:00 2001 From: Ali Maredia Date: Wed, 23 Jan 2019 23:53:53 -0500 Subject: [PATCH] rgw: log refactoring for putobj_processor Signed-off-by: Ali Maredia --- src/rgw/rgw_file.cc | 2 +- src/rgw/rgw_op.cc | 10 ++++----- src/rgw/rgw_putobj_processor.cc | 21 ++++++++--------- src/rgw/rgw_putobj_processor.h | 40 +++++++++++++++++++++------------ 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 5c0a4d3beff..4a28ec6cf03 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1468,7 +1468,7 @@ namespace rgw { &s->dest_placement, s->bucket_owner.get_id(), *static_cast(s->obj_ctx), - obj, olh_epoch, s->req_id); + obj, olh_epoch, s->req_id, this); op_ret = processor->prepare(); if (op_ret < 0) { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 11a62400e23..4e77bdbda58 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3662,7 +3662,7 @@ void RGWPutObj::execute() processor.emplace( &aio, store, s->bucket_info, pdest_placement, s->owner.get_id(), obj_ctx, obj, - multipart_upload_id, multipart_part_num, multipart_part_str); + multipart_upload_id, multipart_part_num, multipart_part_str, this); } else if(append) { if (s->bucket_info.versioned()) { op_ret = -ERR_INVALID_BUCKET_STATE; @@ -3671,7 +3671,7 @@ void RGWPutObj::execute() pdest_placement = &s->dest_placement; processor.emplace( &aio, store, s->bucket_info, pdest_placement, s->bucket_owner.get_id(),obj_ctx, obj, - s->req_id, position, &cur_accounted_size); + s->req_id, position, &cur_accounted_size, this); } else { if (s->bucket_info.versioning_enabled()) { if (!version_id.empty()) { @@ -3684,7 +3684,7 @@ void RGWPutObj::execute() pdest_placement = &s->dest_placement; processor.emplace( &aio, store, s->bucket_info, pdest_placement, - s->bucket_owner.get_id(), obj_ctx, obj, olh_epoch, s->req_id); + s->bucket_owner.get_id(), obj_ctx, obj, olh_epoch, s->req_id, this); } op_ret = processor->prepare(); @@ -4005,7 +4005,7 @@ void RGWPostObj::execute() &s->dest_placement, s->bucket_owner.get_id(), *static_cast(s->obj_ctx), - obj, 0, s->req_id); + obj, 0, s->req_id, this); op_ret = processor.prepare(); if (op_ret < 0) { return; @@ -6748,7 +6748,7 @@ int RGWBulkUploadOp::handle_file(const boost::string_ref path, using namespace rgw::putobj; AtomicObjectProcessor processor(&aio, store, binfo, &s->dest_placement, bowner.get_id(), - obj_ctx, obj, 0, s->req_id); + obj_ctx, obj, 0, s->req_id, this); op_ret = processor.prepare(); if (op_ret < 0) { diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 45ac26c7ebc..638d716a5a2 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -142,22 +142,22 @@ RadosWriter::~RadosWriter() */ for (const auto& obj : written) { if (raw_head && obj == *raw_head) { - ldout(store->ctx(), 5) << "NOTE: we should not process the head object (" << obj << ") here" << dendl; + ldpp_dout(dpp, 5) << "NOTE: we should not process the head object (" << obj << ") here" << dendl; need_to_remove_head = true; continue; } int r = store->delete_raw_obj(obj); if (r < 0 && r != -ENOENT) { - ldout(store->ctx(), 5) << "WARNING: failed to remove obj (" << obj << "), leaked" << dendl; + ldpp_dout(dpp, 5) << "WARNING: failed to remove obj (" << obj << "), leaked" << dendl; } } if (need_to_remove_head) { - ldout(store->ctx(), 5) << "NOTE: we are going to process the head obj (" << *raw_head << ")" << dendl; + ldpp_dout(dpp, 5) << "NOTE: we are going to process the head obj (" << *raw_head << ")" << dendl; int r = store->delete_obj(obj_ctx, bucket_info, head_obj, 0, 0); if (r < 0 && r != -ENOENT) { - ldout(store->ctx(), 0) << "WARNING: failed to remove obj (" << *raw_head << "), leaked" << dendl; + ldpp_dout(dpp, 0) << "WARNING: failed to remove obj (" << *raw_head << "), leaked" << dendl; } } } @@ -190,6 +190,7 @@ int ManifestObjectProcessor::next(uint64_t offset, uint64_t *pstripe_size) } + int AtomicObjectProcessor::process_first_chunk(bufferlist&& data, DataProcessor **processor) { @@ -367,7 +368,7 @@ int MultipartObjectProcessor::prepare_head() int r = store->get_max_chunk_size(tail_placement_rule, target_obj, &chunk_size, &alignment); if (r < 0) { - ldout(store->ctx(), 0) << "ERROR: unexpected: get_max_chunk_size(): placement_rule=" << tail_placement_rule.to_str() << " obj=" << target_obj << " returned r=" << r << dendl; + ldpp_dout(dpp, 0) << "ERROR: unexpected: get_max_chunk_size(): placement_rule=" << tail_placement_rule.to_str() << " obj=" << target_obj << " returned r=" << r << dendl; return r; } store->get_max_aligned_size(default_stripe_size, alignment, &stripe_size); @@ -466,7 +467,7 @@ int MultipartObjectProcessor::complete(size_t accounted_size, bool compressed; r = rgw_compression_info_from_attrset(attrs, compressed, info.cs_info); if (r < 0) { - ldout(store->ctx(), 1) << "cannot get compression info" << dendl; + ldpp_dout(dpp, 1) << "cannot get compression info" << dendl; return r; } @@ -521,7 +522,7 @@ int AppendObjectProcessor::prepare() *cur_accounted_size = astate->accounted_size; if (!astate->exists) { if (position != 0) { - ldout(store->ctx(), 5) << "ERROR: Append position should be zero" << dendl; + ldpp_dout(dpp, 5) << "ERROR: Append position should be zero" << dendl; return -ERR_POSITION_NOT_EQUAL_TO_LENGTH; } else { cur_part_num = 1; @@ -538,17 +539,17 @@ int AppendObjectProcessor::prepare() // check whether the object appendable map::iterator iter = astate->attrset.find(RGW_ATTR_APPEND_PART_NUM); if (iter == astate->attrset.end()) { - ldout(store->ctx(), 5) << "ERROR: The object is not appendable" << dendl; + ldpp_dout(dpp, 5) << "ERROR: The object is not appendable" << dendl; return -ERR_OBJECT_NOT_APPENDABLE; } if (position != *cur_accounted_size) { - ldout(store->ctx(), 5) << "ERROR: Append position should be equal to the obj size" << dendl; + ldpp_dout(dpp, 5) << "ERROR: Append position should be equal to the obj size" << dendl; return -ERR_POSITION_NOT_EQUAL_TO_LENGTH; } try { decode(cur_part_num, iter->second); } catch (buffer::error& err) { - ldout(store->ctx(), 5) << "ERROR: failed to decode part num" << dendl; + ldpp_dout(dpp, 5) << "ERROR: failed to decode part num" << dendl; return -EIO; } cur_part_num++; diff --git a/src/rgw/rgw_putobj_processor.h b/src/rgw/rgw_putobj_processor.h index 8d265f172bc..3037406b905 100644 --- a/src/rgw/rgw_putobj_processor.h +++ b/src/rgw/rgw_putobj_processor.h @@ -83,12 +83,13 @@ class RadosWriter : public DataProcessor { const rgw_obj head_obj; RGWSI_RADOS::Obj stripe_obj; // current stripe object RawObjSet written; // set of written objects for deletion + const DoutPrefixProvider *dpp; public: RadosWriter(Aio *aio, RGWRados *store, const RGWBucketInfo& bucket_info, - RGWObjectCtx& obj_ctx, const rgw_obj& head_obj) + RGWObjectCtx& obj_ctx, const rgw_obj& head_obj, const DoutPrefixProvider *dpp) : aio(aio), store(store), bucket_info(bucket_info), - obj_ctx(obj_ctx), head_obj(head_obj) + obj_ctx(obj_ctx), head_obj(head_obj), dpp(dpp) {} ~RadosWriter(); @@ -106,6 +107,7 @@ class RadosWriter : public DataProcessor { // when the operation completes successfully, clear the set of written objects // so they aren't deleted on destruction void clear_written() { written.clear(); } + }; // a rados object processor that stripes according to RGWObjManifest @@ -118,6 +120,7 @@ class ManifestObjectProcessor : public HeadObjectProcessor, const rgw_user& owner; RGWObjectCtx& obj_ctx; rgw_obj head_obj; + const DoutPrefixProvider *dpp; RadosWriter writer; RGWObjManifest manifest; @@ -133,12 +136,14 @@ class ManifestObjectProcessor : public HeadObjectProcessor, const RGWBucketInfo& bucket_info, const rgw_placement_rule *ptail_placement_rule, const rgw_user& owner, RGWObjectCtx& obj_ctx, - const rgw_obj& head_obj) + const rgw_obj& head_obj, + const DoutPrefixProvider* dpp) : HeadObjectProcessor(0), store(store), bucket_info(bucket_info), owner(owner), obj_ctx(obj_ctx), head_obj(head_obj), - writer(aio, store, bucket_info, obj_ctx, head_obj), + writer(aio, store, bucket_info, obj_ctx, head_obj, dpp), + dpp(dpp), chunk(&writer, 0), stripe(&chunk, this, 0) { if (ptail_placement_rule) { tail_placement_rule = *ptail_placement_rule; @@ -148,6 +153,7 @@ class ManifestObjectProcessor : public HeadObjectProcessor, void set_tail_placement(const rgw_placement_rule&& tpr) { tail_placement_rule = tpr; } + }; @@ -157,6 +163,7 @@ class AtomicObjectProcessor : public ManifestObjectProcessor { const std::optional olh_epoch; const std::string unique_tag; bufferlist first_chunk; // written with the head in complete() + const DoutPrefixProvider *dpp; int process_first_chunk(bufferlist&& data, DataProcessor **processor) override; public: @@ -166,10 +173,11 @@ class AtomicObjectProcessor : public ManifestObjectProcessor { const rgw_user& owner, RGWObjectCtx& obj_ctx, const rgw_obj& head_obj, std::optional olh_epoch, - const std::string& unique_tag) + const std::string& unique_tag, + const DoutPrefixProvider *dpp) : ManifestObjectProcessor(aio, store, bucket_info, ptail_placement_rule, - owner, obj_ctx, head_obj), - olh_epoch(olh_epoch), unique_tag(unique_tag) + owner, obj_ctx, head_obj, dpp), + olh_epoch(olh_epoch), unique_tag(unique_tag), dpp(dpp) {} // prepare a trivial manifest @@ -194,6 +202,7 @@ class MultipartObjectProcessor : public ManifestObjectProcessor { const std::string upload_id; const int part_num; const std::string part_num_str; + const DoutPrefixProvider *dpp; RGWMPObj mp; // write the first chunk and wait on aio->drain() for its completion. @@ -208,12 +217,13 @@ class MultipartObjectProcessor : public ManifestObjectProcessor { const rgw_user& owner, RGWObjectCtx& obj_ctx, const rgw_obj& head_obj, const std::string& upload_id, uint64_t part_num, - const std::string& part_num_str) + const std::string& part_num_str, + const DoutPrefixProvider *dpp) : ManifestObjectProcessor(aio, store, bucket_info, ptail_placement_rule, - owner, obj_ctx, head_obj), + owner, obj_ctx, head_obj, dpp), target_obj(head_obj), upload_id(upload_id), - part_num(part_num), part_num_str(part_num_str), - mp(head_obj.key.name, upload_id) + part_num(part_num), part_num_str(part_num_str), dpp(dpp), + mp(head_obj.key.name, upload_id) {} // prepare a multipart manifest @@ -227,6 +237,7 @@ class MultipartObjectProcessor : public ManifestObjectProcessor { const char *if_match, const char *if_nomatch, const std::string *user_data, rgw_zone_set *zones_trace, bool *canceled) override; + }; class AppendObjectProcessor : public ManifestObjectProcessor { @@ -236,6 +247,7 @@ class MultipartObjectProcessor : public ManifestObjectProcessor { uint64_t *cur_accounted_size; string cur_etag; const std::string unique_tag; + const DoutPrefixProvider *dpp; RGWObjManifest *cur_manifest; @@ -245,9 +257,9 @@ class MultipartObjectProcessor : public ManifestObjectProcessor { AppendObjectProcessor(Aio *aio, RGWRados *store, const RGWBucketInfo& bucket_info, const rgw_placement_rule *ptail_placement_rule, const rgw_user& owner, RGWObjectCtx& obj_ctx,const rgw_obj& head_obj, - const std::string& unique_tag, uint64_t position, uint64_t *cur_accounted_size) - : ManifestObjectProcessor(aio, store, bucket_info, ptail_placement_rule, owner, obj_ctx, head_obj), - position(position), cur_size(0), cur_accounted_size(cur_accounted_size), + const std::string& unique_tag, uint64_t position, uint64_t *cur_accounted_size, const DoutPrefixProvider *dpp) + : ManifestObjectProcessor(aio, store, bucket_info, ptail_placement_rule, owner, obj_ctx, head_obj, dpp), + position(position), cur_size(0), cur_accounted_size(cur_accounted_size), dpp(dpp), unique_tag(unique_tag), cur_manifest(nullptr) {} int prepare() override; -- 2.39.5