From: Cory Snyder Date: Thu, 21 Sep 2023 19:27:51 +0000 (+0000) Subject: rgw: prevent another leftover bucket index olh entry scenario X-Git-Tag: v17.2.7~29^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4210ee20e0ec8b7068980fdcd51f346e5e51241;p=ceph.git rgw: prevent another leftover bucket index olh entry scenario If a call to bucket_index_link_olh or bucket_index_unlink_instance fails, its associated pending xattr may have prevented the olh object from being removed by another thread. We should do a best effort cleanup attempt for this case by calling update_olh before returning an error to the caller. Signed-off-by: Cory Snyder (cherry picked from commit 570adec5bb8142f5baf1f05f0040e8afdb11ec05) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9f2485c1ba90..d389b2c38841 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -7786,6 +7786,13 @@ int RGWRados::set_olh(const DoutPrefixProvider *dpp, RGWObjectCtx& obj_ctx, cons } continue; } + // it's possible that the pending xattr from this op prevented the olh + // object from being cleaned by another thread that was deleting the last + // existing version. We invoke a best-effort update_olh here to handle this case. + int r = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj); + if (r < 0 && r != -ECANCELED) { + ldpp_dout(dpp, 20) << "update_olh() target_obj=" << olh_obj << " returned " << r << dendl; + } return ret; } break; @@ -7848,6 +7855,13 @@ int RGWRados::unlink_obj_instance(const DoutPrefixProvider *dpp, RGWObjectCtx& o if (ret == -ECANCELED) { continue; } + // it's possible that the pending xattr from this op prevented the olh + // object from being cleaned by another thread that was deleting the last + // existing version. We invoke a best-effort update_olh here to handle this case. + int r = update_olh(dpp, obj_ctx, state, bucket_info, olh_obj, zones_trace); + if (r < 0 && r != -ECANCELED) { + ldpp_dout(dpp, 20) << "update_olh() target_obj=" << olh_obj << " returned " << r << dendl; + } return ret; } break;