|
|
ae23c9 |
From cc9208123465166b5217d41f9a20e4b652463475 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Date: Wed, 18 Jul 2018 22:55:01 +0200
|
|
|
ae23c9 |
Subject: [PATCH 243/268] nbd/server: refactor NBDExportMetaContexts
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180718225511.14878-26-jsnow@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81413
|
|
|
ae23c9 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 25/35] nbd/server: refactor NBDExportMetaContexts
|
|
|
ae23c9 |
Bugzilla: 1207657
|
|
|
ae23c9 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Use NBDExport pointer instead of just export name: there is no need to
|
|
|
ae23c9 |
store a duplicated name in the struct; moreover, NBDExport will be used
|
|
|
ae23c9 |
further.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
ae23c9 |
Message-Id: <20180609151758.17343-3-vsementsov@virtuozzo.com>
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
[eblake: commit message grammar tweak]
|
|
|
ae23c9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit af736e546717d832168dd332a328bfcf74a0ab3d)
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
nbd/server.c | 23 +++++++++++------------
|
|
|
ae23c9 |
1 file changed, 11 insertions(+), 12 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/nbd/server.c b/nbd/server.c
|
|
|
ae23c9 |
index 942c016..26cc41a 100644
|
|
|
ae23c9 |
--- a/nbd/server.c
|
|
|
ae23c9 |
+++ b/nbd/server.c
|
|
|
ae23c9 |
@@ -88,7 +88,7 @@ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
|
|
|
ae23c9 |
* as selected by NBD_OPT_SET_META_CONTEXT. Also used for
|
|
|
ae23c9 |
* NBD_OPT_LIST_META_CONTEXT. */
|
|
|
ae23c9 |
typedef struct NBDExportMetaContexts {
|
|
|
ae23c9 |
- char export_name[NBD_MAX_NAME_SIZE + 1];
|
|
|
ae23c9 |
+ NBDExport *exp;
|
|
|
ae23c9 |
bool valid; /* means that negotiation of the option finished without
|
|
|
ae23c9 |
errors */
|
|
|
ae23c9 |
bool base_allocation; /* export base:allocation context (block status) */
|
|
|
ae23c9 |
@@ -399,10 +399,9 @@ static int nbd_negotiate_handle_list(NBDClient *client, Error **errp)
|
|
|
ae23c9 |
return nbd_negotiate_send_rep(client, NBD_REP_ACK, errp);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
-static void nbd_check_meta_export_name(NBDClient *client)
|
|
|
ae23c9 |
+static void nbd_check_meta_export(NBDClient *client)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
- client->export_meta.valid &= !strcmp(client->exp->name,
|
|
|
ae23c9 |
- client->export_meta.export_name);
|
|
|
ae23c9 |
+ client->export_meta.valid &= client->exp == client->export_meta.exp;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* Send a reply to NBD_OPT_EXPORT_NAME.
|
|
|
ae23c9 |
@@ -456,7 +455,7 @@ static int nbd_negotiate_handle_export_name(NBDClient *client,
|
|
|
ae23c9 |
|
|
|
ae23c9 |
QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
|
|
|
ae23c9 |
nbd_export_get(client->exp);
|
|
|
ae23c9 |
- nbd_check_meta_export_name(client);
|
|
|
ae23c9 |
+ nbd_check_meta_export(client);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
return 0;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -650,7 +649,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, uint16_t myflags,
|
|
|
ae23c9 |
client->exp = exp;
|
|
|
ae23c9 |
QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
|
|
|
ae23c9 |
nbd_export_get(client->exp);
|
|
|
ae23c9 |
- nbd_check_meta_export_name(client);
|
|
|
ae23c9 |
+ nbd_check_meta_export(client);
|
|
|
ae23c9 |
rc = 1;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
return rc;
|
|
|
ae23c9 |
@@ -835,7 +834,7 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
|
|
|
ae23c9 |
NBDExportMetaContexts *meta, Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
int ret;
|
|
|
ae23c9 |
- NBDExport *exp;
|
|
|
ae23c9 |
+ char export_name[NBD_MAX_NAME_SIZE + 1];
|
|
|
ae23c9 |
NBDExportMetaContexts local_meta;
|
|
|
ae23c9 |
uint32_t nb_queries;
|
|
|
ae23c9 |
int i;
|
|
|
ae23c9 |
@@ -854,15 +853,15 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
|
|
|
ae23c9 |
|
|
|
ae23c9 |
memset(meta, 0, sizeof(*meta));
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- ret = nbd_opt_read_name(client, meta->export_name, NULL, errp);
|
|
|
ae23c9 |
+ ret = nbd_opt_read_name(client, export_name, NULL, errp);
|
|
|
ae23c9 |
if (ret <= 0) {
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- exp = nbd_export_find(meta->export_name);
|
|
|
ae23c9 |
- if (exp == NULL) {
|
|
|
ae23c9 |
+ meta->exp = nbd_export_find(export_name);
|
|
|
ae23c9 |
+ if (meta->exp == NULL) {
|
|
|
ae23c9 |
return nbd_opt_drop(client, NBD_REP_ERR_UNKNOWN, errp,
|
|
|
ae23c9 |
- "export '%s' not present", meta->export_name);
|
|
|
ae23c9 |
+ "export '%s' not present", export_name);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
ret = nbd_opt_read(client, &nb_queries, sizeof(nb_queries), errp);
|
|
|
ae23c9 |
@@ -871,7 +870,7 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
cpu_to_be32s(&nb_queries);
|
|
|
ae23c9 |
trace_nbd_negotiate_meta_context(nbd_opt_lookup(client->opt),
|
|
|
ae23c9 |
- meta->export_name, nb_queries);
|
|
|
ae23c9 |
+ export_name, nb_queries);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (client->opt == NBD_OPT_LIST_META_CONTEXT && !nb_queries) {
|
|
|
ae23c9 |
/* enable all known contexts */
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|