summaryrefslogtreecommitdiffstats
path: root/lib/snapshot/snapshot.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2010-01-13 01:39:44 +0000
committerMike Snitzer <snitzer@redhat.com>2010-01-13 01:39:44 +0000
commitaa6f4e51a74948c5fea7625b02dc9441e437882b (patch)
treeb6f81ba5698f8f92fc21fd2d821de09ad15eedc2 /lib/snapshot/snapshot.c
parent68e8f5a4a2f17654836580583169736e1d3f0882 (diff)
downloadlvm2-aa6f4e51a74948c5fea7625b02dc9441e437882b.tar.gz
lvm2-aa6f4e51a74948c5fea7625b02dc9441e437882b.tar.xz
lvm2-aa6f4e51a74948c5fea7625b02dc9441e437882b.zip
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.
Diffstat (limited to 'lib/snapshot/snapshot.c')
-rw-r--r--lib/snapshot/snapshot.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 31755921..0e8ac4d6 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -130,17 +130,25 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
}
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;
}