summaryrefslogtreecommitdiffstats
path: root/lib/snapshot/snapshot.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2010-01-13 01:35:49 +0000
committerMike Snitzer <snitzer@redhat.com>2010-01-13 01:35:49 +0000
commit68e8f5a4a2f17654836580583169736e1d3f0882 (patch)
treebb335f2aafd72fb871b8b983f3c323ffdbd80932 /lib/snapshot/snapshot.c
parent109e6334b0d9697fd84090fef9e85dbef5015a17 (diff)
downloadlvm2-68e8f5a4a2f17654836580583169736e1d3f0882.tar.gz
lvm2-68e8f5a4a2f17654836580583169736e1d3f0882.tar.xz
lvm2-68e8f5a4a2f17654836580583169736e1d3f0882.zip
Add 'SNAPSHOT_MERGE' lv_segment 'status' flag.
Make 'merging_snapshot' pointer that points from the origin to the segment that represents the merging snapshot. Import/export 'merging_store' metadata. Do not allow creating snapshots while another snapshot is merging. Snapshot created in this state would certainly contain invalid data. NOTE: patches at the end of this series will remove 'merging_snapshot' and will introduce helpful wrappers and cleanups.
Diffstat (limited to 'lib/snapshot/snapshot.c')
-rw-r--r--lib/snapshot/snapshot.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index b4584427..31755921 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -37,7 +37,7 @@ static int _snap_text_import(struct lv_segment *seg, const struct config_node *s
uint32_t chunk_size;
const char *org_name, *cow_name;
struct logical_volume *org, *cow;
- int old_suppress;
+ int old_suppress, merge = 0;
if (!get_config_uint32(sn, "chunk_size", &chunk_size)) {
log_error("Couldn't read chunk size for snapshot.");
@@ -46,7 +46,10 @@ static int _snap_text_import(struct lv_segment *seg, const struct config_node *s
old_suppress = log_suppress(1);
- if (!(cow_name = find_config_str(sn, "cow_store", NULL))) {
+ cow_name = find_config_str(sn, "merging_store", NULL);
+ if (cow_name) {
+ merge = 1;
+ } else if (!(cow_name = find_config_str(sn, "cow_store", NULL))) {
log_suppress(old_suppress);
log_error("Snapshot cow storage not specified.");
return 0;
@@ -72,7 +75,7 @@ static int _snap_text_import(struct lv_segment *seg, const struct config_node *s
return 0;
}
- init_snapshot_seg(seg, org, cow, chunk_size);
+ init_snapshot_seg(seg, org, cow, chunk_size, merge);
return 1;
}
@@ -81,7 +84,10 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
{
outf(f, "chunk_size = %u", seg->chunk_size);
outf(f, "origin = \"%s\"", seg->origin->name);
- outf(f, "cow_store = \"%s\"", seg->cow->name);
+ if (!(seg->status & SNAPSHOT_MERGE))
+ outf(f, "cow_store = \"%s\"", seg->cow->name);
+ else
+ outf(f, "merging_store = \"%s\"", seg->cow->name);
return 1;
}