[dm-devel] [PATCH 07/16] libmultipath: make one_group allocate a new vector
Benjamin Marzinski
bmarzins at redhat.com
Fri Aug 2 16:33:33 UTC 2019
All the pgpolicy functions besides one_group() allocate a new vector for
the pathgroups. If one_group() works the same, it is easier to factor
out the common code.
Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>
---
libmultipath/pgpolicies.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/libmultipath/pgpolicies.c b/libmultipath/pgpolicies.c
index d447c46e..1af42f52 100644
--- a/libmultipath/pgpolicies.c
+++ b/libmultipath/pgpolicies.c
@@ -267,24 +267,24 @@ out:
int one_group(struct multipath *mp) /* aka multibus */
{
+ int i;
+ struct path * pp;
struct pathgroup * pgp;
- if (VECTOR_SIZE(mp->paths) > 0) {
- pgp = alloc_pathgroup();
+ pgp = alloc_pathgroup();
- if (!pgp)
- goto out;
+ if (!pgp)
+ goto out;
- vector_free(pgp->paths);
+ if (add_pathgroup(mp, pgp))
+ goto out1;
- if (add_pathgroup(mp, pgp))
- goto out1;
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+ pp = VECTOR_SLOT(mp->paths, i);
- pgp->paths = mp->paths;
- /* Do this to avoid freeing vector in group_paths */
- mp->paths = NULL;
+ if (store_path(pgp->paths, pp))
+ goto out;
}
-
return 0;
out1:
free_pathgroup(pgp, KEEP_PATHS);
--
2.17.2
More information about the dm-devel
mailing list