xref: /dflybsd-src/contrib/lvm2/dist/test/t-read-ahead.sh (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino#!/bin/sh
286d7f5d3SJohn Marino# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
386d7f5d3SJohn Marino#
486d7f5d3SJohn Marino# This copyrighted material is made available to anyone wishing to use,
586d7f5d3SJohn Marino# modify, copy, or redistribute it subject to the terms and conditions
686d7f5d3SJohn Marino# of the GNU General Public License v.2.
786d7f5d3SJohn Marino#
886d7f5d3SJohn Marino# You should have received a copy of the GNU General Public License
986d7f5d3SJohn Marino# along with this program; if not, write to the Free Software Foundation,
1086d7f5d3SJohn Marino# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1186d7f5d3SJohn Marino
1286d7f5d3SJohn Marino#
1386d7f5d3SJohn Marino# tests basic functionality of read-ahead and ra regressions
1486d7f5d3SJohn Marino#
1586d7f5d3SJohn Marino
1686d7f5d3SJohn Marinotest_description='Test read-ahead functionality'
1786d7f5d3SJohn Marino
1886d7f5d3SJohn Marino. ./test-utils.sh
1986d7f5d3SJohn Marino
2086d7f5d3SJohn Marino
2186d7f5d3SJohn Marinoget_lvs_() {
2286d7f5d3SJohn Marino   lvs --units s --nosuffix --noheadings -o $1 "$vg"/"$lv"
2386d7f5d3SJohn Marino}
2486d7f5d3SJohn Marino
2586d7f5d3SJohn Marinocheck_lvs_() {
2686d7f5d3SJohn Marino   case $(get_lvs_ $1) in
2786d7f5d3SJohn Marino    *$2) true ;;
2886d7f5d3SJohn Marino    *) false ;;
2986d7f5d3SJohn Marino   esac
3086d7f5d3SJohn Marino}
3186d7f5d3SJohn Marino
3286d7f5d3SJohn Marinoaux prepare_vg 5
3386d7f5d3SJohn Marino
3486d7f5d3SJohn Marino#COMM "test various read ahead settings (bz450922)"
3586d7f5d3SJohn Marinolvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg"
3686d7f5d3SJohn Marinora="$(get_lvs_ lv_kernel_read_ahead)"
3786d7f5d3SJohn Marinotest "$(( ( $ra / 5 ) * 5 ))" -eq $ra
3886d7f5d3SJohn Marinolvdisplay "$vg"/"$lv"
3986d7f5d3SJohn Marinolvchange -r auto "$vg"/"$lv" 2>&1 | grep auto
4086d7f5d3SJohn Marinocheck_lvs_ lv_read_ahead auto
4186d7f5d3SJohn Marinocheck_lvs_ lv_kernel_read_ahead 5120
4286d7f5d3SJohn Marinolvchange -r 640 "$vg/$lv"
4386d7f5d3SJohn Marinocheck_lvs_ lv_read_ahead 640
4486d7f5d3SJohn Marinolvremove -ff "$vg"
4586d7f5d3SJohn Marino
4686d7f5d3SJohn Marino#COMM "read ahead is properly inherited from underlying PV"
4786d7f5d3SJohn Marinoblockdev --setra 768 $dev1
4886d7f5d3SJohn Marinolvcreate -n $lv -L4m $vg $dev1
4986d7f5d3SJohn Marinotest $(blockdev --getra $G_dev_/$vg/$lv) -eq 768
5086d7f5d3SJohn Marinolvremove -ff $vg
5186d7f5d3SJohn Marino
5286d7f5d3SJohn Marino# Check default, active/inactive values for read_ahead / kernel_read_ahead
5386d7f5d3SJohn Marinolvcreate -n $lv -l 50%FREE $vg
5486d7f5d3SJohn Marinolvchange -an $vg/$lv
5586d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv lv_read_ahead auto
5686d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv lv_kernel_read_ahead -1
5786d7f5d3SJohn Marinolvchange -r 512 $vg/$lv
5886d7f5d3SJohn Marinolvchange -ay $vg/$lv
5986d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv lv_read_ahead 256.00k
6086d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv lv_kernel_read_ahead 256.00k
6186d7f5d3SJohn Marinolvremove -ff $vg
62