Skip to content

Commit

Permalink
Merge pull request #10009: jewel: Image removal doesn't necessarily c…
Browse files Browse the repository at this point in the history
…lean up all rbd_mirroring entries

Reviewed-by: Loic Dachary <ldachary@redhat.com>
  • Loading branch information
Loic Dachary committed Jun 30, 2016
2 parents 80f0f3e + db7ce96 commit 1730fd3
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions src/librbd/internal.cc
Expand Up @@ -2123,58 +2123,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

0 comments on commit 1730fd3

Please sign in to comment.