]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-nbd: fix nbd do_unmap error handling 15593/head
authorchenfangxian <chenfangxian@cmss.chinamobile.com>
Tue, 13 Jun 2017 03:05:51 +0000 (11:05 +0800)
committerchenfangxian <chenfangxian@cmss.chinamobile.com>
Tue, 13 Jun 2017 03:05:51 +0000 (11:05 +0800)
when nbd disconnect failed, ensure do_unmap return error logic.

Signed-off-by: chenfangxian <chenfangxian@cmss.chinamobile.com>
Signed-off-by: guojiannan <guojiannan@cmss.chinamobile.com>
src/tools/rbd_nbd/rbd-nbd.cc

index b247c02546f2e5cf4f83dc807996f36e7a64909e..102a5ce6c4fb98b36a7f85adc500adc3d5c1e924 100644 (file)
@@ -776,19 +776,22 @@ close_ret:
 
 static int do_unmap()
 {
+  int r = 0;
+
   int nbd = open_device(devpath.c_str());
   if (nbd < 0) {
     cerr << "rbd-nbd: failed to open device: " << devpath << std::endl;
     return nbd;
   }
 
-  if (ioctl(nbd, NBD_DISCONNECT) < 0) {
-    cerr << "rbd-nbd: the device is not used" << std::endl;
+  r = ioctl(nbd, NBD_DISCONNECT);
+  if (r < 0) {
+      cerr << "rbd-nbd: the device is not used" << std::endl; 
   }
 
   close(nbd);
 
-  return 0;
+  return r;
 }
 
 static int parse_imgpath(const std::string &imgpath)