]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: use unique error code for image removal failures
authorJosh Durgin <josh.durgin@dreamhost.com>
Fri, 27 Apr 2012 18:20:59 +0000 (11:20 -0700)
committerSage Weil <sage@newdream.net>
Mon, 30 Apr 2012 17:55:45 +0000 (10:55 -0700)
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>
src/librbd.cc
src/rbd.cc

index 0a2264bda683eb1a1e0656ed7f2375d3c90048c4..bb7043682aa9be55f894fa9156b5d24e5f7d889a 100644 (file)
@@ -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;
index cb82f9cc70fe64938d8a01a6627ef1ffd7986e95..1c43fb544be9d0f0f0eff466e0c39c077f13dd7c 100644 (file)
@@ -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;