From: Pan Liu Date: Tue, 28 Mar 2017 08:48:21 +0000 (+0800) Subject: rbd-nbd: polish the output info before and after ioctl NBD_DISCONNECT. X-Git-Tag: v12.0.2~267^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F14079%2Fhead;p=ceph.git rbd-nbd: polish the output info before and after ioctl NBD_DISCONNECT. Signed-off-by: Pan Liu --- diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 3a55cf2b1637..ac95e9afbc8a 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;