public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib/activate activate.c dev_manager.c
@ 2012-01-25  9:10 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2012-01-25  9:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-25 09:10:14

Modified files:
	lib/activate   : activate.c dev_manager.c 

Log message:
	Thin add support for origin_only suspend of thin volumes
	
	Pass in the origin_only flag also for thin volumes - but curently the flag
	is not used to its best.
	
	FIXME: achieve the state where only  thin volume snapshot origin is
	suspended without its childrens -  let's explore whether this may
	happen automatically inside libdm (might be generic for other targets).
	So the code would not need to annotate the node for this.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.236&r2=1.237
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.266&r2=1.267

--- LVM2/lib/activate/activate.c	2012/01/25 09:00:18	1.236
+++ LVM2/lib/activate/activate.c	2012/01/25 09:10:13	1.237
@@ -1344,7 +1344,7 @@
 		goto_out;
 
 	/* Ignore origin_only unless LV is origin in both old and new metadata */
-	if (!lv_is_origin(lv) || !lv_is_origin(lv_pre))
+	if (!lv_is_thin_volume(lv) && !(lv_is_origin(lv) && lv_is_origin(lv_pre)))
 		laopts->origin_only = 0;
 
 	if (test_mode()) {
--- LVM2/lib/activate/dev_manager.c	2012/01/25 09:06:43	1.266
+++ LVM2/lib/activate/dev_manager.c	2012/01/25 09:10:14	1.267
@@ -1201,8 +1201,13 @@
 	uint32_t s;
 	struct seg_list *sl;
 	struct lv_segment *seg = first_seg(lv);
+	/* FIXME: Resolve skip_childrens
+	struct dm_tree_node *thin_node;
+	const char *uuid;
+	*/
 
-	if (!origin_only && !_add_dev_to_dtree(dm, dtree, lv, NULL))
+	if ((!origin_only || lv_is_thin_volume(lv)) &&
+	    !_add_dev_to_dtree(dm, dtree, lv, NULL))
 		return_0;
 
 	/* FIXME Can we avoid doing this every time? */
@@ -1233,17 +1238,29 @@
 	    !_add_partial_replicator_to_dtree(dm, dtree, lv))
 		return_0;
 
+	if (lv_is_thin_volume(lv)) {
+		/* FIXME: Resolve skip_childrens
+		if (origin_only) {
+			if (!(uuid = build_dm_uuid(dm->mem, lv->lvid.s, NULL)))
+				return_0;
+			if ((thin_node = dm_tree_find_node_by_uuid(dtree, uuid)))
+				dm_tree_node_skip_childrens(thin_node, 1);
+		}
+		*/
+		/* Add thin pool LV layer */
+		lv = seg->pool_lv;
+		seg = first_seg(lv);
+	}
+
 	if (lv_is_thin_pool(lv)) {
-		if (!_add_lv_to_dtree(dm, dtree, seg->metadata_lv, origin_only))
+		if (!_add_lv_to_dtree(dm, dtree, seg->metadata_lv, 0))
 			return_0;
 		/* FIXME code from _create_partial_dtree() should be moved here */
-		if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, 0), origin_only))
+		if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, 0), 0))
 			return_0;
 		if (!_add_dev_to_dtree(dm, dtree, lv, _thin_layer))
 			return_0;
-	} else if (lv_is_thin_volume(lv) &&
-		   !_add_lv_to_dtree(dm, dtree, seg->pool_lv, origin_only))
-		return_0;
+	}
 
 	return 1;
 }
@@ -1260,7 +1277,7 @@
 		return NULL;
 	}
 
-	if (!_add_lv_to_dtree(dm, dtree, lv, lv_is_origin(lv) ? origin_only : 0))
+	if (!_add_lv_to_dtree(dm, dtree, lv, (lv_is_origin(lv) || lv_is_thin_volume(lv)) ? origin_only : 0))
 		goto_bad;
 
 	/* Add any snapshots of this LV */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* LVM2/lib/activate activate.c dev_manager.c
@ 2010-01-13  1:43 snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: snitzer @ 2010-01-13  1:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-01-13 01:43:32

Modified files:
	lib/activate   : activate.c dev_manager.c 

Log message:
	Conditionally push down either the "snapshot-origin" or
	"snapshot-merge" target based on whether the LV is a merging snapshot.
	
	When activating a snapshot-merge target do not attempt to monitor the
	LV for events; the polldaemon will monitor the snapshot as it is
	merged.
	
	Allow "snapshot-merge" target's usage to be parsed via standard
	"snapshot" methods.
	
	NOTE: follow on fixes to the _percent_run change are still needed

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169

