]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: polish the output info before and after ioctl NBD_DISCONNECT.
authorPan Liu <liupan1111@gmail.com>
Tue, 28 Mar 2017 08:48:21 +0000 (16:48 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 4 Jul 2017 08:56:37 +0000 (10:56 +0200)
Signed-off-by: Pan Liu <liupan1111@gmail.com>
(cherry picked from commit ff4dcf029028e8a3636ac71a6c5ac5380bf274e4)

src/tools/rbd_nbd/rbd-nbd.cc

index 047f3e5c0edd1ccf79578a6c55841f525502d8fb..c87ba051a5656d1132f03341bbcdd48dbd8a68a6 100644 (file)
@@ -91,7 +91,12 @@ static void handle_signal(int signum)
 {
   assert(signum == SIGINT || signum == SIGTERM);
   derr << "*** Got signal " << sig_str(signum) << " ***" << dendl;
-  ioctl(nbd, NBD_DISCONNECT);
+  dout(20) << __func__ << ": " << "sending NBD_DISCONNECT" << dendl;
+  if (ioctl(nbd, NBD_DISCONNECT) < 0) {
+    derr << "rbd-nbd: disconnect failed: " << cpp_error(errno) << std::endl;
+  } else {
+    dout(20) << __func__ << ": " << "disconnected" << dendl;
+  }
 }
 
 class NBDServer
@@ -702,10 +707,13 @@ static int do_unmap()
     return nbd;
   }
 
-  // alert the reader thread to shut down
+  dout(20) << __func__ << ": " << "sending NBD_DISCONNECT" << dendl;
   if (ioctl(nbd, NBD_DISCONNECT) < 0) {
     cerr << "rbd-nbd: the device is not used" << std::endl;
+  } else {
+    dout(20) << __func__ << ": " << "disconnected" << dendl;
   }
+
   close(nbd);
 
   return 0;