++miter;
}
- rgw_rados_ref ref;
- ret = get_raw_obj_ref(dpp, miter.get_location().get_raw_obj(store), &ref);
- if (ret < 0) {
- return ret;
- }
-
bufferlist first_chunk;
const bool copy_itself = (dest_obj->get_obj() == src_obj->get_obj());
append_rand_alpha(cct, tag, tag, 32);
}
+ std::unique_ptr<rgw::Aio> aio;
+ rgw::AioResultList all_results;
if (!copy_itself) {
+ aio = rgw::make_throttle(cct->_conf->rgw_max_copy_obj_concurrent_io, y);
attrs.erase(RGW_ATTR_TAIL_TAG);
manifest = *amanifest;
const rgw_bucket_placement& tail_placement = manifest.get_tail_placement();
ObjectWriteOperation op;
ref_tag = tag + '\0';
cls_refcount_get(op, ref_tag, true);
- const rgw_raw_obj& loc = miter.get_location().get_raw_obj(store);
- auto& ioctx = ref.pool.ioctx();
- ioctx.locator_set_key(loc.loc);
+ auto obj = svc.rados->obj(miter.get_location().get_raw_obj(store));
+ ret = obj.open(dpp);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << "failed to open rados context for " << obj << dendl;
+ goto done_ret;
+ }
- ret = rgw_rados_operate(dpp, ioctx, loc.oid, &op, null_yield);
+ static constexpr uint64_t cost = 1; // 1 throttle unit per request
+ static constexpr uint64_t id = 0; // ids unused
+ rgw::AioResultList completed = aio->get(obj, rgw::Aio::librados_op(std::move(op), y), cost, id);
+ ret = rgw::check_for_errors(completed);
+ all_results.splice(all_results.end(), completed);
if (ret < 0) {
+ ldpp_dout(dpp, 0) << "ERROR: failed to copy obj=" << obj << ", the error code = " << ret << dendl;
goto done_ret;
}
+ }
- ref_objs.push_back(loc);
+ rgw::AioResultList completed = aio->drain();
+ ret = rgw::check_for_errors(completed);
+ all_results.splice(all_results.end(), completed);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << "ERROR: failed to drain ios, the error code = " << ret <<dendl;
+ goto done_ret;
}
pmanifest = &manifest;
done_ret:
if (!copy_itself) {
- vector<rgw_raw_obj>::iterator riter;
+
+ /* wait all pending op done */
+ rgw::AioResultList completed = aio->drain();
+ all_results.splice(all_results.end(), completed);
/* rollback reference */
string ref_tag = tag + '\0';
- for (riter = ref_objs.begin(); riter != ref_objs.end(); ++riter) {
+ int ret2 = 0;
+ for (auto& r : all_results) {
+ if (r.result < 0) {
+ continue; // skip errors
+ }
ObjectWriteOperation op;
cls_refcount_put(op, ref_tag, true);
- ref.pool.ioctx().locator_set_key(riter->loc);
-
- int r = rgw_rados_operate(dpp, ref.pool.ioctx(), riter->oid, &op, null_yield);
- if (r < 0) {
- ldpp_dout(dpp, 0) << "ERROR: cleanup after error failed to drop reference on obj=" << *riter << dendl;
+ static constexpr uint64_t cost = 1; // 1 throttle unit per request
+ static constexpr uint64_t id = 0; // ids unused
+ rgw::AioResultList completed = aio->get(r.obj, rgw::Aio::librados_op(std::move(op), y), cost, id);
+ ret2 = rgw::check_for_errors(completed);
+ if (ret2 < 0) {
+ ldpp_dout(dpp, 0) << "ERROR: cleanup after error failed to drop reference on obj=" << r.obj << dendl;
}
}
+ completed = aio->drain();
+ ret2 = rgw::check_for_errors(completed);
+ if (ret2 < 0) {
+ ldpp_dout(dpp, 0) << "ERROR: failed to drain rollback ios, the error code = " << ret2 <<dendl;
+ }
}
return ret;
}