From d32d94548a05d35483b0f8354cdd2afbeb62109c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 7 Oct 2014 15:34:29 -0700 Subject: [PATCH] rgw: change RGWRados::get_attr() This is an interim fix, will need to make it work similarly to the other calls. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_bucket.cc | 3 ++- src/rgw/rgw_op.cc | 14 +++++++------- src/rgw/rgw_rados.cc | 27 ++++++++++++--------------- src/rgw/rgw_rados.h | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index fd7b075aeed75..35cf784760127 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -802,7 +802,8 @@ int RGWBucket::get_policy(RGWBucketAdminOpState& op_state, ostream& o) if (!object_name.empty()) { bufferlist bl; rgw_obj obj(bucket, object_name); - int ret = store->get_attr(NULL, obj, RGW_ATTR_ACL, bl); + RGWRados::ObjectCtx obj_ctx(store); + int ret = store->get_attr(obj_ctx, obj, RGW_ATTR_ACL, bl); if (ret < 0) return ret; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 95a5dda8c16e4..13a33f9b58ce2 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -203,14 +203,14 @@ static int get_bucket_policy_from_attr(CephContext *cct, RGWRados *store, void * return 0; } -static int get_obj_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx, +static int get_obj_policy_from_attr(CephContext *cct, RGWRados *store, RGWRados::ObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, map& bucket_attrs, RGWAccessControlPolicy *policy, rgw_obj& obj) { bufferlist bl; int ret = 0; - ret = store->get_attr(ctx, obj, RGW_ATTR_ACL, bl); + ret = store->get_attr(obj_ctx, obj, RGW_ATTR_ACL, bl); if (ret >= 0) { ret = decode_policy(cct, bl, policy); if (ret < 0) @@ -250,7 +250,7 @@ static int get_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx, return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, policy, instance_obj); } - return get_obj_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, + return get_obj_policy_from_attr(cct, store, *(RGWRados::ObjectCtx *)ctx, bucket_info, bucket_attrs, policy, obj); } @@ -632,8 +632,8 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, RGWObjEnt& ent, RGWAc { ldout(s->cct, 20) << "user manifest obj=" << ent.key.name << "[" << ent.key.instance << "]" << dendl; - uint64_t cur_ofs = start_ofs; - uint64_t cur_end = end_ofs; + int64_t cur_ofs = start_ofs; + int64_t cur_end = end_ofs; utime_t start_time = s->time; rgw_obj part(bucket, ent.key); @@ -869,7 +869,7 @@ void RGWGetObj::execute() map::iterator attr_iter; perfcounter->inc(l_rgw_get); - uint64_t new_ofs, new_end; + int64_t new_ofs, new_end; RGWRados::Object op_target(store, *(RGWRados::ObjectCtx *)s->obj_ctx, obj); RGWRados::Object::Read read_op(&op_target); @@ -918,7 +918,7 @@ void RGWGetObj::execute() perfcounter->inc(l_rgw_get_b, end - ofs); - ret = store->get_obj_iterate(s->obj_ctx, &handle, obj, ofs, end, &cb); + ret = store->get_obj_iterate(s->obj_ctx, read_op, obj, ofs, end, &cb); perfcounter->tinc(l_rgw_get_lat, (ceph_clock_now(s->cct) - start_time)); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c944087c21dbe..67372bdf3bc62 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4196,7 +4196,7 @@ int RGWRados::get_obj_state(ObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, * dest: bufferlist to store the result in * Returns: 0 on success, -ERR# otherwise. */ -int RGWRados::get_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& dest) +int RGWRados::get_attr(ObjectCtx& obj_ctx, rgw_obj& obj, const char *name, bufferlist& dest) { rgw_rados_ref ref; rgw_bucket bucket; @@ -4204,19 +4204,16 @@ int RGWRados::get_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& de if (r < 0) { return r; } - ObjectCtx *rctx = static_cast(ctx); - if (rctx) { - RGWObjState *state; - r = get_obj_state(rctx, obj, &state, NULL); - if (r < 0) - return r; - if (!state->exists) - return -ENOENT; - if (state->get_attr(name, dest)) - return 0; - return -ENODATA; - } + RGWObjState *state; + r = get_obj_state(&obj_ctx, obj, &state, NULL); + if (r < 0) + return r; + if (!state->exists) + return -ENOENT; + if (state->get_attr(name, dest)) + return 0; + return -ENODATA; ObjectReadOperation op; @@ -4531,7 +4528,7 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) } } if (conds.if_match || conds.if_nomatch) { - r = get_attr(source->get_ctx(), obj, RGW_ATTR_ETAG, etag); + r = store->get_attr(source->get_ctx(), obj, RGW_ATTR_ETAG, etag); if (r < 0) return r; @@ -4694,7 +4691,7 @@ int RGWRados::prepare_get_obj(void *ctx, rgw_obj& obj, } } if (if_match || if_nomatch) { - r = get_attr(rctx, obj, RGW_ATTR_ETAG, etag); + r = get_attr(*rctx, obj, RGW_ATTR_ETAG, etag); if (r < 0) goto done_err; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 628aa13f79c0b..cf87c2ceacbbd 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1585,7 +1585,7 @@ public: * dest: bufferlist to store the result in * Returns: 0 on success, -ERR# otherwise. */ - virtual int get_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& dest); + virtual int get_attr(RGWRados::ObjectCtx& obj_ctx, rgw_obj& obj, const char *name, bufferlist& dest); /** * Set an attr on an object. -- 2.39.5