]> sourceware.org Git - lvm2.git/commitdiff
reporting: should not fail with foreign option if lvm1 pvs exist
authorDavid Teigland <teigland@redhat.com>
Tue, 10 Mar 2015 18:56:25 +0000 (13:56 -0500)
committerDavid Teigland <teigland@redhat.com>
Tue, 10 Mar 2015 18:56:25 +0000 (13:56 -0500)
When lvm1 PVs are visible, and lvmetad is used, and the foreign
option was included in the reporting command, the reporting
command would fail after the 'pvscan all devs' function saw
the lvm1 PVs.  There is no reason the command should fail
because of the lvm1 PVs; they should just be ignored.

lib/cache/lvmetad.c
lib/cache/lvmetad.h
tools/lvscan.c
tools/pvscan.c

index aad44235196a539c76e91efe949bacb3b87b37a1..08c58d2fbe375d1973eded74e0e7d9745d95baea 100644 (file)
@@ -136,6 +136,9 @@ void lvmetad_set_socket(const char *sock)
        _lvmetad_socket = sock;
 }
 
+static int _lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler,
+                                   int ignore_obsolete);
+
 static daemon_reply _lvmetad_send(const char *id, ...)
 {
        va_list ap;
@@ -183,7 +186,7 @@ retry:
                                max_remaining_sleep_times--;    /* Sleep once before rescanning the first time, then 5 times each time after that. */
                } else {
                        /* If the re-scan fails here, we try again later. */
-                       (void) lvmetad_pvscan_all_devs(_lvmetad_cmd, NULL);
+                       (void) _lvmetad_pvscan_all_devs(_lvmetad_cmd, NULL, 0);
                        num_rescans++;
                        max_remaining_sleep_times = 5;
                }
@@ -904,7 +907,7 @@ static int _lvmetad_pvscan_single(struct metadata_area *mda, void *baton)
 }
 
 int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
-                         activation_handler handler)
+                         activation_handler handler, int ignore_obsolete)
 {
        struct label *label;
        struct lvmcache_info *info;
@@ -933,9 +936,16 @@ int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
                goto_bad;
 
        if (baton.fid->fmt->features & FMT_OBSOLETE) {
-               log_error("WARNING: Ignoring obsolete format of metadata (%s) on device %s when using lvmetad",
-                         baton.fid->fmt->name, dev_name(dev));
+               if (ignore_obsolete)
+                       log_warn("WARNING: Ignoring obsolete format of metadata (%s) on device %s when using lvmetad",
+                                 baton.fid->fmt->name, dev_name(dev));
+               else
+                       log_error("WARNING: Ignoring obsolete format of metadata (%s) on device %s when using lvmetad",
+                                 baton.fid->fmt->name, dev_name(dev));
                lvmcache_fmt(info)->ops->destroy_instance(baton.fid);
+
+               if (ignore_obsolete)
+                       return 1;
                return 0;
        }
 
@@ -974,7 +984,8 @@ bad:
        return 0;
 }
 
-int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
+static int _lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler,
+                                   int ignore_obsolete)
 {
        struct dev_iter *iter;
        struct device *dev;
@@ -1016,7 +1027,7 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
                        stack;
                        break;
                }
-               if (!lvmetad_pvscan_single(cmd, dev, handler))
+               if (!lvmetad_pvscan_single(cmd, dev, handler, ignore_obsolete))
                        r = 0;
        }
 
@@ -1031,11 +1042,16 @@ int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
        return r;
 }
 
+int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler)
+{
+       return _lvmetad_pvscan_all_devs(cmd, handler, 0);
+}
+
 /* 
  * FIXME Implement this function, skipping PVs known to belong to local or clustered,
  * non-exported VGs.
  */
 int lvmetad_pvscan_foreign_vgs(struct cmd_context *cmd, activation_handler handler)
 {
-       return lvmetad_pvscan_all_devs(cmd, handler);
+       return _lvmetad_pvscan_all_devs(cmd, handler, 1);
 }
index 4d6f107ebad946502b4c7b03b814c29a9b63dcc7..b5bac69e4f67c704ae7d2cc9bdbbc71c22ee3cff 100644 (file)
@@ -153,7 +153,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd,
  * Scan a single device and update lvmetad with the result(s).
  */
 int lvmetad_pvscan_single(struct cmd_context *cmd, struct device *dev,
-                         activation_handler handler);
+                         activation_handler handler, int ignore_obsolete);
 
 int lvmetad_pvscan_all_devs(struct cmd_context *cmd, activation_handler handler);
 int lvmetad_pvscan_foreign_vgs(struct cmd_context *cmd, activation_handler handler);
@@ -180,7 +180,7 @@ int lvmetad_pvscan_foreign_vgs(struct cmd_context *cmd, activation_handler handl
 #    define lvmetad_pv_lookup_by_dev(cmd, dev, found)  (0)
 #    define lvmetad_vg_list_to_lvmcache(cmd)   (1)
 #    define lvmetad_vg_lookup(cmd, vgname, vgid)       (NULL)
-#    define lvmetad_pvscan_single(cmd, dev, handler  (0)
+#    define lvmetad_pvscan_single(cmd, dev, handler, ignore_obsolete)  (0)
 #    define lvmetad_pvscan_all_devs(cmd, handler)      (0)
 #    define lvmetad_pvscan_foreign_vgs(cmd, handler)   (0)
 
index fa9d976948fffe934633f30d75c7738ff1b7c14f..e98c73d0089cf89ed9eeb2ac78b8ad4453d577f6 100644 (file)
@@ -40,7 +40,7 @@ static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume
                                         pvid_s);
                        continue;
                }
-               if (!lvmetad_pvscan_single(cmd, pvl->pv->dev, NULL))
+               if (!lvmetad_pvscan_single(cmd, pvl->pv->dev, NULL, 0))
                        return ECMD_FAILED;
        }
 
index 57091721093147e44c62c16ab33faa867744823e..307187db74aa0a932ef8fff098fee0a0e06bc909 100644 (file)
@@ -277,7 +277,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
                        stack;
                        break;
                }
-               if (!lvmetad_pvscan_single(cmd, dev, handler)) {
+               if (!lvmetad_pvscan_single(cmd, dev, handler, 0)) {
                        ret = ECMD_FAILED;
                        stack;
                        break;
@@ -310,7 +310,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
                        stack;
                        break;
                }
-               if (!lvmetad_pvscan_single(cmd, dev, handler)) {
+               if (!lvmetad_pvscan_single(cmd, dev, handler, 0)) {
                        ret = ECMD_FAILED;
                        stack;
                        break;
This page took 0.042682 seconds and 5 git commands to generate.