From ff4dcf029028e8a3636ac71a6c5ac5380bf274e4 Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Tue, 28 Mar 2017 16:48:21 +0800 Subject: [PATCH] rbd-nbd: polish the output info before and after ioctl NBD_DISCONNECT. Signed-off-by: Pan Liu --- src/tools/rbd_nbd/rbd-nbd.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 3a55cf2b16373..ac95e9afbc8a6 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -96,7 +96,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 @@ -759,10 +764,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; -- 2.39.5