Skip to content

Commit 8fdf443

Browse files
rgw: cleanup orphaned bucket entry in <user>.buckets OMAP
Signed-off-by: Jane Zhu <[email protected]>
1 parent 693d7d4 commit 8fdf443

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
@@ -201,8 +201,36 @@ int RadosBucket::create(const DoutPrefixProvider* dpp,
201201
ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << ret
202202
<< dendl;
203203
}
204-
} else if (ret == -EEXIST || (ret == 0 && existed)) {
204+
} else if (ret == -EEXIST) {
205205
ret = -ERR_BUCKET_EXISTS;
206+
} else if (ret == 0) {
207+
/* this is to handle the following race condition:
208+
* a concurrent DELETE bucket request deletes the bucket entry point and
209+
* unlinks it (if the bucket pre-exists) before it's linked in this
210+
* bucket creation request. */
211+
212+
if (existed) {
213+
ret = -ERR_BUCKET_EXISTS;
214+
}
215+
216+
RGWBucketEntryPoint ep;
217+
RGWObjVersionTracker objv_tracker;
218+
int r = store->ctl()->bucket->read_bucket_entrypoint_info(info.bucket,
219+
&ep,
220+
y,
221+
dpp,
222+
RGWBucketCtl::Bucket::GetParams()
223+
.set_objv_tracker(&objv_tracker));
224+
if (r == -ENOENT) {
225+
ret = -ERR_NO_SUCH_BUCKET;
226+
227+
ldpp_dout(dpp, 5) << "WARNING: the bucket entry point has been deleted by a concurrent DELETE bucket request."
228+
<< " Unlinking the bucket." << dendl;
229+
r = unlink(dpp, params.owner, y);
230+
if (r < 0) {
231+
ldpp_dout(dpp, 0) << "WARNING: failed to unlink bucket: ret=" << r << dendl;
232+
}
233+
}
206234
}
207235

208236
return ret;

0 commit comments

Comments
 (0)