From: xie xingguo Date: Thu, 25 Feb 2016 10:48:07 +0000 (+0000) Subject: os/bluestore/NVMEDevice: fix error handling for open() X-Git-Tag: v10.1.0~266^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2bbce790f4798b8f34e071bc277ddb103675e0d;p=ceph.git os/bluestore/NVMEDevice: fix error handling for open() 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 --- diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 6d13e65faba8..bb95a4938d1d 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -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; }