Skip to contentSkip to conversation

get exclusive lock on an LV before removing it.

PATCH New Patrick Caulfield 1 participant 1 message Oct 23, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get exclusive lock on an LV before removing it.

This patch is for BZ#209370 and prevents removing of an LV that is activated exclusively on another node.

patrick

Index: tools/lvremove.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvremove.c,v
retrieving revision 1.48

lvremove.c +10 -0
diff -u -p -r1.48 lvremove.c
@@ -75,6 +75,16 @@ static int lvremove_single(struct cmd_co
 	if (!archive(vg))
 		return ECMD_FAILED;
 
+	/* If the VG is clustered then make sure no-one else is using the LV
+	   we are about to remove */
+	if (vg->status & CLUSTERED) {
+		if (!activate_lv_excl(cmd, lv)) {
+			log_error("Can't get exclusive access to volume \"%s\"",
+				  lv->name);
+			return ECMD_FAILED;
+		}
+	}
+
 	/* FIXME Snapshot commit out of sequence if it fails after here? */
 	if (!deactivate_lv(cmd, lv)) {
 		log_error("Unable to deactivate logical volume \"%s\"",
Signature · 1 line
patrick