Import lvm2 from NetBSD
[dragonfly.git] / contrib / lvm2 / dist / test / t-read-ahead.sh
1 #!/bin/sh
2 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3 #
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11
12 #
13 # tests basic functionality of read-ahead and ra regressions
14 #
15
16 test_description='Test read-ahead functionality'
17
18 . ./test-utils.sh
19
20
21 get_lvs_() {
22    lvs --units s --nosuffix --noheadings -o $1 "$vg"/"$lv"
23 }
24
25 check_lvs_() {
26    case $(get_lvs_ $1) in
27     *$2) true ;;
28     *) false ;;
29    esac
30 }
31
32 aux prepare_vg 5
33
34 #COMM "test various read ahead settings (bz450922)"
35 lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg"
36 ra="$(get_lvs_ lv_kernel_read_ahead)"
37 test "$(( ( $ra / 5 ) * 5 ))" -eq $ra
38 lvdisplay "$vg"/"$lv"
39 lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto
40 check_lvs_ lv_read_ahead auto
41 check_lvs_ lv_kernel_read_ahead 5120
42 lvchange -r 640 "$vg/$lv"
43 check_lvs_ lv_read_ahead 640
44 lvremove -ff "$vg"
45
46 #COMM "read ahead is properly inherited from underlying PV"
47 blockdev --setra 768 $dev1
48 lvcreate -n $lv -L4m $vg $dev1
49 test $(blockdev --getra $G_dev_/$vg/$lv) -eq 768
50 lvremove -ff $vg
51
52 # Check default, active/inactive values for read_ahead / kernel_read_ahead
53 lvcreate -n $lv -l 50%FREE $vg
54 lvchange -an $vg/$lv
55 check_lv_field_ $vg/$lv lv_read_ahead auto
56 check_lv_field_ $vg/$lv lv_kernel_read_ahead -1
57 lvchange -r 512 $vg/$lv
58 lvchange -ay $vg/$lv
59 check_lv_field_ $vg/$lv lv_read_ahead 256.00k
60 check_lv_field_ $vg/$lv lv_kernel_read_ahead 256.00k
61 lvremove -ff $vg