From 17c20f0da3d3f749aef68b79d8994df2bd34eeea Mon Sep 17 00:00:00 2001 From: Joshua Baergen Date: Wed, 12 Oct 2022 12:19:36 -0600 Subject: [PATCH] blk/kernel: Fix error code mapping in KernelDevice::read. pread returns -1 upon error and stores the error code in errno, and thus the wrong error was being passed into is_expected_ioerr. This is handled correctly just a few lines down where we return -errno, so it was likely just an oversight when adapting this logic from the aio codepath, where the return code is indeed the errno. This logic has been incorrect since it was introduced in 2018 via a1e0ece7f987c7a563b25ec0d02fc6f8445ef54e. Signed-off-by: Joshua Baergen (cherry picked from commit 5e98a6b959b176b8b3a999e28639437976abb476) --- src/blk/kernel/KernelDevice.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index ee06af61e055f..e5e3461fb71d2 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -1243,7 +1243,7 @@ int KernelDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, << "s" << dendl; } if (r < 0) { - if (ioc->allow_eio && is_expected_ioerr(r)) { + if (ioc->allow_eio && is_expected_ioerr(-errno)) { r = -EIO; } else { r = -errno; -- 2.39.5