Skip to content

Commit c3b9e1c

Browse files
authored
Merge pull request ceph#61684 from jzhu116-bloomberg/wip-69738
rgw: cleanup orphaned bucket entry in <user>.buckets OMAP Reviewed-by: Casey Bodley <[email protected]>
2 parents 23609f6 + 68c674a commit c3b9e1c

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,36 @@ int RadosBucket::create(const DoutPrefixProvider* dpp,
209209
ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << ret
210210
<< dendl;
211211
}
212-
} else if (ret == -EEXIST || (ret == 0 && existed)) {
212+
} else if (ret == -EEXIST) {
213213
ret = -ERR_BUCKET_EXISTS;
214+
} else if (ret == 0) {
215+
/* this is to handle the following race condition:
216+
* a concurrent DELETE bucket request deletes the bucket entry point and
217+
* unlinks it (if the bucket pre-exists) before it's linked in this
218+
* bucket creation request. */
219+
220+
if (existed) {
221+
ret = -ERR_BUCKET_EXISTS;
222+
}
223+
224+
RGWBucketEntryPoint ep;
225+
RGWObjVersionTracker objv_tracker;
226+
int r = store->ctl()->bucket->read_bucket_entrypoint_info(info.bucket,
227+
&ep,
228+
y,
229+
dpp,
230+
RGWBucketCtl::Bucket::GetParams()
231+
.set_objv_tracker(&objv_tracker));
232+
if (r == -ENOENT) {
233+
ret = 0;
234+
235+
ldpp_dout(dpp, 5) << "WARNING: the bucket entry point has been deleted by a concurrent DELETE bucket request."
236+
<< " Unlinking the bucket." << dendl;
237+
r = unlink(dpp, params.owner, y);
238+
if (r < 0) {
239+
ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << r << dendl;
240+
}
241+
}
214242
}
215243

216244
return ret;

0 commit comments

Comments
 (0)