Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jewel: rbd: helpful error message on map failure #9041

Merged
merged 1 commit into from
May 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/tools/rbd/action/Kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,45 @@ static int do_kernel_showmapped(Formatter *f)
return r;
}

/*
* hint user to check syslog for krbd related messages and provide suggestions
* based on errno return by krbd_map(). also note that even if some librbd calls
* fail, we atleast dump the "try dmesg..." message to aid debugging.
*/
static void print_error_description(const char *poolname, const char *imgname,
const char *snapname, int maperrno)
{
int r;
uint8_t oldformat;
librados::Rados rados;
librados::IoCtx ioctx;
librbd::Image image;

if (maperrno == -ENOENT)
goto done;

r = utils::init_and_open_image(poolname, imgname, snapname,
true, &rados, &ioctx, &image);
if (r < 0)
goto done;

r = image.old_format(&oldformat);
if (r < 0)
goto done;

/*
* kernel returns -ENXIO when mapping a V2 image due to unsupported feature
* set - so, hint about that too...
*/
if (!oldformat && (maperrno == -ENXIO)) {
std::cout << "RBD image feature set mismatch. You can disable features unsupported by the "
<< "kernel with \"rbd feature disable\"." << std::endl;
}

done:
std::cout << "In some cases useful info is found in syslog - try \"dmesg | tail\" or so." << std::endl;
}

static int do_kernel_map(const char *poolname, const char *imgname,
const char *snapname)
{
Expand Down Expand Up @@ -181,8 +220,10 @@ static int do_kernel_map(const char *poolname, const char *imgname,
}

r = krbd_map(krbd, poolname, imgname, snapname, oss.str().c_str(), &devnode);
if (r < 0)
if (r < 0) {
print_error_description(poolname, imgname, snapname, r);
goto out;
}

std::cout << devnode << std::endl;

Expand Down