[libmultipath] move pathcount() to libmultipath/structs.c
authorChristophe Varoqui <root@xa-s05.(none)>
Thu, 17 Nov 2005 11:06:03 +0000 (12:06 +0100)
committerChristophe Varoqui <root@xa-s05.(none)>
Thu, 17 Nov 2005 11:06:03 +0000 (12:06 +0100)
Edward Goggin proposed to move it.
Agreed, though I prefer to put it here.

libmultipath/structs.c
libmultipath/structs.h
multipath/main.c
multipathd/main.c

index 1886338..863b29e 100644 (file)
@@ -284,3 +284,19 @@ find_path_by_devt (vector pathvec, char * dev_t)
        return NULL;
 }
 
+extern int
+pathcount (struct multipath * mpp, int state)
+{
+       struct pathgroup *pgp;
+       struct path *pp;
+       int i, j;
+       int count = 0;
+
+       vector_foreach_slot (mpp->pg, pgp, i)
+               vector_foreach_slot (pgp->paths, pp, j)
+                       if (pp->state == state)
+                               count++;
+
+       return count;
+}
+
index 2ba1053..ba51701 100644 (file)
@@ -173,6 +173,8 @@ struct multipath * find_mp_by_minor (vector mp, int minor);
 struct path * find_path_by_devt (vector pathvec, char * devt);
 struct path * find_path_by_dev (vector pathvec, char * dev);
 
+int pathcount (struct multipath *, int);
+
 char sysfs_path[FILE_NAME_SIZE];
 
 #endif
index 8b14ca1..9bd1063 100644 (file)
@@ -345,6 +345,8 @@ setup_map (struct multipath * mpp)
        if (mpp->pgpolicyfn && mpp->pgpolicyfn(mpp))
                return 1;
 
+       mpp->nr_active = pathcount(mpp, PATH_UP);
+
        /*
         * ponders each path group and determine highest prio pg
         * to switch over (default to first)
@@ -362,21 +364,6 @@ setup_map (struct multipath * mpp)
        return 0;
 }
 
-static int
-pathcount (struct multipath * mpp, int state)
-{
-       struct pathgroup *pgp;
-       struct path *pp;
-       int i, j;
-       int count = 0;
-
-       vector_foreach_slot (mpp->pg, pgp, i)
-               vector_foreach_slot (pgp->paths, pp, j)
-                       if (pp->state == state)
-                               count++;
-       return count;
-}
-
 static void
 compute_pgid(struct pathgroup * pgp)
 {
index e1130f0..8fe88e6 100644 (file)
@@ -259,21 +259,6 @@ set_multipath_wwid (struct multipath * mpp)
        dm_get_uuid(mpp->alias, mpp->wwid);
 }
 
-static int
-pathcount (struct multipath *mpp, int state)
-{
-       struct pathgroup *pgp;
-       struct path *pp;
-       int i, j;
-       int count = 0;
-
-       vector_foreach_slot (mpp->pg, pgp, i)
-               vector_foreach_slot (pgp->paths, pp, j)
-                       if (pp->state == state)
-                               count++;
-       return count;
-}
-
 /*
  * mpp->no_path_retry:
  *   -2 (QUEUE) : queue_if_no_path enabled, never turned off