diff options
author | Josh Durgin <josh.durgin@dreamhost.com> | 2012-04-27 20:20:59 +0200 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2012-04-30 19:55:45 +0200 |
commit | 88dda3be5aed38c8f587af9b27cb54a0fcca7530 (patch) | |
tree | 92357b3da2b2e6bcab9bcbd2befda75a905b068c | |
parent | FileJournal: simply flush by waiting for completions to empty (diff) | |
download | ceph-88dda3be5aed38c8f587af9b27cb54a0fcca7530.tar.xz ceph-88dda3be5aed38c8f587af9b27cb54a0fcca7530.zip |
librbd: use unique error code for image removal failures
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>
-rw-r--r-- | src/librbd.cc | 2 | ||||
-rw-r--r-- | src/rbd.cc | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/librbd.cc b/src/librbd.cc index 0a2264bda68..bb7043682aa 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -1025,7 +1025,7 @@ int remove(IoCtx& io_ctx, const char *imgname, ProgressContext& prog_ctx) 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; diff --git a/src/rbd.cc b/src/rbd.cc index cb82f9cc70f..1c43fb544be 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -1193,14 +1193,21 @@ int main(int argc, const char **argv) 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; |