]> sourceware.org Git - lvm2.git/commitdiff
Allow removal of an invalid snapshot that was to be merged on next activation.
authorMike Snitzer <snitzer@redhat.com>
Fri, 20 Jan 2012 22:03:48 +0000 (22:03 +0000)
committerMike Snitzer <snitzer@redhat.com>
Fri, 20 Jan 2012 22:03:48 +0000 (22:03 +0000)
Don't allow a user to merge an invalid snapshot.

WHATS_NEW
lib/metadata/lv_manip.c
tools/lvconvert.c

index 9a27a30d101a544ec7a24f059fb4c29eb704482e..8db135f17fc127fa98f388570b7637ae9a03da59 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.02.89 - 
 ==================================
+  Allow removal of an invalid snapshot that was to be merged on next activation.
+  Don't allow a user to merge an invalid snapshot.
   Use m and M lv_attr to indicate that a snapshot merge failed in lvs.
   Differentiate between snapshot status of "Invalid" and "Merge failed".
   Lookup snapshot usage percent of origin volume when a snapshot is merging.
index f48919df6e61b13bf0b4dff915ed1e29135fde4e..b0a43de00b4a24c4330dc3a050caede321822f8a 100644 (file)
@@ -3263,15 +3263,27 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
 int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
                                const force_t force, unsigned level)
 {
+       percent_t snap_percent;
        struct dm_list *snh, *snht;
        struct seg_list *sl, *tsl;
+       struct lvinfo info;
 
        if (lv_is_cow(lv)) {
-               /* A merging snapshot cannot be removed directly */
+               /*
+                * A merging snapshot cannot be removed directly unless
+                * it has been invalidated.
+                */
                if (lv_is_merging_cow(lv) && !level) {
-                       log_error("Can't remove merging snapshot logical volume \"%s\"",
-                                 lv->name);
-                       return 0;
+                       if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
+                           info.exists && info.live_table) {
+                               if (lv_snapshot_percent(lv, &snap_percent) &&
+                                   ((snap_percent != PERCENT_INVALID) &&
+                                    (snap_percent != PERCENT_MERGE_FAILED))) {
+                                       log_error("Can't remove merging snapshot logical volume \"%s\"",
+                                                 lv->name);
+                                       return 0;
+                               }
+                       }
                }
        }
 
index 66a25bd4cc14f162afb97803853339f60765f2c2..e6c51cb18de659594f4b04fab6a57645a9bd6d71 100644 (file)
@@ -1709,6 +1709,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
 {
        struct lvconvert_params *lp = handle;
        struct dm_list *failed_pvs;
+       struct lvinfo info;
+       percent_t snap_percent;
 
        if (lv->status & LOCKED) {
                log_error("Cannot convert locked LV %s", lv->name);
@@ -1742,6 +1744,13 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
                                  lv->name);
                        return ECMD_FAILED;
                }
+               if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0)
+                   && info.exists && info.live_table &&
+                   (!lv_snapshot_percent(lv, &snap_percent) ||
+                    snap_percent == PERCENT_INVALID)) {
+                       log_error("Unable to merge invalidated snapshot LV \"%s\"", lv->name);
+                       return ECMD_FAILED;
+               }
                if (!archive(lv->vg)) {
                        stack;
                        return ECMD_FAILED;
This page took 0.042038 seconds and 5 git commands to generate.