Display avg priority as group priority
authorHannes Reinecke <hare@suse.de>
Wed, 17 Mar 2010 07:32:51 +0000 (08:32 +0100)
committerHannes Reinecke <hare@suse.de>
Tue, 17 May 2011 10:38:42 +0000 (12:38 +0200)
Now average priority is used as path group priority, instead of sum of
priorities of the paths. But while displaying group priority, sum is
being displayed. Change it to print the average priority.

When there are no enabled paths, print 0 as priority.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/print.c

index f6fe621..ba4210e 100644 (file)
@@ -379,6 +379,7 @@ snprint_pg_selector (char * buff, size_t len, struct pathgroup * pgp)
 static int
 snprint_pg_pri (char * buff, size_t len, struct pathgroup * pgp)
 {
+       int avg_priority = 0;
        /*
         * path group priority is not updated for every path prio change,
         * but only on switch group code path.
@@ -386,7 +387,9 @@ snprint_pg_pri (char * buff, size_t len, struct pathgroup * pgp)
         * Printing is another reason to update.
         */
        path_group_prio_update(pgp);
-       return snprint_int(buff, len, pgp->priority);
+       if (pgp->enabled_paths)
+               avg_priority = pgp->priority / pgp->enabled_paths;
+       return snprint_int(buff, len, avg_priority);
 }
 
 static int