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

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

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

Log message:
	Thin add messages only for activation tree
	
	Extend lv_activate_opts with bool flag to know for which purpose
	dtree is created - and add message only for activation tree
	(since that's the only place that may send them).
	
	Extend validation check for thin snapshot creation and test whether
	active snapshot origin is suspended before its snapshot is created
	(useful in recover scenarios) -  in this case also detect, whether
	transaction has been already completed and avoid such suspend check
	failure in that case.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.265&r2=1.266
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44

--- LVM2/lib/activate/activate.h	2012/01/25 08:48:43	1.95
+++ LVM2/lib/activate/activate.h	2012/01/25 09:06:43	1.96
@@ -35,6 +35,7 @@
 	int origin_only;
 	int no_merging;
 	int real_pool;
+	int is_activate;
 	unsigned revert;
 	unsigned read_only;
 };
--- LVM2/lib/activate/dev_manager.c	2012/01/25 08:48:43	1.265
+++ LVM2/lib/activate/dev_manager.c	2012/01/25 09:06:43	1.266
@@ -1974,6 +1974,8 @@
 	char *dlid;
 	int r = 0;
 
+	laopts->is_activate = (action == ACTIVATE);
+
 	if (!(dtree = _create_partial_dtree(dm, lv, laopts->origin_only)))
 		return_0;
 
--- LVM2/lib/thin/thin.c	2012/01/25 08:51:29	1.43
+++ LVM2/lib/thin/thin.c	2012/01/25 09:06:43	1.44
@@ -223,6 +223,8 @@
 	char *metadata_dlid, *pool_dlid;
 	const struct lv_thin_message *lmsg;
 	const struct logical_volume *origin;
+	struct lvinfo info;
+	uint64_t transaction_id = 0;
 
 	if (!laopts->real_pool) {
 		if (!(pool_dlid = build_dm_uuid(mem, seg->lv->lvid.s, "tpool"))) {
@@ -257,10 +259,35 @@
 					       seg->zero_new_blocks ? 0 : 1))
 		return_0;
 
+	/*
+	 * Add messages only for activation tree.
+	 * Otherwise avoid checking for existence of suspended origin.
+	 * Also transation_id is checked only when snapshot origin is active.
+	 * (This might change later)
+	 */
+	if (!laopts->is_activate)
+		return 1;
+
 	dm_list_iterate_items(lmsg, &seg->thin_messages) {
 		switch (lmsg->type) {
 		case DM_THIN_MESSAGE_CREATE_THIN:
 			origin = first_seg(lmsg->u.lv)->origin;
+			/* Check if the origin is suspended */
+			if (origin && lv_info(cmd, origin, 0, &info, 0, 0) &&
+			    info.exists && !info.suspended) {
+				/* Origin is not suspended, but the transaction may have been
+				 * already transfered, so test for transaction_id and
+				 * allow to pass in the message for dmtree processing
+				 * so it will skip all messages later.
+				 */
+				if (!lv_thin_pool_transaction_id(seg->lv, &transaction_id))
+					return_0; /* Thin pool should exist and work */
+				if (transaction_id != seg->transaction_id) {
+					log_error("Can't create snapshot %s as origin %s is not suspended.",
+						  lmsg->u.lv->name, origin->name);
+					return 0;
+				}
+			}
 			log_debug("Thin pool create_%s %s.", (!origin) ? "thin" : "snap", lmsg->u.lv->name);
 			if (!dm_tree_node_add_thin_pool_message(node,
 								(!origin) ? lmsg->type : DM_THIN_MESSAGE_CREATE_SNAP,


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

* LVM2/lib activate/activate.h activate/dev_mana ...
@ 2011-11-03 14:52 zkabelac
  0 siblings, 0 replies; 2+ messages in thread
From: zkabelac @ 2011-11-03 14:52 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-03 14:52:10

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

Log message:
	Add -tpool layer in activation tree
	
	Let's put the overlay device over real thin pool device.
	So we can get the proper locking on cluster.
	Overwise the pool LV would be activate once implicitely
	and in other case explicitely, confusing locking mechanism.
	This patch make the activation of pool LV independent on
	activation of thin LV since they will both implicitely use
	real -thin pool device.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.247&r2=1.248
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30

--- LVM2/lib/activate/activate.h	2011/10/17 14:18:07	1.84
+++ LVM2/lib/activate/activate.h	2011/11/03 14:52:09	1.85
@@ -34,6 +34,7 @@
 	int exclusive;
 	int origin_only;
 	int no_merging;
+	int real_pool;
 	unsigned revert;
 };
 
--- LVM2/lib/activate/dev_manager.c	2011/10/28 20:34:45	1.247
+++ LVM2/lib/activate/dev_manager.c	2011/11/03 14:52:09	1.248
@@ -1100,13 +1100,16 @@
 		return_0;
 
 	if (lv_is_thin_pool(lv)) {
-		    if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_metadata_lv, origin_only))
-			    return_0;
-		    if (!_add_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), origin_only))
-			    return_0;
+		if (!_add_dev_to_dtree(dm, dtree, lv, "tpool"))
+			return_0;
+		if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_metadata_lv, origin_only))
+			return_0;
+		/* FIXME code from _create_partial_dtree() should be moved here */
+		if (!_add_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), origin_only))
+			return_0;
 	} else if (lv_is_thin_volume(lv)) {
-		    if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_lv, origin_only))
-			    return_0;
+		if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->pool_lv, origin_only))
+			return_0;
 	}
 
 	return 1;
