]> sourceware.org Git - lvm2.git/commitdiff
cleanup: postpone confirmation prompt for snapshot
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 15 Aug 2014 11:31:53 +0000 (13:31 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 15 Aug 2014 13:06:44 +0000 (15:06 +0200)
Prompt user for confimation after more checks are done.
(So we avoid case prompting and failing after prompt)

tools/lvchange.c

index 992efdebea7e67c9070bc9628246eb1a2218d5bd..f3bef8ba2c31b2004f5580b75b8750c29eaf7960 100644 (file)
@@ -964,26 +964,6 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
                return ECMD_FAILED;
        }
 
-       if (lv_is_cow(lv) && !lv_is_virtual_origin(origin = origin_from_cow(lv)) &&
-           arg_count(cmd, activate_ARG)) {
-               if (origin->origin_count < 2)
-                       snaps_msg[0] = '\0';
-               else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
-                                    " and %u other snapshot(s)",
-                                    origin->origin_count - 1) < 0) {
-                       log_error("Failed to prepare message.");
-                       return ECMD_FAILED;
-               }
-
-               if (!arg_count(cmd, yes_ARG) &&
-                   (yes_no_prompt("Change of snapshot %s will also change its"
-                                  " origin %s%s. Proceed? [y/n]: ", lv->name,
-                                  origin->name, snaps_msg) == 'n')) {
-                       log_error("Logical volume %s not changed.", lv->name);
-                       return ECMD_FAILED;
-               }
-       }
-
        if (lv->status & PVMOVE) {
                log_error("Unable to change pvmove LV %s", lv->name);
                if (arg_count(cmd, activate_ARG))
@@ -1019,6 +999,25 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
                return ECMD_FAILED;
        }
 
+       if (lv_is_cow(lv) && arg_count(cmd, activate_ARG)) {
+               if (origin->origin_count < 2)
+                       snaps_msg[0] = '\0';
+               else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
+                                    " and %u other snapshot(s)",
+                                    origin->origin_count - 1) < 0) {
+                       log_error("Failed to prepare message.");
+                       return ECMD_FAILED;
+               }
+
+               if (!arg_count(cmd, yes_ARG) &&
+                   (yes_no_prompt("Change of snapshot %s will also change its "
+                                  "origin %s%s. Proceed? [y/n]: ", lv->name,
+                                  origin->name, snaps_msg) == 'n')) {
+                       log_error("Logical volume %s not changed.", lv->name);
+                       return ECMD_FAILED;
+               }
+       }
+
        /*
         * FIXME: DEFAULT_BACKGROUND_POLLING should be "unspecified".
         * If --poll is explicitly provided use it; otherwise polling
This page took 0.041504 seconds and 5 git commands to generate.