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