Skip to contentSkip to conversation

master - vgchange: move detection of remote exlusivness

PATCH Zdenek Kabelac 1 participant 1 message Dec 4, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=598c82fc077c8a3edfbdb664b41efd89d05b5a10
Commit:        598c82fc077c8a3edfbdb664b41efd89d05b5a10
Parent:        28939dba09fcd36cd0e4e470e73b172f19dd45e8
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Nov 28 23:22:03 2013 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed Dec 4 17:09:51 2013 +0100

vgchange: move detection of remote exlusivness

Since activation takes only read-lock, there could be multiple activation running in parallel.

So instead of checking before taking any real lock, let the locking resolve the problem and just detect if the reason for failure has been remote exlusive activation.

It should be also faster, since each activation does not need to do explicit lock query.

---
 WHATS_NEW        |    1 +
 tools/vgchange.c |   22 +++++++++++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)
WHATS_NEW +1 -0
index 5d41700..60571ff 100644
@@ -1,5 +1,6 @@
 Version 2.02.105 -
 =====================================
+  Test for remote exclusive activation after activation fails.
   Support lvconvert --merge for thin snapshots.
   Add support to read thin device id from table line entry.
   Drop extra test for origin when testing merging origin in lv_refresh().
tools/vgchange.c +11 -11
index b50b444..f9811d2 100644
@@ -121,16 +121,6 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
 		    ((lv->status & PVMOVE) ))
 			continue;
 
-		/*
-		 * If the LV is active exclusive remotely,
-		 * then ignore it here
-		 */
-		if (lv_is_active_exclusive_remotely(lv)) {
-			log_verbose("%s/%s is exclusively active on"
-				    " a remote node", vg->name, lv->name);
-			continue;
-		}
-
 		if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG), 0)) {
 			log_verbose("ACTIVATION_SKIP flag set for LV %s/%s, skipping activation.",
 				    lv->vg->name, lv->name);
@@ -144,7 +134,17 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
 		expected_count++;
 
 		if (!lv_change_activate(cmd, lv, activate)) {
-			stack;
+			if (!lv_is_active_exclusive_remotely(lv))
+				stack;
+			else {
+				/*
+				 * If the LV is active exclusive remotely,
+				 * then ignore it here
+				 */
+				log_verbose("%s/%s is exclusively active on"
+					    " a remote node", vg->name, lv->name);
+				expected_count--; /* not accounted */
+			}
 			continue;
 		}