--- LVM2/lib/activate/activate.c	2010/01/05 21:08:34	1.161
+++ LVM2/lib/activate/activate.c	2010/01/13 01:43:32	1.162
@@ -754,7 +754,7 @@
 	 * In case of a snapshot device, we monitor lv->snapshot->lv,
 	 * not the actual LV itself.
 	 */
-	if (lv_is_cow(lv))
+	if (lv_is_cow(lv) && !(find_cow(lv)->status & SNAPSHOT_MERGE))
 		return monitor_dev_for_events(cmd, lv->snapshot->lv, monitor);
 
 	/*
--- LVM2/lib/activate/dev_manager.c	2010/01/07 19:54:21	1.168
+++ LVM2/lib/activate/dev_manager.c	2010/01/13 01:43:32	1.169
@@ -395,10 +395,16 @@
 			seg = dm_list_item(segh, struct lv_segment);
 		}
 
-		if (!type || !params || strcmp(type, target_type))
+                /*
+                 * If target status doesn't have 'params' or 'type' is not in the same
+                 * target base class as 'target_type' (e.g. snapshot*, mirror*) skip it
+                 * - allows the situation when 'type' is "snapshot-merge" and
+                 *   'target_type' is "snapshot"
+                 */
+		if (!type || !params || strncmp(type, target_type, strlen(target_type)))
 			continue;
 
-		if (!(segtype = get_segtype_from_string(dm->cmd, type)))
+		if (!(segtype = get_segtype_from_string(dm->cmd, target_type)))
 			continue;
 
 		if (segtype->ops->target_percent &&
@@ -890,6 +896,29 @@
 	return 1;
 }
 
+static int _add_snapshot_merge_target_to_dtree(struct dev_manager *dm,
+					       struct dm_tree_node *dnode,
+					       struct logical_volume *lv)
+{
+	const char *origin_dlid, *cow_dlid, *merge_dlid;
+
+	if (!(origin_dlid = build_dlid(dm, lv->lvid.s, "real")))
+		return_0;
+
+	if (!(cow_dlid = build_dlid(dm, lv->merging_snapshot->cow->lvid.s, "cow")))
+		return_0;
+
+	if (!(merge_dlid = build_dlid(dm, lv->merging_snapshot->cow->lvid.s, NULL)))
+		return_0;
+
+	if (!dm_tree_node_add_snapshot_merge_target(dnode, lv->size, origin_dlid,
+						    cow_dlid, merge_dlid,
+						    lv->merging_snapshot->chunk_size))
+		return_0;
+
+	return 1;
+}
+
 static int _add_snapshot_target_to_dtree(struct dev_manager *dm,
 					   struct dm_tree_node *dnode,
 					   struct logical_volume *lv)
@@ -904,6 +933,9 @@
 		return 0;
 	}
 
+	if (snap_seg->status & SNAPSHOT_MERGE)
+		return 1;
+
 	if (!(origin_dlid = build_dlid(dm, snap_seg->origin->lvid.s, "real")))
 		return_0;
 
@@ -971,11 +1003,21 @@
 		return_0;
 
 	/* If this is a snapshot origin, add real LV */
+	/* If this is a snapshot origin w/ merging snapshot, add cow and real LV */
 	if (lv_is_origin(seg->lv) && !layer) {
 		if (vg_is_clustered(seg->lv->vg)) {
 			log_error("Clustered snapshots are not yet supported");
 			return 0;
 		}
+		if (seg->lv->merging_snapshot) {
+			if (!_add_new_lv_to_dtree(dm, dtree,
+			     seg->lv->merging_snapshot->cow, "cow"))
+				return_0;
+			/*
+			 * Must also add "real" LV for use when
+			 * snapshot-merge target is added
+			 */
+		}
 		if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "real"))
 			return_0;
 	} else if (lv_is_cow(seg->lv) && !layer) {
@@ -992,8 +1034,13 @@
 
 	/* Now we've added its dependencies, we can add the target itself */
 	if (lv_is_origin(seg->lv) && !layer) {
-		if (!_add_origin_target_to_dtree(dm, dnode, seg->lv))
-			return_0;
+		if (!seg->lv->merging_snapshot) {
+			if (!_add_origin_target_to_dtree(dm, dnode, seg->lv))
+				return_0;
+		} else {
+			if (!_add_snapshot_merge_target_to_dtree(dm, dnode, seg->lv))
+				return_0;
+		}
 	} else if (lv_is_cow(seg->lv) && !layer) {
 		if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv))
 			return_0;
@@ -1021,6 +1068,9 @@
 	uint32_t read_ahead_flags = UINT32_C(0);
 	uint16_t udev_flags = 0;
 
+	if (lv_is_cow(lv) && find_cow(lv)->status & SNAPSHOT_MERGE && !layer)
+		return 1;
+
 	if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
 		return_0;
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-25  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25  9:10 LVM2/lib/activate activate.c dev_manager.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2010-01-13  1:43 snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).