From: Shilpa Jagannath Date: Fri, 19 Jul 2019 09:31:08 +0000 (+0530) Subject: Minor fixes. X-Git-Tag: v15.1.0~1944^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4eeb9d9526d31e52de2699d927cb49add2adbb91;p=ceph.git Minor fixes. Signed-off-by: Shilpa Jagannath --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 49590824c35..2d365f98b1f 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -243,7 +243,7 @@ int rgw_bucket_chown(RGWRados* const store, RGWUserInfo& user_info, RGWBucketInf do { objs.clear(); - int ret = list_op.list_objects(max_entries, &objs, &common_prefixes, &is_truncated); + int ret = list_op.list_objects(max_entries, &objs, &common_prefixes, &is_truncated, null_yield); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: list objects failed: " << cpp_strerror(-ret) << dendl; return ret; @@ -254,8 +254,12 @@ int rgw_bucket_chown(RGWRados* const store, RGWUserInfo& user_info, RGWBucketInf for (const auto& obj : objs) { - const rgw_obj r_obj(bucket_info.bucket, obj.key); - ret = get_obj_attrs(store, obj_ctx, bucket_info, r_obj, attrs); + rgw_obj r_obj(bucket_info.bucket, obj.key); + RGWRados::Object op_target(store, bucket_info, obj_ctx, r_obj); + RGWRados::Object::Read read_op(&op_target); + + read_op.params.attrs = &attrs; + ret = read_op.prepare(null_yield); if (ret < 0){ ldout(store->ctx(), 0) << "ERROR: failed to read object " << obj.key.name << cpp_strerror(-ret) << dendl; continue; @@ -295,7 +299,8 @@ int rgw_bucket_chown(RGWRados* const store, RGWUserInfo& user_info, RGWBucketInf bl.clear(); encode(policy, bl); - ret = modify_obj_attr(store, obj_ctx, bucket_info, r_obj, RGW_ATTR_ACL, bl); + obj_ctx.set_atomic(r_obj); + ret = store->set_attr(&obj_ctx, bucket_info, r_obj, RGW_ATTR_ACL, bl); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: modify attr failed " << cpp_strerror(-ret) << dendl; return ret; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 0f2d53a265e..6a2189d4a32 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -321,9 +321,9 @@ vector get_iam_user_policy_from_attr(CephContext* cct, return policies; } -int get_obj_attrs(RGWRados *store, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, map& attrs) +static int get_obj_attrs(RGWRados *store, struct req_state *s, const rgw_obj& obj, map& attrs) { - RGWRados::Object op_target(store, bucket_info, obj_ctx, obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), obj); RGWRados::Object::Read read_op(&op_target); read_op.params.attrs = &attrs; @@ -440,10 +440,10 @@ static int get_multipart_info(RGWRados *store, struct req_state *s, return get_multipart_info(store, s, meta_obj, policy, attrs, upload_info); } -int modify_obj_attr(RGWRados *store, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, const char* attr_name, bufferlist& attr_val) +static int modify_obj_attr(RGWRados *store, struct req_state *s, const rgw_obj& obj, const char* attr_name, bufferlist& attr_val) { map attrs; - RGWRados::Object op_target(store, bucket_info, obj_ctx, obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), obj); RGWRados::Object::Read read_op(&op_target); read_op.params.attrs = &attrs; @@ -813,7 +813,7 @@ static int rgw_iam_add_tags_from_bl(struct req_state* s, bufferlist& bl){ static int rgw_iam_add_existing_objtags(RGWRados* store, struct req_state* s, rgw_obj& obj, std::uint64_t action){ map attrs; store->set_atomic(s->obj_ctx, obj); - int op_ret = get_obj_attrs(store, *(s->obj_ctx), s->bucket_info, obj, attrs); + int op_ret = get_obj_attrs(store, s, obj, attrs); if (op_ret < 0) return op_ret; auto tags = attrs.find(RGW_ATTR_TAGS); @@ -1045,7 +1045,7 @@ void RGWGetObjTags::execute() store->set_atomic(s->obj_ctx, obj); - op_ret = get_obj_attrs(store, *(s->obj_ctx), s->bucket_info, obj, attrs); + op_ret = get_obj_attrs(store, s, obj, attrs); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: failed to get obj attrs, obj=" << obj << " ret=" << op_ret << dendl; @@ -1097,7 +1097,7 @@ void RGWPutObjTags::execute() rgw_obj obj; obj = rgw_obj(s->bucket, s->object); store->set_atomic(s->obj_ctx, obj); - op_ret = modify_obj_attr(store, *(s->obj_ctx), s->bucket_info, obj, RGW_ATTR_TAGS, tags_bl); + op_ret = modify_obj_attr(store, s, obj, RGW_ATTR_TAGS, tags_bl); if (op_ret == -ECANCELED){ op_ret = -ERR_TAG_CONFLICT; } @@ -4532,7 +4532,7 @@ void RGWPutMetadataObject::execute() } /* check if obj exists, read orig attrs */ - op_ret = get_obj_attrs(store, *(s->obj_ctx), s->bucket_info, obj, orig_attrs); + op_ret = get_obj_attrs(store, s, obj, orig_attrs); if (op_ret < 0) { return; } @@ -4689,7 +4689,7 @@ void RGWDeleteObj::execute() if (!s->object.empty()) { if (need_object_expiration() || multipart_delete) { /* check if obj exists, read orig attrs */ - op_ret = get_obj_attrs(store, *(s->obj_ctx), s->bucket_info, obj, attrs); + op_ret = get_obj_attrs(store, s, obj, attrs); if (op_ret < 0) { return; } @@ -5355,7 +5355,7 @@ void RGWPutACLs::execute() obj = rgw_obj(s->bucket, s->object); store->set_atomic(s->obj_ctx, obj); //if instance is empty, we should modify the latest object - op_ret = modify_obj_attr(store, *(s->obj_ctx), s->bucket_info, obj, RGW_ATTR_ACL, bl); + op_ret = modify_obj_attr(store, s, obj, RGW_ATTR_ACL, bl); } else { attrs = s->bucket_attrs; attrs[RGW_ATTR_ACL] = bl; @@ -5916,7 +5916,7 @@ void RGWCompleteMultipart::execute() return; } - op_ret = get_obj_attrs(store, *(s->obj_ctx), s->bucket_info, meta_obj, attrs); + op_ret = get_obj_attrs(store, s, meta_obj, attrs); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: failed to get obj attrs, obj=" << meta_obj diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index d7128111b87..657ce7b9ded 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -2380,7 +2380,4 @@ static inline int parse_value_and_bound( return 0; } -int get_obj_attrs(RGWRados *store, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, map& attrs); -int modify_obj_attr(RGWRados *store, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, const char* attr_name, bufferlist& attr_val); - #endif /* CEPH_RGW_OP_H */ diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 17471757e77..960246ab096 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -229,7 +229,7 @@ int rgw_store_user_info(RGWRados *store, map::iterator iter = info.access_keys.begin(); for (; iter != info.access_keys.end(); ++iter) { RGWAccessKey& k = iter->second; - if (old_info && old_info->access_keys.count(iter->first) && !renamed != 0) + if (old_info && old_info->access_keys.count(iter->first) != 0 && !renamed) continue; ret = rgw_put_system_obj(store, store->svc.zone->get_zone_params().user_keys_pool, k.id, @@ -242,7 +242,7 @@ int rgw_store_user_info(RGWRados *store, map::iterator siter; for (siter = info.swift_keys.begin(); siter != info.swift_keys.end(); ++siter) { RGWAccessKey& k = siter->second; - if (old_info && old_info->swift_keys.count(siter->first) && !renamed != 0) + if (old_info && old_info->swift_keys.count(siter->first) != 0 && !renamed) continue; ret = rgw_put_system_obj(store, store->svc.zone->get_zone_params().user_swift_pool, k.id,