summaryrefslogtreecommitdiff
path: root/test/shell/lvconvert-raid-takeover-linear_to_raid4.sh
blob: 6b28cad5cccd6e2b8dc0759ac0c5fd47386b166a (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
#!/usr/bin/env bash

# Copyright (C) 2018 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

which mkfs.ext4 || skip
aux have_raid 1 14 0 || skip

aux prepare_vg 4 32

# FIXME: lvconvert leaks  'error' devices
detect_error_leak_()
{
	dmsetup table -S "name=~^$vg-" | not grep "error" || \
		die "Device(s) with error target should not be here."
}

# Create linear LV
lvcreate -y -L 9M -n $lv $vg
check lv_field $vg/$lv segtype "linear"
check lv_field $vg/$lv data_stripes 1
check lv_field $vg/$lv stripes 1
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
fsck -fn "$DM_DEV_DIR/$vg/$lv"

# Step 1: convert linear -> raid4 (convert to 2-legged raid1)
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
detect_error_leak_
check lv_field $vg/$lv segtype "raid1"
check lv_field $vg/$lv data_stripes 2
check lv_field $vg/$lv stripes 2
aux wait_for_sync $vg $lv

# Step 2: convert linear ->raid4 (convert to raid4)
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
detect_error_leak_
check lv_field $vg/$lv segtype "raid4"
check lv_field $vg/$lv data_stripes 1
check lv_field $vg/$lv stripes 2

# Step 3: convert linear ->raid4 (reshape to add stripes)
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
detect_error_leak_
check lv_field $vg/$lv segtype "raid4"
check lv_field $vg/$lv data_stripes 3
check lv_field $vg/$lv stripes 4

vgremove -ff $vg