summaryrefslogtreecommitdiff
path: root/test/shell/lvconvert-raid-takeover-alloc-failure.sh
blob: 21d051100b423f4404549c45babb5fbd1776ccf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash

# Copyright (C) 017 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA


SKIP_WITH_LVMPOLLD=1

. lib/inittest

aux have_raid 1 9 1 || skip

aux prepare_vg 6

function check_sub_lvs
{
	local vg=$1
	local lv=$2
	local end=$3

	for s in $(seq 0 "$end")
	do
		check lv_exists $vg ${lv}_rmeta_$s
		check lv_exists $vg ${lv}_rimage_$s
	done
}

function check_no_sub_lvs
{
	local vg=$1
	local lv=$2
	local start=$3
	local end=$4

	for s in $(seq "$start" "$end")
	do
		check lv_not_exists $vg ${lv}_rmeta_$s
		check lv_not_exists $vg ${lv}_rimage_$s
	done
}

# Check takover upconversion fails allocation errors nicely without leaving image pair remnants behind

# 6-way striped: neither conversion to raid5 nor raid6 possible
lvcreate -aey --yes --stripes 6 --size 4M --name $lv1 $vg
not lvconvert --yes --type raid4 $vg/$lv1
check lv_field $vg/$lv1 segtype "striped"
check_no_sub_lvs $vg $lv1 0 5

not lvconvert --yes --type raid5 $vg/$lv1
check lv_field $vg/$lv1 segtype "striped"
check_no_sub_lvs $vg $lv1 0 5

not lvconvert --yes --type raid6 $vg/$lv1
check lv_field $vg/$lv1 segtype "striped"
check_no_sub_lvs $vg $lv1 0 5

# raid0_meta conversion is possible
lvconvert --yes --type raid0_meta $vg/$lv1
check lv_field $vg/$lv1 segtype "raid0_meta"
check_sub_lvs $vg $lv1 0 5

lvremove -y $vg

# 5-way striped: conversion to raid5 possible but not to raid6
lvcreate -aey --stripes 5 --size 4M --name $lv1 $vg
not lvconvert --yes --type raid6 $vg/$lv1
check lv_field $vg/$lv1 segtype "striped"
check_no_sub_lvs $vg $lv1 0 5

lvconvert --yes --type raid5 $vg/$lv1
check lv_field $vg/$lv1 segtype "raid5_n"
check lv_field $vg/$lv1 stripes 6
check lv_field $vg/$lv1 datastripes 5
check_sub_lvs $vg $lv1 0 5

lvremove -y $vg

# 4-way striped: conversion to raid5 and raid6 possible
lvcreate -aey --stripes 4 --size 4M --name $lv1 $vg
lvconvert --yes --type raid5 $vg/$lv1
check lv_field $vg/$lv1 segtype "raid5_n"
check lv_field $vg/$lv1 stripes 5
check lv_field $vg/$lv1 datastripes 4
check_sub_lvs $vg $lv1 0 4
check_no_sub_lvs $vg $lv1 5 5

lvremove -y $vg

lvcreate -aey --stripes 4 --size 4M --name $lv1 $vg
lvconvert --yes --type raid6 $vg/$lv1
check lv_field $vg/$lv1 segtype "raid6_n_6"
check lv_field $vg/$lv1 stripes 6
check lv_field $vg/$lv1 datastripes 4
check_sub_lvs $vg $lv1 0 5

vgremove -ff $vg