Blame SOURCES/kvm-file-posix-Fix-EINTR-handling.patch

357786
From 9075cb2c3c074b395192ce166fe17664b0d9543c Mon Sep 17 00:00:00 2001
357786
From: Fam Zheng <famz@redhat.com>
357786
Date: Fri, 29 Jun 2018 06:11:53 +0200
357786
Subject: [PATCH 49/57] file-posix: Fix EINTR handling
357786
357786
RH-Author: Fam Zheng <famz@redhat.com>
357786
Message-id: <20180629061153.12687-14-famz@redhat.com>
357786
Patchwork-id: 81164
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH v2 13/13] file-posix: Fix EINTR handling
357786
Bugzilla: 1482537
357786
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
357786
EINTR should be checked against errno, not ret. While fixing the bug,
357786
collect the branches with a switch block.
357786
357786
Also, change the return value from -ENOSTUP to -ENOSPC when the actual
357786
issue is request range passes EOF, which should be distinguishable from
357786
the case of error == ENOSYS by the caller, so that it could still retry
357786
with other byte ranges, whereas it shouldn't retry anymore upon ENOSYS.
357786
357786
Signed-off-by: Fam Zheng <famz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 block/file-posix.c | 17 +++++++++--------
357786
 1 file changed, 9 insertions(+), 8 deletions(-)
357786
357786
diff --git a/block/file-posix.c b/block/file-posix.c
357786
index 29ff699..0a9df5b 100644
357786
--- a/block/file-posix.c
357786
+++ b/block/file-posix.c
357786
@@ -1449,20 +1449,21 @@ static ssize_t handle_aiocb_copy_range(RawPosixAIOData *aiocb)
357786
         ssize_t ret = copy_file_range(aiocb->aio_fildes, &in_off,
357786
                                       aiocb->aio_fd2, &out_off,
357786
                                       bytes, 0);
357786
-        if (ret == -EINTR) {
357786
-            continue;
357786
+        if (ret == 0) {
357786
+            /* No progress (e.g. when beyond EOF), let the caller fall back to
357786
+             * buffer I/O. */
357786
+            return -ENOSPC;
357786
         }
357786
         if (ret < 0) {
357786
-            if (errno == ENOSYS) {
357786
+            switch (errno) {
357786
+            case ENOSYS:
357786
                 return -ENOTSUP;
357786
-            } else {
357786
+            case EINTR:
357786
+                continue;
357786
+            default:
357786
                 return -errno;
357786
             }
357786
         }
357786
-        if (!ret) {
357786
-            /* No progress (e.g. when beyond EOF), fall back to buffer I/O. */
357786
-            return -ENOTSUP;
357786
-        }
357786
         bytes -= ret;
357786
     }
357786
     return 0;
357786
-- 
357786
1.8.3.1
357786