]> sourceware.org Git - lvm2.git/commitdiff
Some basic checking for presence of device-mapper targets.
authorAlasdair Kergon <agk@redhat.com>
Wed, 5 May 2004 18:11:43 +0000 (18:11 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 5 May 2004 18:11:43 +0000 (18:11 +0000)
lib/activate/dev_manager.c
lib/mirror/mirrored.c
lib/snapshot/snapshot.c
lib/striped/striped.c

index 2e61bed1813935a681b4bb8599edf5a30c34346c..4a98e4c80479d723c9e51705be11aa28d9bc5580 100644 (file)
@@ -2034,6 +2034,58 @@ static int _remove_suspended_lvs(struct dev_manager *dm,
        return 1;
 }
 
+static int _targets_present(struct dev_manager *dm, struct list *lvs)
+{
+       struct logical_volume *lv;
+       struct list *lvh;
+       struct segment_type *segtype;
+       int snapshots = 0, mirrors = 0;
+
+       list_iterate(lvh, lvs) {
+               lv = list_item(lvh, struct lv_list)->lv;
+
+               if (!snapshots)
+                       if (lv_is_cow(lv) || lv_is_origin(lv))
+                               snapshots = 1;
+
+               if (!mirrors)
+                       if (lv->status & PVMOVE)
+                               mirrors = 1;
+       }
+
+       if (mirrors) {
+               if (!(segtype = get_segtype_from_string(dm->cmd, "mirror"))) {
+                       log_error("Can't expand LV: Mirror support "
+                                 "missing from tools?");
+                       return 0;
+               }
+
+               if (!segtype->ops->target_present ||
+                   !segtype->ops->target_present()) {
+                       log_error("Can't expand LV: Mirror support missing "
+                                 "from kernel?");
+                       return 0;
+               }
+       }
+
+       if (snapshots) {
+               if (!(segtype = get_segtype_from_string(dm->cmd, "snapshot"))) {
+                       log_error("Can't expand LV: Snapshot support "
+                                 "missing from tools?");
+                       return 0;
+               }
+
+               if (!segtype->ops->target_present ||
+                   !segtype->ops->target_present()) {
+                       log_error("Can't expand LV: Snapshot support missing "
+                                 "from kernel?");
+                       return 0;
+               }
+       }
+
+       return 1;
+}
+
 static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
 {
        char *dlid;
@@ -2116,6 +2168,12 @@ static int _action(struct dev_manager *dm, struct logical_volume *lv,
                }
        }
 
+       if (!_targets_present(dm, &dm->active_list) ||
+           !_targets_present(dm, &dm->reload_list)) {
+               stack;
+               return 0;
+       }
+
        if (!_execute(dm, lv->vg)) {
                stack;
                return 0;
index b4b64953197b9479616c90d24b815d94e5036c06..7d94201536a9ec41f47e26dc34735c2991175f47 100644 (file)
@@ -26,6 +26,7 @@
 #include "defaults.h"
 #include "lvm-string.h"
 #include "targets.h"
+#include "activate.h"
 
 enum {
        MIRR_DISABLED,
@@ -192,6 +193,19 @@ static int _target_percent(void **target_state, struct pool *mem,
 
        return 1;
 }
+
+static int _target_present(void)
+{
+       static int checked = 0;
+       static int present = 0;
+
+       if (!checked)
+               present = target_present("mirror");
+
+       checked = 1;
+
+       return present;
+}
 #endif
 
 static void _destroy(const struct segment_type *segtype)
@@ -208,6 +222,7 @@ static struct segtype_handler _mirrored_ops = {
 #ifdef DEVMAPPER_SUPPORT
        compose_target_line:_compose_target_line,
        target_percent:_target_percent,
+       target_present:_target_present,
 #endif
        destroy:_destroy,
 };
index feb5faa964f5ff679cc61cebb6839a8902766df8..58b68a50fa076d796db4a81972296162372c181e 100644 (file)
@@ -21,6 +21,7 @@
 #include "segtypes.h"
 #include "text_export.h"
 #include "config.h"
+#include "activate.h"
 
 static const char *_name(const struct lv_segment *seg)
 {
@@ -86,6 +87,7 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
        return 1;
 }
 
+#ifdef DEVMAPPER_SUPPORT
 static int _target_percent(void **target_state, struct pool *mem,
                           struct config_tree *cft, struct lv_segment *seg,
                           char *params, uint64_t *total_numerator,
@@ -108,6 +110,21 @@ static int _target_percent(void **target_state, struct pool *mem,
        return 1;
 }
 
+static int _target_present(void)
+{
+       static int checked = 0;
+       static int present = 0;
+
+       if (!checked)
+               present = target_present("snapshot") &&
+                   target_present("snapshot-origin");
+
+       checked = 1;
+
+       return present;
+}
+#endif
+
 static void _destroy(const struct segment_type *segtype)
 {
        dbg_free((void *) segtype);
@@ -117,7 +134,10 @@ static struct segtype_handler _snapshot_ops = {
        name:_name,
        text_import:_text_import,
        text_export:_text_export,
+#ifdef DEVMAPPER_SUPPORT
        target_percent:_target_percent,
+       target_present:_target_present,
+#endif
        destroy:_destroy,
 };
 
index 3b06c3df3a890e55bc0cf4538db225faa0a48bc3..bf3bc8d516485f8599cf30d2f410c025cc8673c7 100644 (file)
@@ -25,6 +25,7 @@
 #include "str_list.h"
 #include "targets.h"
 #include "lvm-string.h"
+#include "activate.h"
 
 static const char *_name(const struct lv_segment *seg)
 {
@@ -167,6 +168,18 @@ static int _compose_target_line(struct dev_manager *dm, struct pool *mem,
        return compose_areas_line(dm, seg, params, paramsize, pos, 0u,
                                  seg->area_count);
 }
+
+static int _target_present(void)
+{
+       static int checked = 0;
+       static int present = 0;
+
+       if (!checked)
+               present = target_present("linear") && target_present("striped");
+
+       checked = 1;
+       return present;
+}
 #endif
 
 static void _destroy(const struct segment_type *segtype)
@@ -183,6 +196,7 @@ static struct segtype_handler _striped_ops = {
        merge_segments:_merge_segments,
 #ifdef DEVMAPPER_SUPPORT
        compose_target_line:_compose_target_line,
+       target_present:_target_present,
 #endif
        destroy:_destroy,
 };
This page took 0.040686 seconds and 5 git commands to generate.