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