[multipath] new '-f' command line flag
authorroot <root@xa-s05.(none)>
Tue, 21 Jun 2005 21:49:09 +0000 (23:49 +0200)
committerroot <root@xa-s05.(none)>
Tue, 21 Jun 2005 21:49:09 +0000 (23:49 +0200)
This selectively removes an unused multipath map.

libmultipath/config.h
libmultipath/devmapper.c
multipath/main.c
multipath/multipath.8

index f71852b..f41b952 100644 (file)
@@ -51,6 +51,7 @@ struct config {
        int checkint;
        int max_checkint;
        int pgfailback;
+       int remove;
 
        char * dev;
        char * multipath;
index 580b6c8..9c0f6d2 100644 (file)
@@ -275,6 +275,15 @@ out:
 }
        
 extern int
+dm_flush_map (char * mapname, char * type)
+{
+       if (!dm_type(mapname, type) || dm_get_opencount(mapname))
+               return 1;
+
+       return dm_simplecmd(DM_DEVICE_REMOVE, mapname);
+}
+
+extern int
 dm_flush_maps (char * type)
 {
        int r = 0;
@@ -297,11 +306,7 @@ dm_flush_maps (char * type)
                goto out;
 
        do {
-               if (dm_type(names->name, type) &&
-                   dm_get_opencount(names->name) == 0 &&
-                   !dm_simplecmd(DM_DEVICE_REMOVE, names->name))
-                       r++;
-
+               r += dm_flush_map(names->name, type);
                next = names->next;
                names = (void *) names + next;
        } while (next);
index 7d674b9..e77ef3a 100644 (file)
@@ -755,7 +755,7 @@ static void
 usage (char * progname)
 {
        fprintf (stderr, VERSION_STRING);
-       fprintf (stderr, "Usage: %s\t[-v level] [-d] [-l|-ll]\n",
+       fprintf (stderr, "Usage: %s\t[-v level] [-d] [-l|-ll|-f|-F]\n",
                progname);
        fprintf (stderr,
                "\t\t\t[-p failover|multibus|group_by_serial|group_by_prio]\n" \
@@ -769,6 +769,7 @@ usage (char * progname)
                "\t-d\t\tdry run, do not create or update devmaps\n" \
                "\t-l\t\tshow multipath topology (sysfs and DM info)\n" \
                "\t-ll\t\tshow multipath topology (maximum info)\n" \
+               "\t-F\t\tflush a multipath device map\n" \
                "\t-F\t\tflush all multipath device maps\n" \
                "\t-p policy\tforce all maps to specified policy :\n" \
                "\t   failover\t\t1 path per priority group\n" \
@@ -876,7 +877,7 @@ main (int argc, char *argv[])
        if (load_config(DEFAULT_CONFIGFILE))
                exit(1);
 
-       while ((arg = getopt(argc, argv, ":qdl::Fi:M:v:p:")) != EOF ) {
+       while ((arg = getopt(argc, argv, ":qdl::Ffi:M:v:p:")) != EOF ) {
                switch(arg) {
                case 1: printf("optarg : %s\n",optarg);
                        break;
@@ -890,6 +891,9 @@ main (int argc, char *argv[])
                case 'd':
                        conf->dry_run = 1;
                        break;
+               case 'f':
+                       conf->remove = 1;
+                       break;
                case 'F':
                        dm_flush_maps(DEFAULT_TARGET);
                        goto out;
@@ -941,6 +945,17 @@ main (int argc, char *argv[])
 
        }
 
+       if (conf->remove) {
+               if (conf->dev_type == DEV_DEVMAP) {
+                       condlog(4, "remove %s map", conf->dev);
+                       dm_flush_map(conf->dev, DEFAULT_TARGET);
+               }
+               else
+                       condlog(0, "must provide a map name to remove");
+
+               goto out;
+       }
+
        /*
         * allocate core vectors to store paths and multipaths
         */
index 19894e9..7133598 100644 (file)
@@ -6,9 +6,7 @@ multipath \- Device mapper target autoconfig
 .RB [\| \-v\ \c
 .IR verbosity \|]
 .RB [\| \-d \|]
-.RB [\| \-l | \-ll \|]
-.RB [\| \-i\ \c
-.IR int \|]
+.RB [\| \-l | \-ll | \-f | \-F \|]
 .RB [\| \-p\ \c
 .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
 .RB [\| device \|]
@@ -41,14 +39,14 @@ show the current multipath topology from information fetched in sysfs and the de
 show the current multipath topology from all available information (sysfs, the device mapper, path checkers ...)
 .TP
 .TP
-.BI \-i " interval"
-multipath target param: polling interval
-.TP
 .BI \-D " major:minor"
 update only the devmap the path pointed by
 .I major:minor
 is in
 .TP
+.B \-f
+flush a multipath device map specified as parameter, if unused
+.TP
 .B \-F
 flush all unused multipath device maps
 .TP