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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
#!/usr/bin/env bash
# Copyright (C) 2017 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, MA 02110-1301 USA
# Exercise obtaining cache parameter from various sources
# Either command line or metadata profile or implicit default...
SKIP_WITH_LVMPOLLD=1
. lib/inittest
aux have_cache 1 8 0 || skip
PDIR="$LVM_SYSTEM_DIR/profile"
PFILE="cache-test"
aux prepare_profiles
cat <<EOF > "$PDIR/${PFILE}.profile"
allocation {
cache_pool_chunk_size = 128
cache_mode = "writeback"
cache_policy = "mq"
cache_metadata_format = 1
cache_settings {
smq {
sequential_threshold = 300
random_threshold = 500
}
mq {
}
mq {
sequential_threshold = 100
random_threshold = 200
}
writecache {
high_watermark = 60
}
}
}
EOF
cat <<EOF > "$PDIR/${PFILE}1.profile"
allocation {
cache_pool_chunk_size = 512
cache_mode = "passthrough"
cache_policy = "smq"
cache_metadata_format = 1
}
EOF
aux prepare_vg 2 1000000
# Check writecache read data from profile
if aux have_writecache 1 0 0 ; then
lvcreate -n $lv1 -l 4 -an $vg "$dev1"
lvcreate -y --type writecache -l 4 --cachevol $lv1 -n $lv2 --metadataprofile $PFILE $vg "$dev2"
check lv_field $vg/$lv2 cachesettings "high_watermark=60"
lvremove -y $vg
fi
# Check chunk_size is grabbed from configuration
lvcreate -L1G --config 'allocation/cache_pool_chunk_size=512' --type cache-pool $vg/cpool
check lv_field $vg/cpool chunksize "512.00k"
# Check chunk_size can be overruled when caching LV.
lvcreate -H --chunksize 128K -L10 --cachepool $vg/cpool -n $lv1
check lv_field $vg/$lv1 chunksize "128.00k"
lvremove -f $vg
# Check chunk_size is grabbed from metadata profile
lvcreate -L1G --metadataprofile $PFILE --type cache-pool $vg/cpool
#lvcreate -L1G --commandprofile $PFILE --type cache-pool $vg/cpool
# profile name is stored with cache-pool
check lv_field $vg/cpool profile "$PFILE"
# cache chunk size is selected and stored on creation time
check lv_field $vg/cpool chunksize "128.00k"
# cache metadata format is not stored with cache-pool
check lv_field $vg/cpool cachemetadataformat ""
# cache mode is not stored with cache-pool
check lv_field $vg/cpool cachemode ""
# cache policy is not stored with cache-pool
check lv_field $vg/cpool cachepolicy ""
# cache settings are not stored with cache-pool
check lv_field $vg/cpool cachesettings ""
lvcreate -L10 -n $lv1 $vg
lvconvert --metadataprofile "${PFILE}1" -y -H --cachepool $vg/cpool $vg/$lv1
# chunk size 128k is replace with 512k from PFILE1
check lv_field $vg/$lv1 chunksize "512.00k"
# cachemode is from PFILE1
check lv_field $vg/$lv1 cachemode "passthrough"
lvremove -f $vg
lvcreate -L1G --metadataprofile "$PFILE" --type cache-pool $vg/cpool
lvcreate -H -L10 -n $lv1 --cachepool $vg/cpool
# profile name is stored with cache
check lv_field $vg/$lv1 profile "$PFILE"
# cache chunk size is selected and stored on creation time
check lv_field $vg/$lv1 chunksize "128.00k"
# cache metadata format is stored with cache
check lv_field $vg/$lv1 cachemetadataformat "1"
# cache mode is stored with cache
check lv_field $vg/$lv1 cachemode "writeback"
# cache policy is stored with cache
check lv_field $vg/$lv1 cachepolicy "mq"
# cache settings are stored with cache
check lv_field $vg/$lv1 cachesettings "sequential_threshold=100,random_threshold=200"
lvremove -f $vg
#####
lvcreate -L1G --metadataprofile "$PFILE" --type cache-pool $vg/cpool
lvcreate --cachesettings 'sequential_threshold=300' -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 profile "$PFILE"
check lv_field $vg/$lv1 cachesettings "sequential_threshold=300"
lvremove -f $vg
#####
lvcreate -L1G --metadataprofile "$PFILE" --type cache-pool $vg/cpool
lvcreate --chunksize 256 -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 cachemode "writeback"
check lv_field $vg/$lv1 chunksize "256.00k"
lvremove -f $vg
#####
lvcreate -L1G --metadataprofile "$PFILE" --type cache-pool $vg/cpool
lvcreate --metadataprofile "${PFILE}1" -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 chunksize "512.00k"
check lv_field $vg/$lv1 cachemode "passthrough"
lvremove -f $vg
#lvs -a -o+chunksize,cachemode,cachemetadataformat,cachepolicy,cachesettings $vg
vgremove -ff $vg
|