From 18542f38ac98fdd21cce19d37693c0d371f3b7f7 Mon Sep 17 00:00:00 2001 From: Cory Snyder Date: Wed, 14 Jun 2023 14:01:43 +0000 Subject: [PATCH] rgw: apply_olh_log should clear_olh before trimming olh log When pending_removal is true and the log is trimmed prior to clearing olh, it allows for the possibility that the olh is not cleared (e.g. due to new pending xattrs on the olh obj), but the olh log entries are removed. Signed-off-by: Cory Snyder (cherry picked from commit dfbe4f9cb078bad9a0244ce433a9728f8bd6b912) Conflicts: src/rgw/driver/rados/rgw_rados.cc Cherry-pick notes: - conflicts due to https://github.com/ceph/ceph/pull/50206 on main --- src/rgw/driver/rados/rgw_rados.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index d66f4112d6e..df334e99e39 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -7514,17 +7514,21 @@ int RGWRados::apply_olh_log(const DoutPrefixProvider *dpp, return r; } + if (need_to_remove) { + string olh_tag(state.olh_tag.c_str(), state.olh_tag.length()); + r = clear_olh(dpp, obj_ctx, obj, bucket_info, ref, olh_tag, last_ver, null_yield); + if (r < 0 && r != -ECANCELED) { + ldpp_dout(dpp, 0) << "ERROR: could not clear olh, r=" << r << dendl; + return r; + } + } + r = bucket_index_trim_olh_log(dpp, bucket_info, state, obj, last_ver); - if (r < 0) { + if (r < 0 && r != -ECANCELED) { ldpp_dout(dpp, 0) << "ERROR: could not trim olh log, r=" << r << dendl; return r; } - if (need_to_remove) { - string olh_tag(state.olh_tag.c_str(), state.olh_tag.length()); - clear_olh(dpp, obj_ctx, obj, bucket_info, ref, olh_tag, last_ver, null_yield); - } - return 0; } -- 2.39.5