From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v2 03/23] libmultipath: get rid of selector "hack" in print.c
Date: Tue, 6 Mar 2018 00:14:47 +0100 [thread overview]
Message-ID: <20180305231507.10386-4-mwilck@suse.com> (raw)
In-Reply-To: <20180305231507.10386-1-mwilck@suse.com>
By properly linking the path groups with their parent multipath,
we don't need this "hack" any more.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/dmparser.c | 2 +-
libmultipath/pgpolicies.c | 11 ++++++-----
libmultipath/print.c | 6 +++---
libmultipath/structs.c | 10 ++++++++++
libmultipath/structs.h | 3 ++-
5 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 027ae989781e..783c934f1154 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -267,7 +267,7 @@ int disassemble_map(vector pathvec, char *params, struct multipath *mpp,
if (!pgp)
goto out;
- if (store_pathgroup(mpp->pg, pgp))
+ if (add_pathgroup(mpp, pgp))
goto out;
p += get_word(p, &word);
diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index 4ae4afbccdb7..ac2596ada442 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -120,7 +120,7 @@ int group_by_node_name(struct multipath * mp)
if (!pgp)
goto out1;
- if (store_pathgroup(mp->pg, pgp))
+ if (add_pathgroup(mp, pgp))
goto out2;
/* feed the first path */
@@ -196,7 +196,7 @@ int group_by_serial(struct multipath * mp)
if (!pgp)
goto out1;
- if (store_pathgroup(mp->pg, pgp))
+ if (add_pathgroup(mp, pgp))
goto out2;
/* feed the first path */
@@ -254,7 +254,7 @@ int one_path_per_group(struct multipath *mp)
if (!pgp)
goto out;
- if (store_pathgroup(mp->pg, pgp))
+ if (add_pathgroup(mp, pgp))
goto out1;
if (store_path(pgp->paths, pp))
@@ -293,7 +293,7 @@ int one_group(struct multipath *mp) /* aka multibus */
vector_free(pgp->paths);
- if (store_pathgroup(mp->pg, pgp))
+ if (add_pathgroup(mp, pgp))
goto out1;
pgp->paths = mp->paths;
@@ -367,8 +367,9 @@ int group_by_prio(struct multipath *mp)
if (i < VECTOR_SIZE(mp->pg)) {
if (!vector_insert_slot(mp->pg, i, pgp))
goto out2;
+ pgp->mpp = mp;
} else {
- if (store_pathgroup(mp->pg, pgp))
+ if (add_pathgroup(mp, pgp))
goto out2;
}
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 27636c35e5ff..8fb5c5058965 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -476,7 +476,9 @@ snprint_pri (char * buff, size_t len, struct path * pp)
static int
snprint_pg_selector (char * buff, size_t len, struct pathgroup * pgp)
{
- return snprint_str(buff, len, pgp->selector);
+ const char *s = pgp->mpp->selector;
+
+ return snprint_str(buff, len, s ? s : "");
}
static int
@@ -1030,7 +1032,6 @@ int snprint_multipath_topology(char *buff, int len, struct multipath *mpp,
vector_foreach_slot (mpp->pg, pgp, j) {
f=fmt;
- pgp->selector = mpp->selector; /* hack */
if (j + 1 < VECTOR_SIZE(mpp->pg)) {
strcpy(f, "|-+- " PRINT_PG_INDENT);
} else
@@ -1122,7 +1123,6 @@ snprint_multipath_fields_json (char * buff, int len,
vector_foreach_slot (mpp->pg, pgp, i) {
- pgp->selector = mpp->selector;
fwd += snprint_pathgroup(buff + fwd, len - fwd, PRINT_JSON_GROUP, pgp);
if (fwd >= len)
return fwd;
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 4caad2a40302..1ade1a6705ad 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -318,6 +318,16 @@ store_pathgroup (vector pgvec, struct pathgroup * pgp)
return 0;
}
+int add_pathgroup(struct multipath *mpp, struct pathgroup *pgp)
+{
+ int ret = store_pathgroup(mpp->pg, pgp);
+
+ if (ret)
+ return ret;
+ pgp->mpp = mpp;
+ return 0;
+}
+
int
store_hostgroup(vector hostgroupvec, struct host_group * hgp)
{
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index b951c7b0e157..71b37cc20674 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -340,7 +340,7 @@ struct pathgroup {
int priority;
int enabled_paths;
vector paths;
- char * selector;
+ struct multipath *mpp;
};
struct adapter_group {
@@ -379,6 +379,7 @@ int store_hostgroup(vector hostgroupvec, struct host_group *hgp);
int store_path (vector pathvec, struct path * pp);
int store_pathgroup (vector pgvec, struct pathgroup * pgp);
+int add_pathgroup(struct multipath*, struct pathgroup *);
struct multipath * find_mp_by_alias (vector mp, const char * alias);
struct multipath * find_mp_by_wwid (vector mp, char * wwid);
--
2.16.1
next prev parent reply other threads:[~2018-03-05 23:14 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 23:14 [PATCH v2 00/23] "Foreign" NVMe support for multipath-tools Martin Wilck
2018-03-05 23:14 ` [PATCH v2 01/23] multipath(d)/Makefile: add explicit dependency on libraries Martin Wilck
2018-03-06 7:04 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 02/23] libmultipath: remove unused "stdout helpers" Martin Wilck
2018-03-06 7:04 ` Hannes Reinecke
2018-03-05 23:14 ` Martin Wilck [this message]
2018-03-06 7:05 ` [PATCH v2 03/23] libmultipath: get rid of selector "hack" in print.c Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 04/23] libmultipath: parser: use call-by-value for "snprint" methods Martin Wilck
2018-03-06 7:05 ` Hannes Reinecke
2018-03-15 14:25 ` Bart Van Assche
2018-03-05 23:14 ` [PATCH v2 05/23] libmultipath: don't update path groups when printing Martin Wilck
2018-03-06 7:06 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 06/23] libmultipath/print: use "const" where appropriate Martin Wilck
2018-03-06 7:07 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 07/23] libmultipath: use "const" in devmapper code Martin Wilck
2018-03-06 7:07 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 09/23] multipath-tools: Makefile.inc: use -Werror=cast-qual Martin Wilck
2018-03-06 7:08 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 10/23] libmultipath: add vector_free_const() Martin Wilck
2018-03-06 1:01 ` Bart Van Assche
2018-03-06 7:08 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 11/23] libmultipath: add vector_convert() Martin Wilck
2018-03-06 7:10 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 12/23] libmultipath: "generic multipath" interface Martin Wilck
2018-03-06 7:10 ` Hannes Reinecke
2018-03-07 19:01 ` Benjamin Marzinski
2018-03-05 23:14 ` [PATCH v2 13/23] libmultipath: print: convert API to generic data type Martin Wilck
2018-03-06 7:11 ` Hannes Reinecke
2018-03-07 19:02 ` Benjamin Marzinski
2018-03-05 23:14 ` [PATCH v2 14/23] libmultipath: print: use generic API for get_x_layout() Martin Wilck
2018-03-06 7:12 ` Hannes Reinecke
2018-03-05 23:14 ` [PATCH v2 15/23] libmultipath: API for foreign multipath handling Martin Wilck
2018-03-06 7:12 ` Hannes Reinecke
2018-03-07 19:08 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 16/23] libmultipath/print: add "%G - foreign" wildcard Martin Wilck
2018-03-06 7:13 ` Hannes Reinecke
2018-03-05 23:15 ` [PATCH v2 17/23] libmultipath/foreign: nvme foreign library Martin Wilck
2018-03-06 7:13 ` Hannes Reinecke
2018-03-07 19:09 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 18/23] libmultipath: pathinfo: call into " Martin Wilck
2018-03-06 7:14 ` Hannes Reinecke
2018-03-07 19:10 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 19/23] multipath: use foreign API Martin Wilck
2018-03-06 7:14 ` Hannes Reinecke
2018-03-07 19:11 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 20/23] multipathd: " Martin Wilck
2018-03-06 7:15 ` Hannes Reinecke
2018-03-07 19:25 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 21/23] libmultipath: foreign/nvme: implement path display Martin Wilck
2018-03-06 7:15 ` Hannes Reinecke
2018-03-07 19:27 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 22/23] multipathd: update path group prio in check_path Martin Wilck
2018-03-06 7:16 ` Hannes Reinecke
2018-03-07 20:01 ` Benjamin Marzinski
2018-03-05 23:15 ` [PATCH v2 23/23] multipathd: fix signal blocking logic Martin Wilck
2018-03-06 7:16 ` Hannes Reinecke
2018-03-06 8:55 ` Martin Wilck
2018-03-07 20:24 ` Benjamin Marzinski
[not found] ` <20180305231507.10386-9-mwilck@suse.com>
2018-03-06 7:08 ` [PATCH v2 08/23] libmultipath: fix compiler warnings for -Wcast-qual Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180305231507.10386-4-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox