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 <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
Dan Mick 2012-12-13 14:06:17 -08:00
parent c17d628b52
commit 8103414a45

View File

@ -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();