Skip to contentSkip to conversation

Clustered snapshots

linux-lvm Federico Simoncelli 1 participant 2 messages Oct 14, 2008

lore
Share & tools
lore
#0 lore raw

Hi all,
I'm trying to use the snapshot feature in a cluster environment but
I keep getting this error:

# lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1
  Clustered snapshots are not yet supported.

Reading the documentation:

http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Cluster_Logical_Volume_Manager/snapshot_command.html

"LVM snapshots are not cluster-aware, so they require exclusive access to a volume. For information on activating logical volumes on individual nodes in a cluster, see Section 4.8, Activating Logical Volumes on Individual Nodes in a Cluster."

"To activate logical volumes exclusively on one node, use the lvchange -aey command."

I followed the instructions above but I get the same result:

# lvchange -aey /dev/vg00/lvol1
# lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1
  Clustered snapshots are not yet supported.

Looking at the LVM2 code (LVM2.2.02.40, tools/lvcreate.c:640):

/* FIXME Allow exclusive activation. */

if (vg_is_clustered(vg)) {
        log_error("Clustered snapshots are not yet supported.");
        return 0;
}

looks like there is no way to activate a snapshot in a clustered volume group. Is the documentation wrong?
Is there anyone actively working on the "exclusive activation" FIXME that is mentioned in the comment?

As a matter of fact I've been able to create a snapshot removing the cluster flag from the volume group:

# vgchange -cn VolGroup01
  Volume group "VolGroup01" successfully changed
# lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1
  Logical volume "snap" created

What problem can arise meanwhile the cluster flag is disabled? Should I just avoid any change to the volume group (lvcreate, lvextend, etc...) or it might lead to really bad behaviours in any way?

Thanks in advance,

Signature · 1 line
Federico.
#1 lore raw
Quoted 8 lines · Federico Simoncelli

Looking at the LVM2 code (LVM2.2.02.40, tools/lvcreate.c:640):

/* FIXME Allow exclusive activation. */

if (vg_is_clustered(vg)) {
       log_error("Clustered snapshots are not yet supported.");
       return 0;
}
Quoted 4 lines

looks like there is no way to activate a snapshot in a clustered volume group. Is the documentation wrong?
Is there anyone actively working on the "exclusive activation" FIXME that is mentioned in the comment?

Hi all,
I worked a little on this issue and I came up with a working patch
for LVM2.2.02.32.
I'm not sure if my work is enough to prevent wrong behaviours but in my tests worked ok.
The same patch should be applied both on the lvm2 and the lvm2-cluster rpm packages in order to work.
To be able to set the lv as exclusive you have to deactivate it on the other nodes with the command:

# lvchange -aln /dev/vg00/lvol1

and then you can create the snapshot:

# lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1
  Logical volume "snap" created

It automatically takes care to set the lv device as exclusive (vgchange -aey). Can anyone review the patch?

Thanks in advance,

Signature · 1 line
Federico.
lib/activate/dev_manager.c +6 -4
diff -uNr LVM2.2.02.32/lib/activate/dev_manager.c LVM2.2.02.32-exclsnap/lib/activate/dev_manager.c
@@ -856,10 +856,12 @@
 
 	/* If this is a snapshot origin, add real LV */
 	if (lv_is_origin(seg->lv) && !layer) {
-		if (seg->lv->vg->status & CLUSTERED) {
-			log_error("Clustered snapshots are not yet supported");
-			return 0;
-		}
+/* This might not be the right place for this check
+ *		if (seg->lv->vg->status & CLUSTERED) {
+ *			log_error("Clustered snapshots are not yet supported");
+ *			return 0;
+ *		}
+ */
 		if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "real"))
 			return_0;
 	} else if (lv_is_cow(seg->lv) && !layer) {
tools/lvcreate.c +4 -5
diff -uNr LVM2.2.02.32/tools/lvcreate.c LVM2.2.02.32-exclsnap/tools/lvcreate.c
@@ -647,16 +647,15 @@
 				  "device-mapper kernel driver");
 			return 0;
 		}
-		/* FIXME Allow exclusive activation. */
-		if (vg_status(vg) & CLUSTERED) {
-			log_error("Clustered snapshots are not yet supported.");
-			return 0;
-		}
 		if (!(org = find_lv(vg, lp->origin))) {
 			log_err("Couldn't find origin volume '%s'.",
 				lp->origin);
 			return 0;
 		}
+		if ((vg_status(vg) & CLUSTERED) && !activate_lv_excl(cmd, org)) {
+			log_error("Clustered snapshots are not yet supported.");
+			return 0;
+		}
 		if (lv_is_cow(org)) {
 			log_error("Snapshots of snapshots are not supported "
 				  "yet.");