From e2bbce790f4798b8f34e071bc277ddb103675e0d Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 25 Feb 2016 10:48:07 +0000 Subject: [PATCH] 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 --- src/os/bluestore/NVMEDevice.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 6d13e65faba..bb95a4938d1 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; } -- 2.39.5