Support for -M --nameorigin and -M --namesnapshot. --nameorigin preserves the name, uuid and major/minor numbers of the origin, --namesnapshot preserves these attributes of the snapshot. Signed-off-by: Mikulas Patocka --- tools/args.h | 2 ++ tools/commands.h | 4 +++- tools/lvconvert.c | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 5 deletions(-) Index: LVM2.2.02.45/tools/args.h =================================================================== --- LVM2.2.02.45.orig/tools/args.h 2009-05-11 13:08:29.000000000 +0200 +++ LVM2.2.02.45/tools/args.h 2009-05-11 13:09:15.000000000 +0200 @@ -98,6 +98,8 @@ arg(size_ARG, 'L', "size", size_mb_arg, arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign, 0) arg(persistent_ARG, 'M', "persistent", yes_no_arg, 0) arg(merge_ARG, 'M', "merge", NULL, 0) +arg(merge_origin_ARG, '\0', "nameorigin", NULL, 0) +arg(merge_snapshot_ARG, '\0', "namesnapshot", NULL, 0) arg(major_ARG, 'j', "major", major_arg, 0) arg(mirrors_ARG, 'm', "mirrors", int_arg_with_sign, 0) arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg, 0) Index: LVM2.2.02.45/tools/commands.h =================================================================== --- LVM2.2.02.45.orig/tools/commands.h 2009-05-11 13:08:29.000000000 +0200 +++ LVM2.2.02.45/tools/commands.h 2009-05-11 13:09:15.000000000 +0200 @@ -116,11 +116,13 @@ xx(lvconvert, "lvconvert " "[-M|--merge]\n" + "\t[--nameorigin]\n" + "\t[--namesnapshot]\n" "\tSnapshotLogicalVolume[Path]\n", alloc_ARG, background_ARG, chunksize_ARG, corelog_ARG, interval_ARG, mirrorlog_ARG, mirrors_ARG, regionsize_ARG, snapshot_ARG, test_ARG, zero_ARG, - merge_ARG) + merge_ARG, merge_origin_ARG, merge_snapshot_ARG) xx(lvcreate, "Create a logical volume", Index: LVM2.2.02.45/tools/lvconvert.c =================================================================== --- LVM2.2.02.45.orig/tools/lvconvert.c 2009-05-11 13:09:03.000000000 +0200 +++ LVM2.2.02.45/tools/lvconvert.c 2009-05-11 13:09:15.000000000 +0200 @@ -16,6 +16,9 @@ #include "polldaemon.h" #include "lv_alloc.h" +#define MERGE_AS_SNAPSHOT 1 +#define MERGE_AS_ORIGIN 2 + struct lvconvert_params { int snapshot; int merge; @@ -131,8 +134,18 @@ static int _read_params(struct lvconvert if (arg_count(cmd, snapshot_ARG)) lp->snapshot = 1; - if (arg_count(cmd, merge_ARG)) - lp->merge = 1; + if (arg_count(cmd, merge_ARG)) { + if (arg_count(cmd, merge_origin_ARG)) { + lp->merge = MERGE_AS_ORIGIN; + } + if (arg_count(cmd, merge_snapshot_ARG)) { + if (lp->merge) goto invalid_merge_args; + lp->merge = MERGE_AS_SNAPSHOT; + } + if (!lp->merge) { + lp->merge = MERGE_AS_ORIGIN; + } + } if (arg_count(cmd, mirrors_ARG)) { lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0); @@ -145,6 +158,7 @@ static int _read_params(struct lvconvert if (lp->merge) { if (arg_count(cmd, regionsize_ARG) || arg_count(cmd, chunksize_ARG) || arg_count(cmd, zero_ARG) || arg_count(cmd, regionsize_ARG)) { +invalid_merge_args: log_error("invalid arguments for snapshot merge"); return 0; } @@ -399,7 +413,7 @@ int lvconvert_poll(struct cmd_context *c &_lvconvert_mirror_fns, "Converted"); else return poll_daemon(cmd, lv_full_name, background, 0, - &_lvconvert_merge_fns, "Merged"); + &_lvconvert_merge_fns, "Remaining"); } static int _insert_lvconvert_layer(struct cmd_context *cmd, @@ -805,7 +819,8 @@ static int lvconvert_merge(struct cmd_co cow_seg->status |= SNAPSHOT_MERGE; origin->merging_snapshot = cow_seg; - swap_lvids(origin, lv); + if (lp->merge == MERGE_AS_SNAPSHOT) + swap_lvids(origin, lv); /* store vg on disk(s) */ if (!vg_write(lv->vg))