From e1e027477094ce1cb66f8f8a678ffe1fdea3d4bf Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Tue, 23 Jan 2024 16:07:04 -0500 Subject: [PATCH] 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 (cherry picked from commit 1712b95c784c5ce381fbf4b09e8219ea40bd99a8) --- src/tools/rbd_nbd/rbd-nbd.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index f05d06f326ab2..ab904b5f0a4a6 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -1295,21 +1295,21 @@ static int netlink_resize(int nbd_index, const std::string& cookie, sock = netlink_init(&nl_id); if (!sock) { - cerr << "rbd-nbd: Netlink interface not supported." << std::endl; - return 1; + derr << __func__ << ": netlink interface not supported" << dendl; + return -EINVAL; } nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, genl_handle_msg, NULL); msg = nlmsg_alloc(); if (!msg) { - cerr << "rbd-nbd: Could not allocate netlink message." << std::endl; + derr << __func__ << ": could not allocate netlink message" << dendl; goto free_sock; } if (!genlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, nl_id, 0, 0, NBD_CMD_RECONFIGURE, 0)) { - cerr << "rbd-nbd: Could not setup message." << std::endl; + derr << __func__ << ": could not setup netlink message" << dendl; goto free_msg; } @@ -1320,7 +1320,8 @@ static int netlink_resize(int nbd_index, const std::string& cookie, ret = nl_send_sync(sock, msg); if (ret < 0) { - cerr << "rbd-nbd: netlink resize failed: " << nl_geterror(ret) << std::endl; + derr << __func__ << ": netlink resize failed: " << nl_geterror(ret) + << dendl; goto free_sock; } -- 2.39.5