All of lore.kernel.org
 help / color / mirror / Atom feed
From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/m ...
Date: 13 Jun 2011 22:28:05 -0000	[thread overview]
Message-ID: <20110613222805.12344.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2011-06-13 22:28:05

Modified files:
	.              : WHATS_NEW 
	lib/activate   : activate.c 
	lib/metadata   : lv_manip.c 

Log message:
	Fix last snapshot removal to avoid table reload while a device is suspended.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2013&r2=1.2014
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.197&r2=1.198
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.261&r2=1.262

--- LVM2/WHATS_NEW	2011/06/13 03:32:45	1.2013
+++ LVM2/WHATS_NEW	2011/06/13 22:28:04	1.2014
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Fix last snapshot removal to avoid table reload while a device is suspended.
   Use dm_get_suspended_counter in replacement critical_section logic.
   Downgrade critical_section errors to debug level until it is moved to libdm.
   Fix ignored background polling default in vgchange -ay.
--- LVM2/lib/activate/activate.c	2011/06/11 00:03:07	1.197
+++ LVM2/lib/activate/activate.c	2011/06/13 22:28:04	1.198
@@ -534,6 +534,8 @@
 	if (!activation())
 		return 0;
 
+	log_debug("Checking transient status for LV %s/%s", lv->vg->name, lv->name);
+
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
 		return_0;
 
@@ -556,6 +558,8 @@
 	if (!activation())
 		return 0;
 
+	log_debug("Checking snapshot percent for LV %s/%s", lv->vg->name, lv->name);
+
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
 		return_0;
 
@@ -585,6 +589,8 @@
 	if (!activation())
 		return 0;
 
+	log_debug("Checking mirror percent for LV %s/%s", lv->vg->name, lv->name);
+
 	if (!lv_info(cmd, lv, 0, &info, 0, 0))
 		return_0;
 
@@ -692,7 +698,7 @@
 
 /*
  * These two functions return the number of visible LVs in the state,
- * or -1 on error.
+ * or -1 on error.  FIXME Check this.
  */
 int lvs_in_vg_activated(struct volume_group *vg)
 {
@@ -702,10 +708,11 @@
 	if (!activation())
 		return 0;
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
+	dm_list_iterate_items(lvl, &vg->lvs)
 		if (lv_is_visible(lvl->lv))
 			count += (_lv_active(vg->cmd, lvl->lv) == 1);
-	}
+
+	log_debug("Counted %d active LVs in VG %s", count, vg->name);
 
 	return count;
 }
@@ -718,10 +725,11 @@
 	if (!activation())
 		return 0;
 
-	dm_list_iterate_items(lvl, &vg->lvs) {
+	dm_list_iterate_items(lvl, &vg->lvs)
 		if (lv_is_visible(lvl->lv))
 			count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
-	}
+
+	log_debug("Counted %d open LVs in VG %s", count, vg->name);
 
 	return count;
 }
@@ -822,12 +830,14 @@
 int lv_is_active_exclusive_locally(struct logical_volume *lv)
 {
 	int l, e;
+
 	return _lv_is_active(lv, &l, &e) && l && e;
 }
 
 int lv_is_active_exclusive_remotely(struct logical_volume *lv)
 {
 	int l, e;
+
 	return _lv_is_active(lv, &l, &e) && !l && e;
 }
 
@@ -1258,6 +1268,10 @@
 		goto out;
 	}
 
+	log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name,
+		  error_if_not_active ? "" : " if active",
+		  origin_only ? " without snapshots" : "");
+
 	if (!lv_info(cmd, lv, origin_only, &info, 0, 0))
 		goto_out;
 
@@ -1347,6 +1361,8 @@
 		goto out;
 	}
 
+	log_debug("Deactivating %s/%s.", lv->vg->name, lv->name);
+
 	if (!lv_info(cmd, lv, 0, &info, 1, 0))
 		goto_out;
 
@@ -1454,6 +1470,8 @@
 		goto out;
 	}
 
+	log_debug("Activating %s/%s%s.", lv->vg->name, lv->name, exclusive ? " exclusively" : "");
+
 	if (!lv_info(cmd, lv, 0, &info, 0, 0))
 		goto_out;
 
--- LVM2/lib/metadata/lv_manip.c	2011/06/11 00:03:07	1.261
+++ LVM2/lib/metadata/lv_manip.c	2011/06/13 22:28:05	1.262
@@ -2677,6 +2677,7 @@
 	struct lvinfo info;
 	struct logical_volume *origin = NULL;
 	int was_merging = 0;
+	int reload_required = 0;
 
 	vg = lv->vg;
 
@@ -2738,6 +2739,7 @@
 			return_0;
 	}
 
+	/* FIXME Review and fix the snapshot error paths! */
 	if (!deactivate_lv(cmd, lv)) {
 		log_error("Unable to deactivate logical volume \"%s\"",
 			  lv->name);
@@ -2750,20 +2752,24 @@
 		return 0;
 	}
 
+	/* If no snapshots left, and was not merging, reload without -real. */
+	if (origin && (!lv_is_origin(origin) && !was_merging))
+		reload_required = 1;
+
 	/* store it on disks */
-	if (!vg_write(vg) || !vg_commit(vg))
+	if (!vg_write(vg))
 		return_0;
 
-	/* If no snapshots left, and was not merging, reload without -real. */
-	if (origin && (!lv_is_origin(origin) && !was_merging)) {
-		if (!suspend_lv(cmd, origin)) {
-			log_error("Failed to refresh %s without snapshot.", origin->name);
-			return 0;
-		}
-		if (!resume_lv(cmd, origin)) {
-			log_error("Failed to resume %s.", origin->name);
-			return 0;
-		}
+	if (reload_required && !suspend_lv(cmd, origin))
+		log_error("Failed to refresh %s without snapshot.", origin->name);
+		/* FIXME Falls through because first part of change already in kernel! */
+
+	if (!vg_commit(vg))
+		return_0;
+
+	if (reload_required && !resume_lv(cmd, origin)) {
+		log_error("Failed to resume %s.", origin->name);
+		return 0;
 	}
 
 	backup(vg);



             reply	other threads:[~2011-06-13 22:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 22:28 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-02-18 14:29 LVM2 ./WHATS_NEW lib/activate/activate.c lib/m zkabelac
2011-01-13 14:51 zkabelac
2010-11-05 18:18 prajnoha
2010-11-01 14:17 zkabelac
2009-05-13 21:26 mbroz
2008-01-17 17:17 agk
2007-01-24 16:51 agk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110613222805.12344.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.