]> sourceware.org Git - lvm2.git/commitdiff
Remove thin volumes before thin pools
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 16 Sep 2011 12:12:51 +0000 (12:12 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 16 Sep 2011 12:12:51 +0000 (12:12 +0000)
When user wants to remove thin pool - check if there are no thin volumes using it.
If so - query before removal (or -ff for no question) and remove them first.

lib/metadata/lv_manip.c

index 2e23e5d8cc02e2b853d4d348108c0b43254d3486..f2d5f5e778fd817a04d68c97a1eb2e651cbf8a85 100644 (file)
@@ -3178,6 +3178,22 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
                }
        }
 
+       if (lv_is_thin_pool(lv) && dm_list_size(&lv->segs_using_this_lv)) {
+               /* remove thin LVs first */
+               if ((force == PROMPT) &&
+                   yes_no_prompt("Do you really want to remove all thin volumes when removing "
+                                 "pool logical volume %s? [y/n]: ", lv->name) == 'n') {
+                       log_error("Logical volume %s not removed", lv->name);
+                       return 0;
+               }
+               dm_list_iterate_safe(snh, snht, &lv->segs_using_this_lv) {
+                       if (!lv_remove_with_dependencies(cmd,
+                                                        dm_list_item(snh, struct seg_list)->seg->lv,
+                                                        force, level + 1))
+                               return 0;
+               }
+       }
+
        return lv_remove_single(cmd, lv, force);
 }
 
This page took 0.045532 seconds and 5 git commands to generate.