diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index be8eac93d90e83..e61f8f77342a92 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1238,7 +1238,7 @@ int check_obj_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_o string status = (needs_fixing ? "needs_fixing" : "ok"); if ((needs_fixing || remove_bad) && fix) { - ret = store->fix_head_obj_locator(obj.bucket, needs_fixing, remove_bad, key); + ret = store->fix_head_obj_locator(bucket_info, needs_fixing, remove_bad, key); if (ret < 0) { cerr << "ERROR: fix_head_object_locator() returned ret=" << ret << std::endl; goto done; @@ -1265,7 +1265,7 @@ int check_obj_tail_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj& obj, bool needs_fixing; string status; - int ret = store->fix_tail_obj_locator(obj.bucket, key, fix, &needs_fixing); + int ret = store->fix_tail_obj_locator(bucket_info, key, fix, &needs_fixing); if (ret < 0) { cerr << "ERROR: fix_tail_object_locator_underscore() returned ret=" << ret << std::endl; status = "failed"; @@ -4567,9 +4567,15 @@ int main(int argc, char **argv) } if (opt_cmd == OPT_OLH_GET) { + RGWBucketInfo bucket_info; + int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket); + if (ret < 0) { + cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; + return -ret; + } RGWOLHInfo olh; rgw_obj obj(bucket, object); - int ret = store->get_olh(obj, &olh); + ret = store->get_olh(bucket_info, obj, &olh); if (ret < 0) { cerr << "ERROR: failed reading olh: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -4579,6 +4585,12 @@ int main(int argc, char **argv) } if (opt_cmd == OPT_OLH_READLOG) { + RGWBucketInfo bucket_info; + int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket); + if (ret < 0) { + cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; + return -ret; + } map > log; bool is_truncated; @@ -4587,12 +4599,12 @@ int main(int argc, char **argv) RGWObjState *state; - int ret = store->get_obj_state(&rctx, obj, &state, false); /* don't follow olh */ + ret = store->get_obj_state(&rctx, bucket_info, obj, &state, false); /* don't follow olh */ if (ret < 0) { return -ret; } - ret = store->bucket_index_read_olh_log(*state, obj, 0, &log, &is_truncated); + ret = store->bucket_index_read_olh_log(bucket_info, *state, obj, 0, &log, &is_truncated); if (ret < 0) { cerr << "ERROR: failed reading olh: " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 748b70d05d982a..70c39fd0c0fa48 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -647,7 +647,7 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, RGWObjState *astate = NULL; rgw_obj obj(bucket, (*it).key); - ret = store->get_obj_state(&obj_ctx, obj, &astate, NULL); + ret = store->get_obj_state(&obj_ctx, info, obj, &astate, NULL); if (ret == -ENOENT) { dout(1) << "WARNING: cannot find obj state for obj " << obj.get_oid() << dendl; continue; @@ -662,7 +662,7 @@ int rgw_remove_bucket_bypass_gc(RGWRados *store, rgw_bucket& bucket, RGWObjManifest::obj_iterator miter = manifest.obj_begin(); rgw_obj head_obj = manifest.get_obj(); rgw_raw_obj raw_head_obj; - store->obj_to_raw(head_obj, &raw_head_obj); + store->obj_to_raw(info.placement_rule, head_obj, &raw_head_obj); for (; miter != manifest.obj_end() && max_aio--; ++miter) { diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 0e0fc4e6c29e18..c5817b72843999 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -572,7 +572,7 @@ int RGWAsyncRemoveObj::_send_request() RGWObjState *state; - int ret = store->get_obj_state(&obj_ctx, obj, &state); + int ret = store->get_obj_state(&obj_ctx, bucket_info, obj, &state); if (ret < 0) { ldout(store->ctx(), 20) << __func__ << "(): get_obj_state() obj=" << obj << " returned ret=" << ret << dendl; return ret; @@ -728,17 +728,17 @@ int RGWRadosTimelogTrimCR::request_complete() int RGWAsyncStatObj::_send_request() { rgw_raw_obj raw_obj; - store->obj_to_raw(obj, &raw_obj); + store->obj_to_raw(bucket_info.placement_rule, obj, &raw_obj); return store->raw_obj_stat(raw_obj, psize, pmtime, pepoch, nullptr, nullptr, objv_tracker); } RGWStatObjCR::RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store, - const rgw_obj& obj, uint64_t *psize, + const RGWBucketInfo& _bucket_info, const rgw_obj& obj, uint64_t *psize, real_time* pmtime, uint64_t *pepoch, RGWObjVersionTracker *objv_tracker) : RGWSimpleCoroutine(store->ctx()), store(store), async_rados(async_rados), - obj(obj), psize(psize), pmtime(pmtime), pepoch(pepoch), + bucket_info(_bucket_info), obj(obj), psize(psize), pmtime(pmtime), pepoch(pepoch), objv_tracker(objv_tracker) { } @@ -754,7 +754,7 @@ void RGWStatObjCR::request_cleanup() int RGWStatObjCR::send_request() { req = new RGWAsyncStatObj(this, stack->create_completion_notifier(), - store, obj, psize, pmtime, pepoch, objv_tracker); + store, bucket_info, obj, psize, pmtime, pepoch, objv_tracker); async_rados->queue(req); return 0; } diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 1a7a1353d36705..3e7c1bca289aa6 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -1085,6 +1085,7 @@ class RGWRadosTimelogTrimCR : public RGWSimpleCoroutine { class RGWAsyncStatObj : public RGWAsyncRadosRequest { RGWRados *store; + RGWBucketInfo bucket_info; rgw_obj obj; uint64_t *psize; real_time *pmtime; @@ -1094,7 +1095,7 @@ class RGWAsyncStatObj : public RGWAsyncRadosRequest { int _send_request() override; public: RGWAsyncStatObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *store, - const rgw_obj& obj, uint64_t *psize = nullptr, + const RGWBucketInfo& _bucket_info, const rgw_obj& obj, uint64_t *psize = nullptr, real_time *pmtime = nullptr, uint64_t *pepoch = nullptr, RGWObjVersionTracker *objv_tracker = nullptr) : RGWAsyncRadosRequest(caller, cn), store(store), obj(obj), psize(psize), @@ -1104,6 +1105,7 @@ class RGWAsyncStatObj : public RGWAsyncRadosRequest { class RGWStatObjCR : public RGWSimpleCoroutine { RGWRados *store; RGWAsyncRadosProcessor *async_rados; + RGWBucketInfo bucket_info; rgw_obj obj; uint64_t *psize; real_time *pmtime; @@ -1112,7 +1114,7 @@ class RGWStatObjCR : public RGWSimpleCoroutine { RGWAsyncStatObj *req = nullptr; public: RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store, - const rgw_obj& obj, uint64_t *psize = nullptr, + const RGWBucketInfo& _bucket_info, const rgw_obj& obj, uint64_t *psize = nullptr, real_time* pmtime = nullptr, uint64_t *pepoch = nullptr, RGWObjVersionTracker *objv_tracker = nullptr); ~RGWStatObjCR() { diff --git a/src/rgw/rgw_dencoder.cc b/src/rgw/rgw_dencoder.cc index 44103604c09fd9..6ee42bfe163fe5 100644 --- a/src/rgw/rgw_dencoder.cc +++ b/src/rgw/rgw_dencoder.cc @@ -194,8 +194,8 @@ void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_st } } - if (!tail_bucket.name.empty()) { - loc.bucket = tail_bucket.bucket; + if (!tail_placement.bucket.name.empty()) { + loc.bucket = tail_placement.bucket; } else { loc.bucket = obj.bucket; } @@ -204,7 +204,7 @@ void RGWObjManifest::get_implicit_location(uint64_t cur_part_id, uint64_t cur_st // to get the right shadow object location loc.key.set_instance(tail_instance); - location->set_placement_rule(tail_bucket.placement_rule); + location->set_placement_rule(tail_placement.placement_rule); *location = loc; } diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 3e1c962bc59e82..66bb0b7905e00d 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -80,6 +80,12 @@ void RGWObjManifestRule::dump(Formatter *f) const encode_json("override_prefix", override_prefix, f); } +void rgw_bucket_placement::dump(Formatter *f) const +{ + encode_json("bucket", bucket, f); + encode_json("placement_rule", placement_rule, f); +} + void RGWObjManifest::dump(Formatter *f) const { map::const_iterator iter = objs.begin(); @@ -96,9 +102,9 @@ void RGWObjManifest::dump(Formatter *f) const ::encode_json("head_size", head_size, f); ::encode_json("max_head_size", max_head_size, f); ::encode_json("prefix", prefix, f); - ::encode_json("tail_bucket", tail_bucket, f); ::encode_json("rules", rules, f); ::encode_json("tail_instance", tail_instance, f); + ::encode_json("tail_placement", tail_placement, f); } void rgw_log_entry::dump(Formatter *f) const @@ -799,7 +805,6 @@ void rgw_obj::dump(Formatter *f) const { encode_json("bucket", bucket, f); encode_json("key", key, f); - encode_json("placement_id", placement_id, f); } void RGWDefaultSystemMetaObjInfo::dump(Formatter *f) const { diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 3a4d7b954a01b8..6d9f363354ff56 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -280,7 +280,7 @@ int RGWLC::bucket_lc_process(string& shard_id) RGWObjectCtx rctx(store); rgw_obj obj(bucket_info.bucket, key); RGWObjState *state; - int ret = store->get_obj_state(&rctx, obj, &state, false); + int ret = store->get_obj_state(&rctx, bucket_info, obj, &state, false); if (ret < 0) { return ret; } @@ -330,7 +330,7 @@ int RGWLC::bucket_lc_process(string& shard_id) RGWObjectCtx rctx(store); rgw_obj obj(bucket_info.bucket, key); RGWObjState *state; - int ret = store->get_obj_state(&rctx, obj, &state, false); + int ret = store->get_obj_state(&rctx, bucket_info, obj, &state, false); if (ret < 0) { return ret; } diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index b587f17e011bcf..09a56113212555 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1272,7 +1272,7 @@ int RGWGetObj::get_data_cb(bufferlist& bl, off_t bl_ofs, off_t bl_len) /* garbage collection related handling */ utime_t start_time = ceph_clock_now(s->cct); if (start_time > gc_invalidate_time) { - int r = store->defer_gc(s->obj_ctx, obj); + int r = store->defer_gc(s->obj_ctx, s->bucket_info, obj); if (r < 0) { dout(0) << "WARNING: could not defer gc entry for obj" << dendl; } @@ -2632,7 +2632,7 @@ int RGWPutObjProcessor_Multipart::prepare(RGWRados *store, string *oid_rand) manifest.set_multipart_part_rule(store->ctx()->_conf->rgw_obj_stripe_size, num); - int r = manifest_gen.create_begin(store->ctx(), &manifest, bucket, target_obj); + int r = manifest_gen.create_begin(store->ctx(), &manifest, s->bucket_info.placement_rule, bucket, target_obj); if (r < 0) { return r; } @@ -2721,7 +2721,7 @@ int RGWPutObjProcessor_Multipart::do_complete(size_t accounted_size, rgw_raw_obj raw_meta_obj; - store->obj_to_raw(meta_obj, &raw_meta_obj); + store->obj_to_raw(s->bucket_info.placement_rule, meta_obj, &raw_meta_obj); r = store->omap_set(raw_meta_obj, p, bl); @@ -3543,7 +3543,7 @@ void RGWPutMetadataObject::execute() } } - op_ret = store->set_attrs(s->obj_ctx, obj, attrs, &rmattrs); + op_ret = store->set_attrs(s->obj_ctx, s->bucket_info, obj, attrs, &rmattrs); } int RGWDeleteObj::handle_slo_manifest(bufferlist& bl) @@ -4133,7 +4133,7 @@ void RGWPutACLs::execute() return; attrs[RGW_ATTR_ACL] = bl; - op_ret = store->set_attrs(s->obj_ctx, obj, attrs, NULL); + op_ret = store->set_attrs(s->obj_ctx, s->bucket_info, obj, attrs, NULL); } else { attrs = s->bucket_attrs; attrs[RGW_ATTR_ACL] = bl; @@ -4594,7 +4594,7 @@ static int list_multipart_parts(RGWRados *store, struct req_state *s, obj.set_in_extra_data(true); rgw_raw_obj raw_obj; - store->obj_to_raw(obj, &raw_obj); + store->obj_to_raw(s->bucket_info.placement_rule, obj, &raw_obj); bool sorted_omap = is_v2_upload_id(upload_id) && !assume_unsorted; @@ -5428,7 +5428,7 @@ void RGWSetAttrs::execute() store->set_atomic(s->obj_ctx, obj); if (!s->object.empty()) { - op_ret = store->set_attrs(s->obj_ctx, obj, attrs, nullptr); + op_ret = store->set_attrs(s->obj_ctx, s->bucket_info, obj, attrs, nullptr); } else { for (auto& iter : attrs) { s->bucket_attrs[iter.first] = std::move(iter.second); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index da1dc247918ca1..dfed9b2287fa66 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8111,7 +8111,7 @@ int RGWRados::Object::Delete::delete_obj() } else { rgw_bucket_dir_entry dirent; - int r = store->bi_get_instance(obj, &dirent); + int r = store->bi_get_instance(target->get_bucket_info(), obj, &dirent); if (r < 0) { return r; } @@ -8256,7 +8256,7 @@ int RGWRados::Object::Delete::delete_obj() } int RGWRados::delete_obj(RGWObjectCtx& obj_ctx, - RGWBucketInfo& bucket_info, + const RGWBucketInfo& bucket_info, const rgw_obj& obj, int versioning_status, uint16_t bilog_flags, @@ -8388,7 +8388,7 @@ int RGWRados::get_olh_target_state(RGWObjectCtx& obj_ctx, const RGWBucketInfo& b assert(olh_state->is_olh); rgw_obj target; - int r = RGWRados::follow_olh(obj_ctx, olh_state, obj, &target); /* might return -EAGAIN */ + int r = RGWRados::follow_olh(bucket_info, obj_ctx, olh_state, obj, &target); /* might return -EAGAIN */ if (r < 0) { return r; } @@ -10127,14 +10127,15 @@ int RGWRados::olh_init_modification(const RGWBucketInfo& bucket_info, RGWObjStat return ret; } -int RGWRados::bucket_index_link_olh(RGWObjState& olh_state, const rgw_obj& obj_instance, bool delete_marker, +int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjState& olh_state, const rgw_obj& obj_instance, + bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, real_time unmod_since, bool high_precision_time) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj_instance, &ref); + int r = get_obj_head_ref(bucket_info, obj_instance, &ref); if (r < 0) { return r; } @@ -10163,10 +10164,11 @@ void RGWRados::bucket_index_guard_olh_op(RGWObjState& olh_state, ObjectOperation op.cmpxattr(RGW_ATTR_OLH_ID_TAG, CEPH_OSD_CMPXATTR_OP_EQ, olh_state.olh_tag); } -int RGWRados::bucket_index_unlink_instance(const rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch) +int RGWRados::bucket_index_unlink_instance(const RGWBucketInfo& bucket_info, const rgw_obj& obj_instance, + const string& op_tag, const string& olh_tag, uint64_t olh_epoch) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj_instance, &ref); + int r = get_obj_head_ref(bucket_info, obj_instance, &ref); if (r < 0) { return r; } @@ -10187,12 +10189,13 @@ int RGWRados::bucket_index_unlink_instance(const rgw_obj& obj_instance, const st return 0; } -int RGWRados::bucket_index_read_olh_log(RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver_marker, +int RGWRados::bucket_index_read_olh_log(const RGWBucketInfo& bucket_info, RGWObjState& state, + const rgw_obj& obj_instance, uint64_t ver_marker, map > *log, bool *is_truncated) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj_instance, &ref); + int r = get_obj_head_ref(bucket_info, obj_instance, &ref); if (r < 0) { return r; } @@ -10217,10 +10220,10 @@ int RGWRados::bucket_index_read_olh_log(RGWObjState& state, const rgw_obj& obj_i return 0; } -int RGWRados::bucket_index_trim_olh_log(RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver) +int RGWRados::bucket_index_trim_olh_log(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj_instance, &ref); + int r = get_obj_head_ref(bucket_info, obj_instance, &ref); if (r < 0) { return r; } @@ -10247,10 +10250,10 @@ int RGWRados::bucket_index_trim_olh_log(RGWObjState& state, const rgw_obj& obj_i return 0; } -int RGWRados::bucket_index_clear_olh(RGWObjState& state, const rgw_obj& obj_instance) +int RGWRados::bucket_index_clear_olh(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& obj_instance) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj_instance, &ref); + int r = get_obj_head_ref(bucket_info, obj_instance, &ref); if (r < 0) { return r; } @@ -10275,7 +10278,7 @@ int RGWRados::bucket_index_clear_olh(RGWObjState& state, const rgw_obj& obj_inst return 0; } -int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucketInfo& bucket_info, const rgw_obj& obj, +int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, const RGWBucketInfo& bucket_info, const rgw_obj& obj, bufferlist& olh_tag, map >& log, uint64_t *plast_ver) { @@ -10332,7 +10335,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket } rgw_rados_ref ref; - int r = get_obj_head_ref(obj, &ref); + int r = get_obj_head_ref(bucket_info, obj, &ref); if (r < 0) { return r; } @@ -10371,7 +10374,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket return r; } - r = bucket_index_trim_olh_log(state, obj, last_ver); + r = bucket_index_trim_olh_log(bucket_info, state, obj, last_ver); if (r < 0) { ldout(cct, 0) << "ERROR: could not trim olh log, r=" << r << dendl; return r; @@ -10392,7 +10395,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket /* * only clear if was successful, otherwise we might clobber pending operations on this object */ - r = bucket_index_clear_olh(state, obj); + r = bucket_index_clear_olh(bucket_info, state, obj); if (r < 0) { ldout(cct, 0) << "ERROR: could not clear bucket index olh entries r=" << r << dendl; return r; @@ -10406,14 +10409,14 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket /* * read olh log and apply it */ -int RGWRados::update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, const rgw_obj& obj) +int RGWRados::update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const RGWBucketInfo& bucket_info, const rgw_obj& obj) { map > log; bool is_truncated; uint64_t ver_marker = 0; do { - int ret = bucket_index_read_olh_log(*state, obj, ver_marker, &log, &is_truncated); + int ret = bucket_index_read_olh_log(bucket_info, *state, obj, ver_marker, &log, &is_truncated); if (ret < 0) { return ret; } @@ -10458,7 +10461,7 @@ int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const r } return ret; } - ret = bucket_index_link_olh(*state, target_obj, delete_marker, op_tag, meta, olh_epoch, unmod_since, high_precision_time); + ret = bucket_index_link_olh(bucket_info, *state, target_obj, delete_marker, op_tag, meta, olh_epoch, unmod_since, high_precision_time); if (ret < 0) { ldout(cct, 20) << "bucket_index_link_olh() target_obj=" << target_obj << " delete_marker=" << (int)delete_marker << " returned " << ret << dendl; if (ret == -ECANCELED) { @@ -10519,9 +10522,9 @@ int RGWRados::unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_i string olh_tag(state->olh_tag.c_str(), state->olh_tag.length()); - ret = bucket_index_unlink_instance(target_obj, op_tag, olh_tag, olh_epoch); + ret = bucket_index_unlink_instance(bucket_info, target_obj, op_tag, olh_tag, olh_epoch); if (ret < 0) { - ldout(cct, 20) << "bucket_index_link_olh() target_obj=" << target_obj << " returned " << ret << dendl; + ldout(cct, 20) << "bucket_index_unlink_instance() target_obj=" << target_obj << " returned " << ret << dendl; if (ret == -ECANCELED) { continue; } @@ -10635,7 +10638,7 @@ void RGWRados::check_pending_olh_entries(map& pending_entrie } } -int RGWRados::remove_olh_pending_entries(RGWObjState& state, const rgw_obj& olh_obj, map& pending_attrs) +int RGWRados::remove_olh_pending_entries(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, map& pending_attrs) { ObjectWriteOperation op; @@ -10646,7 +10649,7 @@ int RGWRados::remove_olh_pending_entries(RGWObjState& state, const rgw_obj& olh_ } rgw_rados_ref ref; - int r = get_obj_head_ref(olh_obj, &ref); + int r = get_obj_head_ref(bucket_info, olh_obj, &ref); if (r < 0) { return r; } @@ -10665,7 +10668,7 @@ int RGWRados::remove_olh_pending_entries(RGWObjState& state, const rgw_obj& olh_ return 0; } -int RGWRados::follow_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const rgw_obj& olh_obj, rgw_obj *target) +int RGWRados::follow_olh(const RGWBucketInfo& bucket_info, RGWObjectCtx& obj_ctx, RGWObjState *state, const rgw_obj& olh_obj, rgw_obj *target) { map pending_entries; filter_attrset(state->attrset, RGW_ATTR_OLH_PENDING_PREFIX, &pending_entries); @@ -10674,7 +10677,7 @@ int RGWRados::follow_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const rgw_ob check_pending_olh_entries(pending_entries, &rm_pending_entries); if (!rm_pending_entries.empty()) { - int ret = remove_olh_pending_entries(*state, olh_obj, rm_pending_entries); + int ret = remove_olh_pending_entries(bucket_info, *state, olh_obj, rm_pending_entries); if (ret < 0) { ldout(cct, 20) << "ERROR: rm_pending_entries returned ret=" << ret << dendl; return ret; @@ -10683,16 +10686,7 @@ int RGWRados::follow_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const rgw_ob if (!pending_entries.empty()) { ldout(cct, 20) << __func__ << "(): found pending entries, need to update_olh() on bucket=" << olh_obj.bucket << dendl; - /* we could save a few cpu cycles if we drilled through all the layers and passed the bucket - * info in, but this is supposed to be a rare call and it doesn't seem compelling enough - * for cluttering everything - */ - RGWBucketInfo bucket_info; - int ret = get_bucket_instance_info(obj_ctx, olh_obj.bucket, bucket_info, NULL, NULL); - if (ret < 0) { - ldout(cct, 0) << "ERROR: get_bucket_instance_info() returned " << ret << " olh_obj.bucket=" << olh_obj.bucket << dendl; - } - ret = update_olh(obj_ctx, state, bucket_info, olh_obj); + int ret = update_olh(obj_ctx, state, bucket_info, olh_obj); if (ret < 0) { return ret; } @@ -11570,10 +11564,10 @@ int RGWRados::trim_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, stri cct->_conf->rgw_bucket_index_max_aio)(); } -int RGWRados::bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent) +int RGWRados::bi_get_instance(const RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_bucket_dir_entry *dirent) { rgw_rados_ref ref; - int r = get_obj_head_ref(obj, &ref); + int r = get_obj_head_ref(bucket_info, obj, &ref); if (r < 0) { return r; } @@ -11885,7 +11879,7 @@ int RGWRados::cls_bucket_list(RGWBucketInfo& bucket_info, int shard_id, rgw_obj_ * and if the tags are old we need to do cleanup as well. */ librados::IoCtx sub_ctx; sub_ctx.dup(index_ctx); - r = check_disk_state(sub_ctx, bucket_info.bucket, dirent, dirent, updates[vnames[pos]]); + r = check_disk_state(sub_ctx, bucket_info, dirent, dirent, updates[vnames[pos]]); if (r < 0 && r != -ENOENT) { return r; } @@ -12037,7 +12031,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx, RGWObjState *astate = NULL; RGWObjectCtx rctx(this); - int r = get_obj_state(&rctx, obj, &astate, NULL); + int r = get_obj_state(&rctx, bucket_info, obj, &astate, NULL); if (r < 0) return r; @@ -12838,7 +12832,7 @@ int RGWRados::delete_obj_aio(const rgw_obj& obj, list& handles, bool keep_index_consistent) { rgw_rados_ref ref; - int ret = get_obj_head_ref(obj, &ref); + int ret = get_obj_head_ref(bucket_info, obj, &ref); if (ret < 0) { lderr(cct) << "ERROR: failed to get obj ref with ret=" << ret << dendl; return ret; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 78d52846fbcf92..8fbd083d3bfcb9 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -96,6 +96,8 @@ static inline bool rgw_raw_obj_to_obj(const rgw_bucket& bucket, const rgw_raw_ob struct rgw_bucket_placement { string placement_rule; rgw_bucket bucket; + + void dump(Formatter *f) const; }; class rgw_obj_select { @@ -2606,7 +2608,7 @@ class RGWRados int complete_atomic_modification(); public: - Object(RGWRados *_store, RGWBucketInfo& _bucket_info, RGWObjectCtx& _ctx, const rgw_obj& _obj) : store(_store), bucket_info(_bucket_info), + Object(RGWRados *_store, const RGWBucketInfo& _bucket_info, RGWObjectCtx& _ctx, const rgw_obj& _obj) : store(_store), bucket_info(_bucket_info), ctx(_ctx), obj(_obj), bs(store), state(NULL), versioning_disabled(false), bs_initialized(false) {} @@ -3058,7 +3060,7 @@ class RGWRados /** Delete an object.*/ int delete_obj(RGWObjectCtx& obj_ctx, - RGWBucketInfo& bucket_owner, + const RGWBucketInfo& bucket_owner, const rgw_obj& src_obj, int versioning_status, uint16_t bilog_flags = 0, @@ -3158,27 +3160,28 @@ class RGWRados void bucket_index_guard_olh_op(RGWObjState& olh_state, librados::ObjectOperation& op); int olh_init_modification(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, string *op_tag); int olh_init_modification_impl(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, string *op_tag); - int bucket_index_link_olh(RGWObjState& olh_state, const rgw_obj& obj_instance, bool delete_marker, + int bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjState& olh_state, + const rgw_obj& obj_instance, bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time); - int bucket_index_unlink_instance(const rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch); - int bucket_index_read_olh_log(RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver_marker, + int bucket_index_unlink_instance(const RGWBucketInfo& bucket_info, const rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch); + int bucket_index_read_olh_log(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& obj_instance, uint64_t ver_marker, map > *log, bool *is_truncated); - int bucket_index_trim_olh_log(RGWObjState& obj_state, const rgw_obj& obj_instance, uint64_t ver); - int bucket_index_clear_olh(RGWObjState& state, const rgw_obj& obj_instance); - int apply_olh_log(RGWObjectCtx& ctx, RGWObjState& obj_state, RGWBucketInfo& bucket_info, const rgw_obj& obj, + int bucket_index_trim_olh_log(const RGWBucketInfo& bucket_info, RGWObjState& obj_state, const rgw_obj& obj_instance, uint64_t ver); + int bucket_index_clear_olh(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& obj_instance); + int apply_olh_log(RGWObjectCtx& ctx, RGWObjState& obj_state, const RGWBucketInfo& bucket_info, const rgw_obj& obj, bufferlist& obj_tag, map >& log, uint64_t *plast_ver); - int update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, const rgw_obj& obj); + int update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, const RGWBucketInfo& bucket_info, const rgw_obj& obj); int set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta, uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time); int unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& target_obj, uint64_t olh_epoch); void check_pending_olh_entries(map& pending_entries, map *rm_pending_entries); - int remove_olh_pending_entries(RGWObjState& state, const rgw_obj& olh_obj, map& pending_attrs); - int follow_olh(RGWObjectCtx& ctx, RGWObjState *state, const rgw_obj& olh_obj, rgw_obj *target); + int remove_olh_pending_entries(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, map& pending_attrs); + int follow_olh(const RGWBucketInfo& bucket_info, RGWObjectCtx& ctx, RGWObjState *state, const rgw_obj& olh_obj, rgw_obj *target); int get_olh(const RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWOLHInfo *olh); void gen_rand_obj_instance_name(rgw_obj *target); @@ -3270,7 +3273,7 @@ class RGWRados int trim_bi_log_entries(RGWBucketInfo& bucket_info, int shard_id, string& marker, string& end_marker); int get_bi_log_status(RGWBucketInfo& bucket_info, int shard_id, map& max_marker); - int bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent); + int bi_get_instance(const RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_bucket_dir_entry *dirent); int bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry); void bi_put(librados::ObjectWriteOperation& op, BucketShard& bs, rgw_cls_bi_entry& entry); int bi_put(BucketShard& bs, rgw_cls_bi_entry& entry); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 2415b622a71eb0..27dbb3ddecbf39 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1797,7 +1797,7 @@ bool RGWSwiftWebsiteHandler::is_web_dir() const obj_ctx.obj.set_prefetch_data(obj); RGWObjState* state = nullptr; - if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) { + if (store->get_obj_state(&obj_ctx, s->bucket_info, obj, &state, false) < 0) { return false; } @@ -1827,7 +1827,7 @@ bool RGWSwiftWebsiteHandler::is_index_present(const std::string& index) obj_ctx.obj.set_prefetch_data(obj); RGWObjState* state = nullptr; - if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) { + if (store->get_obj_state(&obj_ctx, s->bucket_info, obj, &state, false) < 0) { return false; } diff --git a/src/rgw/rgw_torrent.cc b/src/rgw/rgw_torrent.cc index 8333bb902eb421..d8f9c7dbcfdeed 100644 --- a/src/rgw/rgw_torrent.cc +++ b/src/rgw/rgw_torrent.cc @@ -268,7 +268,7 @@ int seed::save_torrent_file() rgw_obj obj(s->bucket, s->object.name); rgw_raw_obj raw_obj; - store->obj_to_raw(obj, &raw_obj); + store->obj_to_raw(s->bucket_info.placement_rule, obj, &raw_obj); op_ret = store->omap_set(raw_obj, key, bl); if (op_ret < 0)