From a308e3a1d590f1a35337415caf756a550f2617a9 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 20 Feb 2023 08:08:01 -0500 Subject: [PATCH] rgw/rados: add get_obj_state() overload for RGWObjStateManifest add an overload to expose the manifest storage to callers of get_obj_state(). the existing RGWObjState+RGWObjManifest overload just calls the RGWObjStateManifest one Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_rados.cc | 64 +++++++++++++++++++------------ src/rgw/driver/rados/rgw_rados.h | 15 ++++++-- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index efb7fd37f61ce..fc1d7b7a68552 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -5887,48 +5887,38 @@ static bool has_olh_tag(map& attrs) int RGWRados::get_olh_target_state(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState *olh_state, - RGWObjState **target_state, - RGWObjManifest **target_manifest, optional_yield y) + RGWObjStateManifest **psm, optional_yield y) { ceph_assert(olh_state->is_olh); rgw_obj target; - int r = RGWRados::follow_olh(dpp, bucket_info, obj_ctx, olh_state, obj, &target, y); /* might return -EAGAIN */ + int r = RGWRados::follow_olh(dpp, bucket_info, obj_ctx, olh_state, + obj, &target, y); /* might return -EAGAIN */ if (r < 0) { return r; } - r = get_obj_state(dpp, &obj_ctx, bucket_info, target, target_state, - target_manifest, false, y); - if (r < 0) { - return r; - } - - return 0; + return get_obj_state(dpp, &obj_ctx, bucket_info, target, psm, false, y); } int RGWRados::get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *octx, - RGWBucketInfo& bucket_info, const rgw_obj& obj, - RGWObjState **state, RGWObjManifest** manifest, - bool follow_olh, optional_yield y, bool assume_noent) + RGWBucketInfo& bucket_info, const rgw_obj& obj, + RGWObjStateManifest** psm, bool follow_olh, + optional_yield y, bool assume_noent) { if (obj.empty()) { return -EINVAL; } bool need_follow_olh = follow_olh && obj.key.instance.empty(); - *manifest = nullptr; RGWObjStateManifest *sm = octx->get_state(obj); RGWObjState *s = &(sm->state); ldpp_dout(dpp, 20) << "get_obj_state: octx=" << (void *)octx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl; - *state = s; - if (sm->manifest) { - *manifest = &(*sm->manifest); - } + *psm = sm; if (s->has_attrs) { if (s->is_olh && need_follow_olh) { - return get_olh_target_state(dpp, *octx, bucket_info, obj, s, state, manifest, y); + return get_olh_target_state(dpp, *octx, bucket_info, obj, s, psm, y); } return 0; } @@ -6020,7 +6010,6 @@ int RGWRados::get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *oc ldpp_dout(dpp, 0) << "ERROR: couldn't decode manifest" << dendl; return -EIO; } - *manifest = &(*sm->manifest); ldpp_dout(dpp, 10) << "manifest: total_size = " << sm->manifest->get_obj_size() << dendl; if (cct->_conf->subsys.should_gather() && \ sm->manifest->has_explicit_objs()) { @@ -6080,7 +6069,7 @@ int RGWRados::get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *oc ldpp_dout(dpp, 20) << __func__ << ": setting s->olh_tag to " << string(s->olh_tag.c_str(), s->olh_tag.length()) << dendl; if (need_follow_olh) { - return get_olh_target_state(dpp, *octx, bucket_info, obj, s, state, manifest, y); + return get_olh_target_state(dpp, *octx, bucket_info, obj, s, psm, y); } else if (obj.key.have_null_instance() && !sm->manifest) { // read null version, and the head object only have olh info s->exists = false; @@ -6091,18 +6080,45 @@ int RGWRados::get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *oc return 0; } -int RGWRados::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *octx, RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState **state, RGWObjManifest** manifest, - bool follow_olh, optional_yield y, bool assume_noent) +int RGWRados::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *octx, + RGWBucketInfo& bucket_info, const rgw_obj& obj, + RGWObjStateManifest** psm, bool follow_olh, + optional_yield y, bool assume_noent) { int ret; do { - ret = get_obj_state_impl(dpp, octx, bucket_info, obj, state, manifest, follow_olh, y, assume_noent); + ret = get_obj_state_impl(dpp, octx, bucket_info, obj, psm, + follow_olh, y, assume_noent); } while (ret == -EAGAIN); return ret; } +int RGWRados::get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, + RGWBucketInfo& bucket_info, const rgw_obj& obj, + RGWObjState** pstate, RGWObjManifest** pmanifest, + bool follow_olh, optional_yield y, bool assume_noent) +{ + RGWObjStateManifest* sm = nullptr; + int r = get_obj_state(dpp, rctx, bucket_info, obj, &sm, + follow_olh, y, assume_noent); + if (r < 0) { + return r; + } + if (pstate) { + *pstate = &sm->state; + } + if (pmanifest) { + if (sm->manifest) { + *pmanifest = &(*sm->manifest); + } else { + *pmanifest = nullptr; + } + } + return 0; +} + int RGWRados::Object::get_manifest(const DoutPrefixProvider *dpp, RGWObjManifest **pmanifest, optional_yield y) { RGWObjState *astate; diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index cde2fa66bdfa4..d8cba7b9b4edd 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -414,10 +414,12 @@ class RGWRados int get_olh_target_state(const DoutPrefixProvider *dpp, RGWObjectCtx& rctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, - RGWObjState *olh_state, RGWObjState **target_state, - RGWObjManifest **target_manifest, optional_yield y); - int get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState **state, RGWObjManifest** manifest, - bool follow_olh, optional_yield y, bool assume_noent = false); + RGWObjState *olh_state, RGWObjStateManifest **psm, + optional_yield y); + int get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, + RGWBucketInfo& bucket_info, const rgw_obj& obj, + RGWObjStateManifest** psm, bool follow_olh, + optional_yield y, bool assume_noent = false); int append_atomic_test(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::ObjectOperation& op, RGWObjState **state, RGWObjManifest** pmanifest, optional_yield y); @@ -1268,6 +1270,11 @@ public: optional_yield y, ceph::real_time set_mtime = ceph::real_clock::zero()); + int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, + RGWBucketInfo& bucket_info, const rgw_obj& obj, + RGWObjStateManifest** psm, bool follow_olh, + optional_yield y, bool assume_noent = false); + int get_obj_state(const DoutPrefixProvider *dpp, RGWObjectCtx *rctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, RGWObjState** pstate, RGWObjManifest** pmanifest, -- 2.39.5