Skip to contentSkip to conversation

linux-aio: Handle io_submit() failure gracefully

PATCH Applied Kevin Wolf 3 participants 3 messages Aug 9, 2016 – Aug 12, 2016 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 linux-aio: Handle io_submit() failure gracefully

It is generally not expected that io_submit() fails other than with -EAGAIN, but corner cases like SELinux refusing I/O when permissions are revoked are still possible. In this case, we shouldn't abort, but just return an I/O error for the request.

---
 block/linux-aio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
block/linux-aio.c +7 -1
index de3548f..e906abe 100644
@@ -221,7 +221,13 @@ static void ioq_submit(LinuxAioState *s)
             break;
         }
         if (ret < 0) {
-            abort();
+            /* Fail the first request, retry the rest */
+            aiocb = QSIMPLEQ_FIRST(&s->io_q.pending);
+            QSIMPLEQ_REMOVE_HEAD(&s->io_q.pending, next);
+            s->io_q.in_queue--;
+            aiocb->ret = ret;
+            qemu_laio_process_completion(aiocb);
+            continue;
         }
 
         s->io_q.in_flight += ret;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Kevin Wolf

It is generally not expected that io_submit() fails other than with -EAGAIN, but corner cases like SELinux refusing I/O when permissions are revoked are still possible. In this case, we shouldn't abort, but just return an I/O error for the request.

---
 block/linux-aio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#2 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

It is generally not expected that io_submit() fails other than with -EAGAIN, but corner cases like SELinux refusing I/O when permissions are revoked are still possible. In this case, we shouldn't abort, but just return an I/O error for the request.

Yes, we have seen this as well when having a disk accessed by two different guests and quickly starting/stopping. AFAIK Bjoern or Boris are looking into some libvirt fixes to prevent that race from being triggered by libvirt, but having QEMU to not crash is certainly useful on its own.

Christian

Quoted 24 lines
---
 block/linux-aio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
block/linux-aio.c +7 -1
index de3548f..e906abe 100644
@@ -221,7 +221,13 @@ static void ioq_submit(LinuxAioState *s)
             break;
         }
         if (ret < 0) {
-            abort();
+            /* Fail the first request, retry the rest */
+            aiocb = QSIMPLEQ_FIRST(&s->io_q.pending);
+            QSIMPLEQ_REMOVE_HEAD(&s->io_q.pending, next);
+            s->io_q.in_queue--;
+            aiocb->ret = ret;
+            qemu_laio_process_completion(aiocb);
+            continue;
         }
 
         s->io_q.in_flight += ret;