From: Jane Zhu Date: Thu, 6 Feb 2025 22:51:19 +0000 (+0000) Subject: rgw: cleanup orphaned bucket entry in .buckets OMAP X-Git-Tag: testing/wip-vshankar-testing-20250407.173548-debug~68^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8fdf4431dc98ee3735dde9121501fedb9835bb71;p=ceph-ci.git rgw: cleanup orphaned bucket entry in .buckets OMAP Signed-off-by: Jane Zhu --- diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index ea2572b4121..b03c5e6027e 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -201,8 +201,36 @@ int RadosBucket::create(const DoutPrefixProvider* dpp, ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << ret << dendl; } - } else if (ret == -EEXIST || (ret == 0 && existed)) { + } else if (ret == -EEXIST) { ret = -ERR_BUCKET_EXISTS; + } else if (ret == 0) { + /* this is to handle the following race condition: + * a concurrent DELETE bucket request deletes the bucket entry point and + * unlinks it (if the bucket pre-exists) before it's linked in this + * bucket creation request. */ + + if (existed) { + ret = -ERR_BUCKET_EXISTS; + } + + RGWBucketEntryPoint ep; + RGWObjVersionTracker objv_tracker; + int r = store->ctl()->bucket->read_bucket_entrypoint_info(info.bucket, + &ep, + y, + dpp, + RGWBucketCtl::Bucket::GetParams() + .set_objv_tracker(&objv_tracker)); + if (r == -ENOENT) { + ret = -ERR_NO_SUCH_BUCKET; + + ldpp_dout(dpp, 5) << "WARNING: the bucket entry point has been deleted by a concurrent DELETE bucket request." + << " Unlinking the bucket." << dendl; + r = unlink(dpp, params.owner, y); + if (r < 0) { + ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << r << dendl; + } + } } return ret;