From b4f3de0475afb231af2d5c99add5c155ff257ade Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 18 Nov 2014 11:32:37 -0800 Subject: [PATCH] rgw: Object::Read operations should use state->obj and not the provided obj, as it might have been an olh, therefore we have prepare() that sets the state.obj as the effective object. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 25 ++++++++++++------------- src/rgw/rgw_rados.h | 1 + 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e30bb62c8ed82..cc61414057e18 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4540,7 +4540,6 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj, int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); CephContext *cct = store->ctx(); bufferlist etag; @@ -4551,13 +4550,8 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) map::iterator iter; - int r = store->get_obj_ioctx(obj, &state.io_ctx); - if (r < 0) { - return r; - } - RGWObjState *astate; - r = source->get_state(&astate, true); + int r = source->get_state(&astate, true); if (r < 0) return r; @@ -4565,6 +4559,13 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) return -ENOENT; } + state.obj = astate->obj; + + r = store->get_obj_ioctx(state.obj, &state.io_ctx); + if (r < 0) { + return r; + } + if (params.attrs) { *params.attrs = astate->attrset; if (cct->_conf->subsys.should_gather(ceph_subsys_rgw, 20)) { @@ -4770,12 +4771,11 @@ int RGWRados::Bucket::UpdateIndex::cancel() int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); CephContext *cct = store->ctx(); rgw_bucket bucket; std::string oid, key; - rgw_obj read_obj = obj; + rgw_obj read_obj = state.obj; uint64_t read_ofs = ofs; uint64_t len, read_len; bool reading_from_head = true; @@ -4787,7 +4787,7 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) uint64_t max_chunk_size; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(state.obj, bucket, oid, key); RGWObjState *astate; int r = source->get_state(&astate, true); @@ -4807,7 +4807,7 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) read_obj = iter.get_location(); len = min(len, iter.get_stripe_size() - (ofs - stripe_ofs)); read_ofs = iter.location_ofs() + (ofs - stripe_ofs); - reading_from_head = (read_obj == obj); + reading_from_head = (read_obj == state.obj); if (!reading_from_head) { get_obj_bucket_and_oid_loc(read_obj, bucket, oid, key); @@ -5307,7 +5307,6 @@ done_err: int RGWRados::Object::Read::iterate(int64_t ofs, int64_t end, RGWGetDataCB *cb) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); CephContext *cct = store->ctx(); struct get_obj_data *data = new get_obj_data(cct); @@ -5319,7 +5318,7 @@ int RGWRados::Object::Read::iterate(int64_t ofs, int64_t end, RGWGetDataCB *cb) data->io_ctx.dup(state.io_ctx); data->client_cb = cb; - int r = store->iterate_obj(obj_ctx, obj, ofs, end, cct->_conf->rgw_get_obj_max_req_size, _get_obj_iterate_cb, (void *)data); + int r = store->iterate_obj(obj_ctx, state.obj, ofs, end, cct->_conf->rgw_get_obj_max_req_size, _get_obj_iterate_cb, (void *)data); if (r < 0) { data->cancel_all_io(); goto done; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index a21e4c52e9496..2aca4b1c52507 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1411,6 +1411,7 @@ public: struct GetObjState { librados::IoCtx io_ctx; + rgw_obj obj; } state; struct ConditionParams { -- 2.39.5