Skip to contentSkip to conversation

LVM2 lib/metadata/lv_manip.c lib/metadata/meta ...

PATCH [email protected] 1 participant 1 message Aug 5, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2008-08-05 12:05:26

Modified files:
lib/metadata : lv_manip.c metadata-exported.h metadata.c
. : WHATS_NEW

Log message:
vgremove tries to remove lv snapshot first. Added function lv_remove_with_dependencies().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.154&r2=1.155
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.184&r2=1.185
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.943&r2=1.944

lib/metadata/lv_manip.c +21 -0
@@ -2049,6 +2049,27 @@
 }
 
 /*
+ * remove LVs with its dependencies - LV leaf nodes should be removed first
+ */
+int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
+				const force_t force)
+{
+	struct list *snh, *snht;
+
+        if (lv_is_origin(lv)) {
+		/* remove snapshot LVs first */
+		list_iterate_safe(snh, snht, &lv->snapshot_segs) {
+			if (!lv_remove_with_dependencies(cmd, list_struct_base(snh, struct lv_segment,
+									       origin_list)->cow,
+							 force))
+				return 0;
+		}
+	}
+
+        return lv_remove_single(cmd, lv, force);
+}
+
+/*
  * insert_layer_for_segments_on_pv() inserts a layer segment for a segment area.
  * However, layer modification could split the underlying layer segment.
  * This function splits the parent area according to keep the 1:1 relationship
lib/metadata/metadata-exported.h +3 -0
@@ -416,6 +416,9 @@
 int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
 		     force_t force);
 
+int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *lv,
+				force_t force);
+
 int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
 	      const char *new_name);
 
lib/metadata/metadata.c +2 -2
@@ -298,8 +298,8 @@
 {
 	struct lv_list *lvl;
 
-	list_iterate_items(lvl, &vg->lvs)
-		if (!lv_remove_single(cmd, lvl->lv, force))
+        while ((lvl = list_first(&vg->lvs)))
+		if (!lv_remove_with_dependencies(cmd, lvl->lv, force))
 			return 0;
 
 	return 1;
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@
 Version 2.02.40 - 
 ================================
+  vgremove tries to remove lv snapshot first.
+  Added function lv_remove_with_dependencies().
   Improve file descriptor leak detection to display likely culprit and filename.
   Change clustered mirror kernel module name from cmirror to dm-log-clustered.
   Avoid looping forever in _pv_analyze_mda_raw used by pvck.