@@ -1451,6 +1454,7 @@
 	struct dm_list *snh;
 	struct lv_segment *seg_present;
 	const char *target_name;
+	struct lv_activate_opts lva;
 
 	/* Ensure required device-mapper targets are loaded */
 	seg_present = find_cow(seg->lv) ? : seg;
@@ -1495,13 +1499,18 @@
 	} else if (lv_is_cow(seg->lv) && !layer) {
 		if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow"))
 			return_0;
-	} else if (lv_is_thin_volume(seg->lv)) {
-		if (!_add_new_lv_to_dtree(dm, dtree, seg->pool_lv, laopts, NULL))
+	} else if (!layer && (lv_is_thin_pool(seg->lv) ||
+			      lv_is_thin_volume(seg->lv))) {
+		lva = *laopts;
+		lva.real_pool = 1;
+		if (!_add_new_lv_to_dtree(dm, dtree, lv_is_thin_pool(seg->lv) ?
+					  seg->lv : seg->pool_lv, &lva, "tpool"))
 			return_0;
 	} else {
 		if (lv_is_thin_pool(seg->lv) &&
 		    !_add_new_lv_to_dtree(dm, dtree, seg->pool_metadata_lv, laopts, NULL))
 			return_0;
+
 		/* Add any LVs used by this segment */
 		for (s = 0; s < seg->area_count; s++) {
 			if ((seg_type(seg, s) == AREA_LV) &&
--- LVM2/lib/thin/thin.c	2011/11/03 14:45:01	1.29
+++ LVM2/lib/thin/thin.c	2011/11/03 14:52:10	1.30
@@ -223,6 +223,21 @@
 	char *metadata_dlid, *pool_dlid;
 	const struct lv_thin_message *lmsg;
 
+	if (!laopts->real_pool) {
+		if (!(pool_dlid = build_dm_uuid(mem, seg->lv->lvid.s, "tpool"))) {
+			log_error("Failed to build uuid for thin pool LV %s.", seg->pool_lv->name);
+			return 0;
+		}
+
+		//if (!dm_tree_node_add_thin_target(node, len, pool_dlid,
+		//				    DM_THIN_ERROR_DEVICE_ID))
+		if (!dm_tree_node_add_linear_target(node, len) ||
+		    !dm_tree_node_add_target_area(node, NULL, pool_dlid, 0))
+			return_0;
+
+		return 1;
+	}
+
 	if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) {
 		log_error("Failed to build uuid for metadata LV %s.",
 			  seg->pool_metadata_lv->name);
@@ -356,14 +371,29 @@
 				 struct dm_tree_node *node, uint64_t len,
 				 uint32_t *pvmove_mirror_count __attribute__((unused)))
 {
-	char *thin_pool_dlid;
+	char *pool_dlid;
+	uint32_t device_id = seg->device_id;
 
-	if (!(thin_pool_dlid = build_dm_uuid(mem, seg->pool_lv->lvid.s, NULL))) {
-		log_error("Failed to build uuid for thin pool LV %s.", seg->pool_lv->name);
+	if (!(pool_dlid = build_dm_uuid(mem, seg->pool_lv->lvid.s, "tpool"))) {
+		log_error("Failed to build uuid for pool LV %s.",
+			  seg->pool_lv->name);
 		return 0;
 	}
 
-	if (!dm_tree_node_add_thin_target(node, len, thin_pool_dlid, seg->device_id))
+#if 0
+{
+	/* If we would need to activate 'to be deleted' thin LVs */
+	struct lv_thin_message *tmsg;
+	dm_list_iterate_items(tmsg, &first_seg(seg->pool_lv)->thin_messages)
+		/* If this node is going to be deleted - use the error target */
+		if ((tmsg->type == DM_THIN_MESSAGE_DELETE) &&
+		    (tmsg->u.delete_id == seg->device_id)) {
+			device_id = DM_THIN_ERROR_DEVICE_ID;
+			break;
+		}
+}
+#endif
+	if (!dm_tree_node_add_thin_target(node, len, pool_dlid, device_id))
 		return_0;
 
 	return 1;


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

end of thread, other threads:[~2012-01-25  9:06 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:06 LVM2/lib activate/activate.h activate/dev_mana zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2011-11-03 14:52 zkabelac

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).