All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	Martin Wilck <mwilck@suse.com>,
	Muneendra Kumar <mkumar@redhat.com>
Subject: [PATCH 10/16] libmultipath: make pgpolicyfn take a paths vector
Date: Fri,  2 Aug 2019 11:33:36 -0500	[thread overview]
Message-ID: <1564763622-31752-11-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1564763622-31752-1-git-send-email-bmarzins@redhat.com>

To enable future changes, mp->pgpolicyfn() now takes a vector of
paths instead of always using mp->paths.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/pgpolicies.c | 38 +++++++++++++++++++-------------------
 libmultipath/pgpolicies.h | 10 +++++-----
 libmultipath/structs.h    |  2 +-
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index 2e4db74c..2e7c0502 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -93,7 +93,7 @@ int group_paths(struct multipath *mp)
 		return 1;
 
 	if (VECTOR_SIZE(mp->paths) > 0 &&
-	    (!mp->pgpolicyfn || mp->pgpolicyfn(mp))) {
+	    (!mp->pgpolicyfn || mp->pgpolicyfn(mp, mp->paths))) {
 		vector_free(mp->pg);
 		mp->pg = NULL;
 		return 1;
@@ -126,7 +126,7 @@ prios_match(struct path *pp1, struct path *pp2)
 	return (pp1->priority == pp2->priority);
 }
 
