Blame SOURCES/kvm-block-nbd-client-don-t-check-ioc.patch

7711c0
From 9cfc0299d10213160701c07ed5f4feb1c98d4f2a Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 27 Mar 2019 17:23:02 +0100
7711c0
Subject: [PATCH 124/163] block/nbd-client: don't check ioc
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190327172308.31077-50-jsnow@redhat.com>
7711c0
Patchwork-id: 85214
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 49/55] block/nbd-client: don't check ioc
7711c0
Bugzilla: 1691009
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
7711c0
We have several paranoid checks for ioc != NULL. But ioc may become
7711c0
NULL only on close, which should not happen during requests handling.
7711c0
Also, we check ioc only sometimes, not after each yield, which is
7711c0
inconsistent. Let's drop these checks. However, for safety, let's leave
7711c0
asserts instead.
7711c0
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Message-Id: <20190201130138.94525-6-vsementsov@virtuozzo.com>
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
(cherry picked from commit 88ed4e1bf0c7017c04fac2166ec9a7687aa21f97)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/nbd-client.c | 16 +++++-----------
7711c0
 1 file changed, 5 insertions(+), 11 deletions(-)
7711c0
7711c0
diff --git a/block/nbd-client.c b/block/nbd-client.c
7711c0
index 5d22f8b..5f3a67f 100644
7711c0
--- a/block/nbd-client.c
7711c0
+++ b/block/nbd-client.c
7711c0
@@ -53,9 +53,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
7711c0
 {
7711c0
     NBDClientSession *client = nbd_get_client_session(bs);
7711c0
 
7711c0
-    if (!client->ioc) { /* Already closed */
7711c0
-        return;
7711c0
-    }
7711c0
+    assert(client->ioc);
7711c0
 
7711c0
     /* finish any pending coroutines */
7711c0
     qio_channel_shutdown(client->ioc,
7711c0
@@ -153,10 +151,7 @@ static int nbd_co_send_request(BlockDriverState *bs,
7711c0
         rc = -EIO;
7711c0
         goto err;
7711c0
     }
7711c0
-    if (!s->ioc) {
7711c0
-        rc = -EPIPE;
7711c0
-        goto err;
7711c0
-    }
7711c0
+    assert(s->ioc);
7711c0
 
7711c0
     if (qiov) {
7711c0
         qio_channel_set_cork(s->ioc, true);
7711c0
@@ -428,10 +423,11 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
7711c0
     s->requests[i].receiving = true;
7711c0
     qemu_coroutine_yield();
7711c0
     s->requests[i].receiving = false;
7711c0
-    if (!s->ioc || s->quit) {
7711c0
+    if (s->quit) {
7711c0
         error_setg(errp, "Connection closed");
7711c0
         return -EIO;
7711c0
     }
7711c0
+    assert(s->ioc);
7711c0
 
7711c0
     assert(s->reply.handle == handle);
7711c0
 
7711c0
@@ -981,9 +977,7 @@ void nbd_client_close(BlockDriverState *bs)
7711c0
     NBDClientSession *client = nbd_get_client_session(bs);
7711c0
     NBDRequest request = { .type = NBD_CMD_DISC };
7711c0
 
7711c0
-    if (client->ioc == NULL) {
7711c0
-        return;
7711c0
-    }
7711c0
+    assert(client->ioc);
7711c0
 
7711c0
     nbd_send_request(client->ioc, &request);
7711c0
 
7711c0
-- 
7711c0
1.8.3.1
7711c0