From: Dan Mick Date: Thu, 13 Dec 2012 22:06:17 +0000 (-0800) Subject: rbd: handle images disappearing while in ls -l X-Git-Tag: v0.56~63 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8103414a45a02275b61e9bee93a60db0619f7a1c;p=ceph.git rbd: handle images disappearing while in ls -l rbd.list() returns a list of names, but nothing stops them from going away before rbd.open(); check for ENOENT and ignore if that happens; warn on other errors Signed-off-by: Dan Mick Reviewed-by: Josh Durgin --- diff --git a/src/rbd.cc b/src/rbd.cc index 3db897871265..3920d4b9d552 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -199,7 +199,19 @@ static int do_list(librbd::RBD &rbd, librados::IoCtx& io_ctx, bool lflag) librbd::image_info_t info; librbd::Image im; - rbd.open(io_ctx, im, i->c_str()); + r = rbd.open(io_ctx, im, i->c_str()); + // image might disappear between rbd.list() and rbd.open(); ignore + // that, warn about other possible errors (EPERM, say, for opening + // an old-format image, because you need execute permission for the + // class method) + if (r < 0) { + if (r != -ENOENT) { + cerr << "rbd: error opening " << *i << ": " << cpp_strerror(r) + << std::endl; + } + // in any event, continue to next image + continue; + } // handle second-nth trips through loop parent.clear();