1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-31 05:47:43 +03:00

toollib: fix lv_is_type for snapshots

This commit is contained in:
David Teigland 2016-12-08 13:27:02 -06:00
parent 08cf602be1
commit 4df2157c72
3 changed files with 15 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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))