Skip to contentSkip to conversation

LVM2 patch to clean-up --resync on cluster mirrors

PATCH Jonathan Brassow 1 participant 1 message May 15, 2008

lore
Share & tools
lore
#0 lore raw

If an LV is clustered, it must be deactivated before activating excl. So, we move the deactivate so an LV is deactivated regardless. Then if clustered, we activate excl (to ensure no-one else has it open/active), and deactivate.

This should save us crappy messages like:
[root at bp-xen-01 ~]# lvchange --resync vg/lv1
Do you really want to deactivate logical volume lv1 to resync it? [y/n]: y
Error locking on node bp-xen-01: Volume is busy on another node Can't get exclusive access to clustered volume lv1

tools/lvchange.c +7 -4
Index: LVM2-cvs/tools/lvchange.c
===================================================================
@@ -221,15 +221,18 @@ static int lvchange_resync(struct cmd_co
 		}
 	}
 
+	if (!deactivate_lv(cmd, lv)) {
+		log_error("Unable to deactivate %s for resync", lv->name);
+		return 0;
+	}
+
 	if (vg_is_clustered(lv->vg) && !activate_lv_excl(cmd, lv)) {
 		log_error("Can't get exclusive access to clustered volume %s",
 			  lv->name);
 		return ECMD_FAILED;
-	}
-
-	if (!deactivate_lv(cmd, lv)) {
+	} else if (!deactivate_lv(cmd, lv)) {
 		log_error("Unable to deactivate %s for resync", lv->name);
-		return 0;
+		return ECMD_FAILED;
 	}
 
 	log_lv = first_seg(lv)->log_lv;