diff options
author | David Teigland <teigland@redhat.com> | 2016-12-08 13:27:02 -0600 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2016-12-08 13:33:52 -0600 |
commit | 4df2157c7262d17c021d274211d1a2859a824dc5 (patch) | |
tree | 89698be6613b71dd639678b583f3fa4d3361e516 | |
parent | 08cf602be1dfb87a3eee551463c13187d5fc1b30 (diff) | |
download | lvm2-4df2157c7262d17c021d274211d1a2859a824dc5.tar.gz |
toollib: fix lv_is_type for snapshots
-rw-r--r-- | test/shell/lvconvert-thin-raid.sh | 4 | ||||
-rw-r--r-- | test/shell/lvconvert-thin.sh | 4 | ||||
-rw-r--r-- | tools/toollib.c | 17 |
3 files changed, 15 insertions, 10 deletions
diff --git a/test/shell/lvconvert-thin-raid.sh b/test/shell/lvconvert-thin-raid.sh index 7fa8733f6..33e5b6dd9 100644 --- a/test/shell/lvconvert-thin-raid.sh +++ b/test/shell/lvconvert-thin-raid.sh @@ -30,8 +30,8 @@ aux wait_for_sync $vg $lv2 lvchange -an $vg/$lv1 # conversion fails for internal volumes -invalid lvconvert --thinpool $vg/${lv1}_rimage_0 -invalid lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $vg/${lv2}_rimage_0 +not lvconvert --thinpool $vg/${lv1}_rimage_0 +not lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $vg/${lv2}_rimage_0 lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 diff --git a/test/shell/lvconvert-thin.sh b/test/shell/lvconvert-thin.sh index 1999d8649..2144bd23b 100644 --- a/test/shell/lvconvert-thin.sh +++ b/test/shell/lvconvert-thin.sh @@ -58,13 +58,13 @@ lvchange -an $vg/$lv1 # conversion fails for mirror segment type fail lvconvert --thinpool $vg/$lv1 # cannot use same LV -invalid lvconvert --yes --thinpool $vg/$lv2 --poolmetadata $vg/$lv2 +not lvconvert --yes --thinpool $vg/$lv2 --poolmetadata $vg/$lv2 prepare_lvs # conversion fails for internal volumes # can't use --readahead with --poolmetadata -invalid lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 --readahead 512 +not lvconvert --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 --readahead 512 lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 prepare_lvs diff --git a/tools/toollib.c b/tools/toollib.c index 17680b13f..29afe0d0b 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -2498,9 +2498,9 @@ static int _lv_is_type(struct cmd_context *cmd, struct logical_volume *lv, int l switch (lvt_enum) { case striped_LVT: - return seg_is_striped(seg); + return seg_is_striped(seg) && !lv_is_cow(lv); case linear_LVT: - return seg_is_linear(seg); + return seg_is_linear(seg) && !lv_is_cow(lv); case snapshot_LVT: return lv_is_cow(lv); case thin_LVT: @@ -2544,12 +2544,17 @@ int get_lvt_enum(struct logical_volume *lv) { struct lv_segment *seg = first_seg(lv); - if (seg_is_striped(seg)) - return striped_LVT; - if (seg_is_linear(seg)) - return linear_LVT; + /* + * The order these are checked is important, because a snapshot LV has + * a linear seg type. + */ + if (lv_is_cow(lv)) return snapshot_LVT; + if (seg_is_linear(seg)) + return linear_LVT; + if (seg_is_striped(seg)) + return striped_LVT; if (lv_is_thin_volume(lv)) return thin_LVT; if (lv_is_thin_pool(lv)) |