--- tools/lvconvert.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) Index: LVM2.2.02.70/tools/lvconvert.c =================================================================== --- LVM2.2.02.70.orig/tools/lvconvert.c 2010-07-10 04:08:41.000000000 +0200 +++ LVM2.2.02.70/tools/lvconvert.c 2010-07-10 04:08:46.000000000 +0200 @@ -1417,27 +1417,12 @@ out: return r; } -static int lvconvert_merge(struct cmd_context *cmd, - struct logical_volume *lv, - struct lvconvert_params *lp) +static int lvconvert_merge_on_activate(struct cmd_context *cmd, + struct logical_volume *lv, + struct logical_volume *origin) { - int r = 0; - int merge_on_activate = 0; - struct logical_volume *origin = origin_from_cow(lv); - struct lv_segment *cow_seg = find_cow(lv); struct lvinfo info; - - /* Check if merge is possible */ - if (lv_is_merging_cow(lv)) { - log_error("Snapshot %s is already merging", lv->name); - return 0; - } - if (lv_is_merging_origin(origin)) { - log_error("Snapshot %s is already merging into the origin", - find_merging_cow(origin)->cow->name); - return 0; - } - + int merge_on_activate = 0; /* * Prevent merge with open device(s) as it would likely lead * to application/filesystem failure. Merge on origin's next @@ -1460,6 +1445,30 @@ static int lvconvert_merge(struct cmd_co merge_on_activate = 1; } } + return merge_on_activate; +} + +static int lvconvert_merge(struct cmd_context *cmd, + struct logical_volume *lv, + struct lvconvert_params *lp) +{ + int r = 0; + int merge_on_activate; + struct logical_volume *origin = origin_from_cow(lv); + struct lv_segment *cow_seg = find_cow(lv); + + /* Check if merge is possible */ + if (lv_is_merging_cow(lv)) { + log_error("Snapshot %s is already merging", lv->name); + return 0; + } + if (lv_is_merging_origin(origin)) { + log_error("Snapshot %s is already merging into the origin", + find_merging_cow(origin)->cow->name); + return 0; + } + + merge_on_activate = lvconvert_merge_on_activate(cmd, lv, origin); init_snapshot_merge(cow_seg, origin);