This allows the rbd tool to provide a useful error message, instead of
compounding more possible causes into one error code.
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
if (r >= 0) {
if (has_snaps(io_ctx, md_oid)) {
lderr(cct) << "image has snapshots - not removing" << dendl;
- return -EBUSY;
+ return -ENOTEMPTY;
}
trim_image(io_ctx, header, 0, prog_ctx);
ldout(cct, 2) << "removing header..." << dendl;
case OPT_RM:
r = do_delete(rbd, io_ctx, imgname);
if (r < 0) {
- if (r == -EBUSY) {
+ if (r == -ENOTEMPTY) {
cerr << "delete error: image has snapshots - these must be deleted"
<< " with 'rbd snap purge' before the image can be removed."
<< std::endl;
+ } else if (r == -EBUSY) {
+ cerr << "delete error: image still has watchers"
+ << std::endl
+ << "This means the image is still open or the client using "
+ << "it crashed. Try again after closing/unmapping it or "
+ << "waiting 30s for the crashed client to timeout."
+ << std::endl;
} else {
cerr << "delete error: " << cpp_strerror(-r) << std::endl;
}
- exit(1);
+ exit(-r);
}
break;