Skip to content

Commit 1712b95

Browse files
committed
rbd-nbd: log errors during netlink_resize() using derr
When using rbd CLI to map the images to NBD devices via netlink, any errors that arose during image resizing in netlink_resize() were not logged. Switching the error logging from using cerr to derr helps log the errors from netlink_resize(). Signed-off-by: Ramana Raja <[email protected]>
1 parent 1eebb7b commit 1712b95

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/tools/rbd_nbd/rbd-nbd.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,21 +1332,21 @@ static int netlink_resize(int nbd_index, const std::string& cookie,
13321332

13331333
sock = netlink_init(&nl_id);
13341334
if (!sock) {
1335-
cerr << "rbd-nbd: Netlink interface not supported." << std::endl;
1336-
return 1;
1335+
derr << __func__ << ": netlink interface not supported" << dendl;
1336+
return -EINVAL;
13371337
}
13381338

13391339
nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, genl_handle_msg, NULL);
13401340

13411341
msg = nlmsg_alloc();
13421342
if (!msg) {
1343-
cerr << "rbd-nbd: Could not allocate netlink message." << std::endl;
1343+
derr << __func__ << ": could not allocate netlink message" << dendl;
13441344
goto free_sock;
13451345
}
13461346

13471347
if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, nl_id, 0, 0,
13481348
NBD_CMD_RECONFIGURE, 0)) {
1349-
cerr << "rbd-nbd: Could not setup message." << std::endl;
1349+
derr << __func__ << ": could not setup netlink message" << dendl;
13501350
goto free_msg;
13511351
}
13521352

@@ -1357,7 +1357,8 @@ static int netlink_resize(int nbd_index, const std::string& cookie,
13571357

13581358
ret = nl_send_sync(sock, msg);
13591359
if (ret < 0) {
1360-
cerr << "rbd-nbd: netlink resize failed: " << nl_geterror(ret) << std::endl;
1360+
derr << __func__ << ": netlink resize failed: " << nl_geterror(ret)
1361+
<< dendl;
13611362
goto free_sock;
13621363
}
13631364

0 commit comments

Comments
 (0)