-int group_by_match(struct multipath * mp,
+int group_by_match(struct multipath * mp, vector paths,
 		   bool (*path_match_fn)(struct path *, struct path *))
 {
 	int i, j;
@@ -136,17 +136,17 @@ int group_by_match(struct multipath * mp,
 	struct path * pp2;
 
 	/* init the bitmap */
-	bitmap = (int *)MALLOC(VECTOR_SIZE(mp->paths) * sizeof (int));
+	bitmap = (int *)MALLOC(VECTOR_SIZE(paths) * sizeof (int));
 
 	if (!bitmap)
 		goto out;
 
-	for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+	for (i = 0; i < VECTOR_SIZE(paths); i++) {
 
 		if (bitmap[i])
 			continue;
 
-		pp = VECTOR_SLOT(mp->paths, i);
+		pp = VECTOR_SLOT(paths, i);
 
 		/* here, we really got a new pg */
 		pgp = alloc_pathgroup();
@@ -163,12 +163,12 @@ int group_by_match(struct multipath * mp,
 
 		bitmap[i] = 1;
 
-		for (j = i + 1; j < VECTOR_SIZE(mp->paths); j++) {
+		for (j = i + 1; j < VECTOR_SIZE(paths); j++) {
 
 			if (bitmap[j])
 				continue;
 
-			pp2 = VECTOR_SLOT(mp->paths, j);
+			pp2 = VECTOR_SLOT(paths, j);
 
 			if (path_match_fn(pp, pp2)) {
 				if (store_path(pgp->paths, pp2))
@@ -193,35 +193,35 @@ out:
 /*
  * One path group per unique tgt_node_name present in the path vector
  */
-int group_by_node_name(struct multipath * mp)
+int group_by_node_name(struct multipath * mp, vector paths)
 {
-	return group_by_match(mp, node_names_match);
+	return group_by_match(mp, paths, node_names_match);
 }
 
 /*
  * One path group per unique serial number present in the path vector
  */
-int group_by_serial(struct multipath * mp)
+int group_by_serial(struct multipath * mp, vector paths)
 {
-	return group_by_match(mp, serials_match);
+	return group_by_match(mp, paths, serials_match);
 }
 
 /*
  * One path group per priority present in the path vector
  */
-int group_by_prio(struct multipath *mp)
+int group_by_prio(struct multipath *mp, vector paths)
 {
-	return group_by_match(mp, prios_match);
+	return group_by_match(mp, paths, prios_match);
 }
 
-int one_path_per_group(struct multipath *mp)
+int one_path_per_group(struct multipath *mp, vector paths)
 {
 	int i;
 	struct path * pp;
 	struct pathgroup * pgp;
 
-	for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
-		pp = VECTOR_SLOT(mp->paths, i);
+	for (i = 0; i < VECTOR_SIZE(paths); i++) {
+		pp = VECTOR_SLOT(paths, i);
 		pgp = alloc_pathgroup();
 
 		if (!pgp)
@@ -242,7 +242,7 @@ out:
 	return 1;
 }
 
-int one_group(struct multipath *mp)	/* aka multibus */
+int one_group(struct multipath *mp, vector paths)	/* aka multibus */
 {
 	int i;
 	struct path * pp;
@@ -256,8 +256,8 @@ int one_group(struct multipath *mp)	/* aka multibus */
 	if (add_pathgroup(mp, pgp))
 		goto out1;
 
-	for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
-		pp = VECTOR_SLOT(mp->paths, i);
+	for (i = 0; i < VECTOR_SIZE(paths); i++) {
+		pp = VECTOR_SLOT(paths, i);
 
 		if (store_path(pgp->paths, pp))
 			goto out;
diff --git a/libmultipath/pgpolicies.h b/libmultipath/pgpolicies.h
index 11834011..7532d75f 100644
--- a/libmultipath/pgpolicies.h
+++ b/libmultipath/pgpolicies.h
@@ -25,10 +25,10 @@ int group_paths(struct multipath *);
 /*
  * policies
  */
-int one_path_per_group(struct multipath *);
-int one_group(struct multipath *);
-int group_by_serial(struct multipath *);
-int group_by_prio(struct multipath *);
-int group_by_node_name(struct multipath *);
+int one_path_per_group(struct multipath *, vector);
+int one_group(struct multipath *, vector);
+int group_by_serial(struct multipath *, vector);
+int group_by_prio(struct multipath *, vector);
+int group_by_node_name(struct multipath *, vector);
 
 #endif
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 893074eb..a8b9d325 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -295,7 +295,7 @@ struct path {
 	struct gen_path generic_path;
 };
 
-typedef int (pgpolicyfn) (struct multipath *);
+typedef int (pgpolicyfn) (struct multipath *, vector);
 
 struct multipath {
 	char wwid[WWID_SIZE];
-- 
2.17.2

  parent reply	other threads:[~2019-08-02 16:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 16:33 [PATCH 00/16] multipath marginal pathgroups Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 01/16] libmultipath: make vector_foreach_slot_backwards work as expected Benjamin Marzinski
2019-08-14 21:35   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 02/16] libmultipath: add marginal paths and groups infrastructure Benjamin Marzinski
2019-08-14 21:37   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 03/16] tests: add path grouping policy unit tests Benjamin Marzinski
2019-08-14 21:22   ` Martin Wilck
2019-08-16 21:01     ` Benjamin Marzinski
2019-08-19  9:34       ` Martin Wilck
2019-08-14 21:38   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 04/16] libmultipath: add wrapper function around pgpolicyfn Benjamin Marzinski
2019-08-14 21:39   ` Martin Wilck
2019-08-16 21:02     ` Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 05/16] libmultipath: fix double free in pgpolicyfn error paths Benjamin Marzinski
2019-08-14 21:21   ` Martin Wilck
2019-08-14 21:39   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 06/16] libmultipath: remove store_pathgroup Benjamin Marzinski
2019-08-14 21:40   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 07/16] libmultipath: make one_group allocate a new vector Benjamin Marzinski
2019-08-14 21:40   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 08/16] libmultipath: consolidate group_by_* functions Benjamin Marzinski
2019-08-14 21:40   ` Martin Wilck
2019-08-02 16:33 ` [PATCH 09/16] tests: update pgpolicy tests to work with group_paths() Benjamin Marzinski
2019-08-14 21:20   ` Martin Wilck
2019-08-14 21:41   ` Martin Wilck
2019-08-02 16:33 ` Benjamin Marzinski [this message]
2019-08-14 22:05   ` [PATCH 10/16] libmultipath: make pgpolicyfn take a paths vector Martin Wilck
2019-08-16 21:28     ` Benjamin Marzinski
2019-08-20 22:55       ` Benjamin Marzinski
2019-08-21 10:28         ` Martin Wilck
2019-08-02 16:33 ` [PATCH 11/16] libmultipath: make group_paths handle marginal paths Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 12/16] tests: add tests for grouping " Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 13/16] libmultipath: add marginal_pathgroups config option Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 14/16] libmutipath: deprecate delay_*_checks Benjamin Marzinski
2019-08-14 21:20   ` Martin Wilck
2019-08-16 20:47     ` Benjamin Marzinski
2019-08-16 21:51       ` Martin Wilck
2019-08-02 16:33 ` [PATCH 15/16] multipathd: use marginal_pathgroups Benjamin Marzinski
2019-08-02 16:33 ` [PATCH 16/16] multipath: update man pages Benjamin Marzinski
2019-08-14 21:21   ` Martin Wilck
2019-08-16 20:54     ` Benjamin Marzinski

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=1564763622-31752-11-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=mkumar@redhat.com \
    --cc=mwilck@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.