Skip to contentSkip to conversation

LVM2 lib/snapshot/snapshot.c libdm/.exported_s ...

PATCH [email protected] 1 participant 1 message Jan 13, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer at sourceware.org 2010-01-13 01:39:45

Modified files:
lib/snapshot : snapshot.c
libdm : .exported_symbols libdevmapper.h
libdm-deptree.c

Log message:
Add support for "snapshot-merge" target.

Introduces new libdevmapper function dm_tree_node_add_snapshot_merge_target

Verifies that the kernel (dm-snapshot) provides the 'snapshot-merge' target.

Activate origin LV as snapshot-merge target. Using snapshot-origin target would be pointless because the origin contains volatile data while a merge is in progress.

Because snapshot-merge target is activated in place of the snapshot-origin target it must be resumed after all other snapshots (just like snapshot-origin does) --- otherwise small window for data corruption would exist.

Ideally the merging snapshot would not be activated at all but if it is to be activated (because snapshot was already active) it _must_ be done after the snapshot-merge. This insures that DM's snapshot-merge target will perform exception handover in the proper order (new->resume before old->resume). DM's snapshot-merge does support handover if the reverse sequence is used (old->resume before new->resume) but DM will fail to resume the old snapshot; leaving it suspended.

To insure the proper activation sequence dm_tree_activate_children() was updated to accommodate an additional 'activation_priority' level. All regular snapshots are 0, snapshot-merge is 1, and merging snapshot is 2.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69

lib/snapshot/snapshot.c +11 -3
@@ -130,17 +130,25 @@
 }
 
 static int _snap_target_present(struct cmd_context *cmd,
-				const struct lv_segment *seg __attribute((unused)),
+				const struct lv_segment *seg,
 				unsigned *attributes __attribute((unused)))
 {
 	static int _snap_checked = 0;
+	static int _snap_merge_checked = 0;
 	static int _snap_present = 0;
+	static int _snap_merge_present = 0;
 
-	if (!_snap_checked)
+	if (!_snap_checked) {
 		_snap_present = target_present(cmd, "snapshot", 1) &&
 		    target_present(cmd, "snapshot-origin", 0);
+		_snap_checked = 1;
+	}
 
-	_snap_checked = 1;
+	if (!_snap_merge_checked && seg && (seg->status & SNAPSHOT_MERGE)) {
+		_snap_merge_present = target_present(cmd, "snapshot-merge", 0);
+		_snap_merge_checked = 1;
+		return _snap_present && _snap_merge_present;
+	}
 
 	return _snap_present;
 }
libdm/.exported_symbols +1 -0
@@ -71,6 +71,7 @@
 dm_tree_children_use_uuid
 dm_tree_node_add_snapshot_origin_target
 dm_tree_node_add_snapshot_target
+dm_tree_node_add_snapshot_merge_target
 dm_tree_node_add_error_target
 dm_tree_node_add_zero_target
 dm_tree_node_add_linear_target
libdm/libdevmapper.h +6 -0
@@ -394,6 +394,12 @@
 					const char *cow_uuid,
 					int persistent,
 					uint32_t chunk_size);
+int dm_tree_node_add_snapshot_merge_target(struct dm_tree_node *node,
+					     uint64_t size,
+					     const char *origin_uuid,
+					     const char *cow_uuid,
+					     const char *merge_uuid,
+					     uint32_t chunk_size);
 int dm_tree_node_add_error_target(struct dm_tree_node *node,
 				     uint64_t size);
 int dm_tree_node_add_zero_target(struct dm_tree_node *node,
libdm/libdm-deptree.c +60 -10

136 lines not on this page · raw message