]> sourceware.org Git - lvm2.git/commitdiff
lvremove: reduce ioctl count
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 8 Mar 2021 13:22:43 +0000 (14:22 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 8 Mar 2021 14:32:10 +0000 (15:32 +0100)
Just like with deactivation, call of 'lv_is_not_in_use()'
now has embeded report for inactivate LV.

Note: this patch cannot be backported to stable-2.02 - as
there lv_is_active() has 'cluster' meaning and differs from lvinfo().

lib/metadata/lv_manip.c

index b93f18e6ec54c5cd9cea541ec414c2ef659b4cfb..5573e6f435731715cd2298d8a956600e30cf5af7 100644 (file)
@@ -6602,26 +6602,27 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
        /* FIXME Ensure not referred to by another existing LVs */
        ask_discard = find_config_tree_bool(cmd, devices_issue_discards_CFG, NULL);
 
-       if (!lv_is_cache_vol(lv) &&
-           lv_is_active(lv)) {
-               if (!lv_check_not_in_use(lv, 1))
-                       return_0;
-
-               if ((force == PROMPT) &&
-                   !lv_is_pending_delete(lv) &&
-                   lv_is_visible(lv)) {
-                       if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
-                               return 0;
-                       if (yes_no_prompt("Do you really want to remove%s active "
-                                         "%slogical volume %s? [y/n]: ",
-                                         ask_discard ? " and DISCARD" : "",
-                                         vg_is_clustered(vg) ? "clustered " : "",
-                                         display_lvname(lv)) == 'n') {
-                               log_error("Logical volume %s not removed.", display_lvname(lv));
-                               return 0;
+       if (!lv_is_cache_vol(lv)) {
+               switch (lv_check_not_in_use(lv, 1)) {
+               case 0: return_0;
+               case 1: /* Active, not in use */
+                       if ((force == PROMPT) &&
+                           !lv_is_pending_delete(lv) &&
+                           lv_is_visible(lv)) {
+                               if (vg->needs_write_and_commit && (!vg_write(vg) || !vg_commit(vg)))
+                                       return 0;
+                               if (yes_no_prompt("Do you really want to remove%s active "
+                                                 "%slogical volume %s? [y/n]: ",
+                                                 ask_discard ? " and DISCARD" : "",
+                                                 vg_is_clustered(vg) ? "clustered " : "",
+                                                 display_lvname(lv)) == 'n') {
+                                       log_error("Logical volume %s not removed.", display_lvname(lv));
+                                       return 0;
+                               }
+                               ask_discard = 0;
                        }
-
-                       ask_discard = 0;
+                       break;
+               default: /* Not active */ ;
                }
        }
 
This page took 0.042169 seconds and 5 git commands to generate.