]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/NVMEDevice: fix error handling for open()
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 25 Feb 2016 10:48:07 +0000 (10:48 +0000)
committerxiexingguo <xie.xingguo@zte.com.cn>
Fri, 26 Feb 2016 11:03:56 +0000 (19:03 +0800)
According to Linux man page, the system call read() may return zero to indicate
that end of file reached on success. So below here we need to convert the result
code to a customized one in this case as errno is not set and we actually want
let caller know something is going wrong.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/NVMEDevice.cc

index 6d13e65faba87b8deea9fdb423d56e6c970b0765..bb95a4938d1db52ccb5a932c6bdd245d2c5a204f 100644 (file)
@@ -604,7 +604,11 @@ int NVMEDevice::open(string p)
   VOID_TEMP_FAILURE_RETRY(::close(fd));
   fd = -1; // defensive
   if (r <= 0) {
-    r = -errno;
+    if (r == 0) {
+      r = -EINVAL;
+    } else {
+      r = -errno;
+    }
     derr << __func__ << " unable to read " << p << ": " << cpp_strerror(r) << dendl;
     return r;
   }