Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jewel: librbd: Image removal doesn't necessarily clean up all rbd_mirroring entries #10009

Merged
1 commit merged into from Aug 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 37 additions & 29 deletions src/librbd/internal.cc
Expand Up @@ -2125,58 +2125,66 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
}

if (old_format || unknown_format) {
ldout(cct, 2) << "removing rbd image from directory..." << dendl;
ldout(cct, 2) << "removing rbd image from v1 directory..." << dendl;
r = tmap_rm(io_ctx, imgname);
old_format = (r == 0);
if (r < 0 && !unknown_format) {
if (r != -ENOENT) {
lderr(cct) << "error removing img from old-style directory: "
<< cpp_strerror(-r) << dendl;
lderr(cct) << "error removing image from v1 directory: "
<< cpp_strerror(-r) << dendl;
}
return r;
}
}
if (!old_format) {
r = Journal<>::remove(io_ctx, id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing image journal" << dendl;
return r;
if (id.empty()) {
ldout(cct, 5) << "attempting to determine image id" << dendl;
r = cls_client::dir_get_id(&io_ctx, RBD_DIRECTORY, imgname, &id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error getting id of image" << dendl;
return r;
}
}
if (!id.empty()) {
ldout(cct, 10) << "removing journal..." << dendl;
r = Journal<>::remove(io_ctx, id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing image journal" << dendl;
return r;
}

r = ObjectMap::remove(io_ctx, id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing image object map" << dendl;
return r;
ldout(cct, 10) << "removing object map..." << dendl;
r = ObjectMap::remove(io_ctx, id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing image object map" << dendl;
return r;
}

ldout(cct, 10) << "removing image from rbd_mirroring object..."
<< dendl;
r = cls_client::mirror_image_remove(&io_ctx, id);
if (r < 0 && r != -ENOENT && r != -EOPNOTSUPP) {
lderr(cct) << "failed to remove image from mirroring directory: "
<< cpp_strerror(r) << dendl;
return r;
}
}

ldout(cct, 2) << "removing id object..." << dendl;
r = io_ctx.remove(util::id_obj_name(imgname));
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error removing id object: " << cpp_strerror(r) << dendl;
return r;
}

r = cls_client::dir_get_id(&io_ctx, RBD_DIRECTORY, imgname, &id);
if (r < 0 && r != -ENOENT) {
lderr(cct) << "error getting id of image" << dendl;
lderr(cct) << "error removing id object: " << cpp_strerror(r)
<< dendl;
return r;
}

ldout(cct, 2) << "removing rbd image from directory..." << dendl;
ldout(cct, 2) << "removing rbd image from v2 directory..." << dendl;
r = cls_client::dir_remove_image(&io_ctx, RBD_DIRECTORY, imgname, id);
if (r < 0) {
if (r != -ENOENT) {
lderr(cct) << "error removing img from new-style directory: "
<< cpp_strerror(-r) << dendl;
lderr(cct) << "error removing image from v2 directory: "
<< cpp_strerror(-r) << dendl;
}
return r;
}

ldout(cct, 2) << "removing image from rbd_mirroring object..." << dendl;
r = cls_client::mirror_image_remove(&io_ctx, id);
if (r < 0 && r != -ENOENT && r != -EOPNOTSUPP) {
lderr(cct) << "failed to remove image from mirroring directory: "
<< cpp_strerror(r) << dendl;
return r;
}
}
Expand Down