From d2f901f04f76cca110475395272e70c83bea816d Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Mon, 6 Oct 2014 08:11:06 +0200 Subject: [PATCH] lvconvert: Forward --splitmirror to a cache origin when applicable. --- test/shell/lvconvert-cache.sh | 14 ++++++++++++++ tools/lvconvert.c | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/shell/lvconvert-cache.sh b/test/shell/lvconvert-cache.sh index 6c2acd9ff..5979912e7 100644 --- a/test/shell/lvconvert-cache.sh +++ b/test/shell/lvconvert-cache.sh @@ -81,4 +81,18 @@ lvs -a $vg/${lv1}_corig_rimage_0 # ensure images are properly renamed dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel lvremove -ff $vg +lvcreate -n corigin -l 10 $vg +lvcreate -n pool -l 10 $vg +lvs -a -o +devices +echo n | not lvconvert --type cache --cachepool $vg/pool $vg/corigin +lvconvert -y --type cache --cachepool $vg/pool $vg/corigin + +lvremove -ff $vg + +# TODO: creating a cache on top of active RAID appears to be broken +lvcreate -n corigin -m 1 --type raid1 -l 10 $vg +lvcreate -n cpool --type cache $vg/corigin -l 10 +lvchange --refresh $vg # fix up DM tables +lvconvert --splitmirrors 1 --name split $vg/corigin $dev1 + vgremove -f $vg diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 09257e333..0d800ec93 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -3064,6 +3064,7 @@ static int _lvconvert_cache(struct cmd_context *cmd, static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle) { + struct logical_volume *origin = NULL; struct lvconvert_params *lp = handle; struct dm_list *failed_pvs; @@ -3102,6 +3103,15 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv, } } + /* forward splitmirror operations to the cache origin, which may be raid + * or old-style mirror */ + if (arg_count(cmd, splitmirrors_ARG) && lv_is_cache_type(lv) + && (origin = seg_lv(first_seg(lv), 0)) && lv_is_cache_origin(origin)) { + log_warn("WARNING: Selected operation does not work with cache-type LVs."); + log_warn("Proceeding using the cache origin LV %s instead", origin->name); + lv = origin; + } + if (!lp->segtype) { /* segtype not explicitly set in _read_params */ lp->segtype = first_seg(lv)->segtype; -- 2.43.5