From a4d3977cfacc5eb0de16618f2c957bb417505597 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 3 Dec 2018 16:32:08 -0500 Subject: [PATCH] rgw: rgw_rados_ref contains rgw_raw_obj rgw_rados_ref duplicated each of the fields from rgw_raw_obj Signed-off-by: Casey Bodley --- src/rgw/rgw_cr_rados.cc | 12 ++--- src/rgw/rgw_rados.cc | 83 ++++++++++++++++------------------ src/rgw/rgw_sync_log_trim.cc | 20 ++++---- src/rgw/services/svc_notify.cc | 3 +- src/rgw/services/svc_rados.cc | 25 +++++----- src/rgw/services/svc_rados.h | 4 +- 6 files changed, 71 insertions(+), 76 deletions(-) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 033c372ed3f..4fa3499f2e2 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -197,7 +197,7 @@ int RGWAsyncLockSystemObj::_send_request() l.set_cookie(cookie); l.set_may_renew(true); - return l.lock_exclusive(&ref.ioctx, ref.oid); + return l.lock_exclusive(&ref.ioctx, ref.obj.oid); } RGWAsyncLockSystemObj::RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, @@ -223,7 +223,7 @@ int RGWAsyncUnlockSystemObj::_send_request() l.set_cookie(cookie); - return l.unlock(&ref.ioctx, ref.oid); + return l.unlock(&ref.ioctx, ref.obj.oid); } RGWAsyncUnlockSystemObj::RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, @@ -266,7 +266,7 @@ int RGWRadosSetOmapKeysCR::send_request() op.omap_set(entries); cn = stack->create_completion_notifier(); - return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op); + return ref.ioctx.aio_operate(ref.obj.oid, cn->completion(), &op); } int RGWRadosSetOmapKeysCR::request_complete() @@ -304,7 +304,7 @@ int RGWRadosGetOmapKeysCR::send_request() { op.omap_get_keys2(marker, max_entries, &result->entries, &result->more, nullptr); cn = stack->create_completion_notifier(result); - return result->ref.ioctx.aio_operate(result->ref.oid, cn->completion(), &op, NULL); + return result->ref.ioctx.aio_operate(result->ref.obj.oid, cn->completion(), &op, NULL); } int RGWRadosGetOmapKeysCR::request_complete() @@ -339,7 +339,7 @@ int RGWRadosRemoveOmapKeysCR::send_request() { op.omap_rm_keys(keys); cn = stack->create_completion_notifier(); - return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op); + return ref.ioctx.aio_operate(ref.obj.oid, cn->completion(), &op); } int RGWRadosRemoveOmapKeysCR::request_complete() @@ -884,7 +884,7 @@ int RGWRadosNotifyCR::send_request() set_status() << "sending request"; cn = stack->create_completion_notifier(); - return ref.ioctx.aio_notify(ref.oid, cn->completion(), request, + return ref.ioctx.aio_notify(ref.obj.oid, cn->completion(), request, timeout_ms, response); } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 34faff5dd1f..f2561f88af0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2898,7 +2898,7 @@ int RGWRados::get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj int RGWRados::get_obj_head_ref(const RGWBucketInfo& bucket_info, const rgw_obj& obj, rgw_rados_ref *ref) { - get_obj_bucket_and_oid_loc(obj, ref->oid, ref->key); + get_obj_bucket_and_oid_loc(obj, ref->obj.oid, ref->obj.loc); rgw_pool pool; if (!get_obj_data_pool(bucket_info.placement_rule, obj, &pool)) { @@ -2911,29 +2911,26 @@ int RGWRados::get_obj_head_ref(const RGWBucketInfo& bucket_info, const rgw_obj& return r; } - ref->ioctx.locator_set_key(ref->key); + ref->ioctx.locator_set_key(ref->obj.loc); return 0; } int RGWRados::get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref) { - ref->oid = obj.oid; - ref->key = obj.loc; + ref->obj = obj; int r; - if (ref->oid.empty()) { - ref->oid = obj.pool.to_str(); - ref->pool = svc.zone->get_zone_params().domain_root; - } else { - ref->pool = obj.pool; + if (ref->obj.oid.empty()) { + ref->obj.oid = obj.pool.to_str(); + ref->obj.pool = svc.zone->get_zone_params().domain_root; } - r = open_pool_ctx(ref->pool, ref->ioctx); + r = open_pool_ctx(ref->obj.pool, ref->ioctx); if (r < 0) return r; - ref->ioctx.locator_set_key(ref->key); + ref->ioctx.locator_set_key(ref->obj.loc); return 0; } @@ -3631,7 +3628,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si } tracepoint(rgw_rados, operate_enter, req_id.c_str()); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); tracepoint(rgw_rados, operate_exit, req_id.c_str()); if (r < 0) { /* we can expect to get -ECANCELED if object was replaced under, or -ENOENT if was removed, or -EEXIST if it did not exist @@ -5366,7 +5363,7 @@ int RGWRados::Object::Delete::delete_obj() return r; store->remove_rgw_head_obj(op); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); /* raced with another operation, object state is indeterminate */ const bool need_invalidate = (r == -ECANCELED); @@ -5436,7 +5433,7 @@ int RGWRados::delete_raw_obj(const rgw_raw_obj& obj) ObjectWriteOperation op; op.remove(); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); if (r < 0) return r; @@ -6048,7 +6045,7 @@ int RGWRados::set_attrs(void *ctx, const RGWBucketInfo& bucket_info, rgw_obj& ob real_time mtime = real_clock::now(); struct timespec mtime_ts = real_clock::to_timespec(mtime); op.mtime2(&mtime_ts); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); if (state) { if (r >= 0) { bufferlist acl_bl = attrs[RGW_ATTR_ACL]; @@ -6691,7 +6688,7 @@ int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, return r; } - return ref.ioctx.operate(ref.oid, op); + return ref.ioctx.operate(ref.obj.oid, op); } int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, ObjectReadOperation *op) @@ -6704,7 +6701,7 @@ int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, bufferlist outbl; - return ref.ioctx.operate(ref.oid, op, &outbl); + return ref.ioctx.operate(ref.obj.oid, op, &outbl); } int RGWRados::olh_init_modification_impl(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, string *op_tag) @@ -7137,7 +7134,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, const RGW } /* update olh object */ - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); if (r == -ECANCELED) { r = 0; } @@ -7160,7 +7157,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, const RGW cls_obj_check_prefix_exist(rm_op, RGW_ATTR_OLH_PENDING_PREFIX, true); /* fail if found one of these, pending modification */ rm_op.remove(); - r = ref.ioctx.operate(ref.oid, &rm_op); + r = ref.ioctx.operate(ref.obj.oid, &rm_op); if (r == -ECANCELED) { return 0; /* someone else won this race */ } else { @@ -7417,7 +7414,7 @@ int RGWRados::remove_olh_pending_entries(const RGWBucketInfo& bucket_info, RGWOb } /* update olh object */ - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); if (r == -ENOENT || r == -ECANCELED) { /* raced with some other change, shouldn't sweat about it */ r = 0; @@ -7502,7 +7499,7 @@ int RGWRados::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, op.read(0, cct->_conf->rgw_max_chunk_size, first_chunk, NULL); } bufferlist outbl; - r = ref.ioctx.operate(ref.oid, &op, &outbl); + r = ref.ioctx.operate(ref.obj.oid, &op, &outbl); if (epoch) { *epoch = ref.ioctx.get_last_version(); @@ -8083,7 +8080,7 @@ int RGWRados::append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl) librados::Rados *rad = get_rados_handle(); librados::AioCompletion *completion = rad->aio_create_completion(NULL, NULL, NULL); - r = ref.ioctx.aio_append(ref.oid, completion, bl, size); + r = ref.ioctx.aio_append(ref.obj.oid, completion, bl, size); completion->release(); return r; } @@ -8919,7 +8916,7 @@ int RGWRados::cls_obj_usage_log_add(const string& oid, ObjectWriteOperation op; cls_rgw_usage_log_add(op, info); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); return r; } @@ -8938,7 +8935,7 @@ int RGWRados::cls_obj_usage_log_read(const string& oid, const string& user, cons *is_truncated = false; - r = cls_rgw_usage_log_read(ref.ioctx, ref.oid, user, bucket, start_epoch, end_epoch, + r = cls_rgw_usage_log_read(ref.ioctx, ref.obj.oid, user, bucket, start_epoch, end_epoch, max_entries, read_iter, usage, is_truncated); return r; @@ -8955,7 +8952,7 @@ int RGWRados::cls_obj_usage_log_trim(const string& oid, const string& user, cons return r; } - r = cls_rgw_usage_log_trim(ref.ioctx, ref.oid, user, bucket, start_epoch, end_epoch); + r = cls_rgw_usage_log_trim(ref.ioctx, ref.obj.oid, user, bucket, start_epoch, end_epoch); return r; } @@ -8970,7 +8967,7 @@ int RGWRados::cls_obj_usage_log_clear(string& oid) } librados::ObjectWriteOperation op; cls_rgw_usage_log_clear(op); - r = ref.ioctx.operate(ref.oid, &op); + r = ref.ioctx.operate(ref.obj.oid, &op); return r; } @@ -9171,7 +9168,7 @@ int RGWRados::cls_user_get_header(const string& user_id, cls_user_header *header int rc; ::cls_user_get_header(op, header, &rc); bufferlist ibl; - r = ref.ioctx.operate(ref.oid, &op, &ibl); + r = ref.ioctx.operate(ref.obj.oid, &op, &ibl); if (r < 0) return r; if (rc < 0) @@ -9194,7 +9191,7 @@ int RGWRados::cls_user_reset_stats(const string& user_id) librados::ObjectWriteOperation op; ::cls_user_reset_stats(op); - return ref.ioctx.operate(ref.oid, &op); + return ref.ioctx.operate(ref.obj.oid, &op); } int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_CB *ctx) @@ -9209,7 +9206,7 @@ int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_ return r; } - r = ::cls_user_get_header_async(ref.ioctx, ref.oid, ctx); + r = ::cls_user_get_header_async(ref.ioctx, ref.obj.oid, ctx); if (r < 0) return r; @@ -9299,7 +9296,7 @@ int RGWRados::cls_user_list_buckets(rgw_raw_obj& obj, cls_user_bucket_list(op, in_marker, end_marker, max_entries, entries, out_marker, truncated, &rc); bufferlist ibl; - r = ref.ioctx.operate(ref.oid, &op, &ibl); + r = ref.ioctx.operate(ref.obj.oid, &op, &ibl); if (r < 0) return r; if (rc < 0) @@ -9318,7 +9315,7 @@ int RGWRados::cls_user_update_buckets(rgw_raw_obj& obj, listctx()) << "Failed to watch " << ref.obj << " with " << cpp_strerror(-r) << dendl; ref.ioctx.close(); return r; } - ldout(store->ctx(), 10) << "Watching " << ref.oid << dendl; + ldout(store->ctx(), 10) << "Watching " << ref.obj.oid << dendl; return 0; } int restart() { int r = ref.ioctx.unwatch2(handle); if (r < 0) { - lderr(store->ctx()) << "Failed to unwatch on " << ref.oid + lderr(store->ctx()) << "Failed to unwatch on " << ref.obj << " with " << cpp_strerror(-r) << dendl; } - r = ref.ioctx.watch2(ref.oid, &handle, this); + r = ref.ioctx.watch2(ref.obj.oid, &handle, this); if (r < 0) { - lderr(store->ctx()) << "Failed to restart watch on " << ref.oid + lderr(store->ctx()) << "Failed to restart watch on " << ref.obj << " with " << cpp_strerror(-r) << dendl; ref.ioctx.close(); } @@ -323,7 +323,7 @@ class BucketTrimWatcher : public librados::WatchCtx2 { } catch (const buffer::error& e) { lderr(store->ctx()) << "Failed to decode notification: " << e.what() << dendl; } - ref.ioctx.notify_ack(ref.oid, notify_id, cookie, reply); + ref.ioctx.notify_ack(ref.obj.oid, notify_id, cookie, reply); } /// reestablish the watch if it gets disconnected @@ -332,7 +332,7 @@ class BucketTrimWatcher : public librados::WatchCtx2 { return; } if (err == -ENOTCONN) { - ldout(store->ctx(), 4) << "Disconnected watch on " << ref.oid << dendl; + ldout(store->ctx(), 4) << "Disconnected watch on " << ref.obj << dendl; restart(); } } diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index c34c1578bd6..27a5a169fa9 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -357,7 +357,8 @@ int RGWSI_Notify::distribute(const string& key, bufferlist& bl) { RGWSI_RADOS::Obj notify_obj = pick_control_obj(key); - ldout(cct, 10) << "distributing notification oid=" << notify_obj.get_ref().oid << " bl.length()=" << bl.length() << dendl; + ldout(cct, 10) << "distributing notification oid=" << notify_obj.get_ref().obj + << " bl.length()=" << bl.length() << dendl; return robust_notify(notify_obj, bl); } diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index e31378cb304..db0855b197b 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -133,21 +133,20 @@ int RGWSI_RADOS::pool_iterate(librados::IoCtx& io_ctx, return objs.size(); } + void RGWSI_RADOS::Obj::init(const rgw_raw_obj& obj) { - ref.oid = obj.oid; - ref.key = obj.loc; - ref.pool = obj.pool; + ref.obj = obj; } int RGWSI_RADOS::Obj::open() { - int r = rados_svc->open_pool_ctx(ref.pool, ref.ioctx, rados_handle); + int r = rados_svc->open_pool_ctx(ref.obj.pool, ref.ioctx, rados_handle); if (r < 0) { return r; } - ref.ioctx.locator_set_key(ref.key); + ref.ioctx.locator_set_key(ref.obj.loc); return 0; } @@ -155,34 +154,34 @@ int RGWSI_RADOS::Obj::open() int RGWSI_RADOS::Obj::operate(librados::ObjectWriteOperation *op, optional_yield y) { - return rgw_rados_operate(ref.ioctx, ref.oid, op, y); + return rgw_rados_operate(ref.ioctx, ref.obj.oid, op, y); } int RGWSI_RADOS::Obj::operate(librados::ObjectReadOperation *op, bufferlist *pbl, optional_yield y) { - return rgw_rados_operate(ref.ioctx, ref.oid, op, pbl, y); + return rgw_rados_operate(ref.ioctx, ref.obj.oid, op, pbl, y); } int RGWSI_RADOS::Obj::aio_operate(librados::AioCompletion *c, librados::ObjectWriteOperation *op) { - return ref.ioctx.aio_operate(ref.oid, c, op); + return ref.ioctx.aio_operate(ref.obj.oid, c, op); } int RGWSI_RADOS::Obj::aio_operate(librados::AioCompletion *c, librados::ObjectReadOperation *op, bufferlist *pbl) { - return ref.ioctx.aio_operate(ref.oid, c, op, pbl); + return ref.ioctx.aio_operate(ref.obj.oid, c, op, pbl); } int RGWSI_RADOS::Obj::watch(uint64_t *handle, librados::WatchCtx2 *ctx) { - return ref.ioctx.watch2(ref.oid, handle, ctx); + return ref.ioctx.watch2(ref.obj.oid, handle, ctx); } int RGWSI_RADOS::Obj::aio_watch(librados::AioCompletion *c, uint64_t *handle, librados::WatchCtx2 *ctx) { - return ref.ioctx.aio_watch(ref.oid, c, handle, ctx); + return ref.ioctx.aio_watch(ref.obj.oid, c, handle, ctx); } int RGWSI_RADOS::Obj::unwatch(uint64_t handle) @@ -194,14 +193,14 @@ int RGWSI_RADOS::Obj::notify(bufferlist& bl, uint64_t timeout_ms, bufferlist *pbl) { - return ref.ioctx.notify2(ref.oid, bl, timeout_ms, pbl); + return ref.ioctx.notify2(ref.obj.oid, bl, timeout_ms, pbl); } void RGWSI_RADOS::Obj::notify_ack(uint64_t notify_id, uint64_t cookie, bufferlist& bl) { - ref.ioctx.notify_ack(ref.oid, notify_id, cookie, bl); + ref.ioctx.notify_ack(ref.obj.oid, notify_id, cookie, bl); } uint64_t RGWSI_RADOS::Obj::get_last_version() diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index 4d242a75c16..90b421e68d9 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -23,9 +23,7 @@ struct RGWAccessListFilterPrefix : public RGWAccessListFilter { }; struct rgw_rados_ref { - rgw_pool pool; - string oid; - string key; + rgw_raw_obj obj; librados::IoCtx ioctx; }; -- 2.39.5