]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: log errors during netlink_resize() using derr 55317/head
authorRamana Raja <rraja@redhat.com>
Tue, 23 Jan 2024 21:07:04 +0000 (16:07 -0500)
committerRamana Raja <rraja@redhat.com>
Thu, 25 Jan 2024 15:35:50 +0000 (10:35 -0500)
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 <rraja@redhat.com>
(cherry picked from commit 1712b95c784c5ce381fbf4b09e8219ea40bd99a8)

src/tools/rbd_nbd/rbd-nbd.cc

index f05d06f326ab2511df8a0df6a25d01413ba6227d..ab904b5f0a4a69b83ed58cf5ba5bd073df98bd30 100644 (file)
@@ -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;
   }