2019-06-18 13:19:06 +00:00
|
|
|
# Common utility functions to be sourced by the libftl test scripts
|
|
|
|
|
|
|
|
function get_chunk_size() {
|
2019-10-10 05:37:35 +00:00
|
|
|
$rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" |
|
|
|
|
grep 'Logical blks per chunk' | sed 's/[^0-9]//g'
|
2019-06-18 13:19:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function has_separate_md() {
|
|
|
|
local md_type=$($rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | \
|
|
|
|
grep 'Metadata Transferred' | cut -d: -f2)
|
|
|
|
if [[ "$md_type" =~ Separate ]]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_nv_cache_bdev() {
|
|
|
|
local name=$1
|
|
|
|
local ocssd_bdf=$2
|
|
|
|
local cache_bdf=$3
|
|
|
|
local num_punits=$4
|
|
|
|
|
2019-08-05 13:43:47 +00:00
|
|
|
local bytes_to_mb=$((1024 * 1024))
|
2019-06-18 13:19:06 +00:00
|
|
|
local chunk_size=$(get_chunk_size $ocssd_bdf)
|
|
|
|
|
|
|
|
# We need at least 2 bands worth of data + 1 block
|
2019-08-05 13:43:47 +00:00
|
|
|
local size=$((2 * 4096 * $chunk_size * $num_punits + 1))
|
2019-06-18 13:19:06 +00:00
|
|
|
# Round the size up to the nearest megabyte
|
2019-08-05 13:43:47 +00:00
|
|
|
local size=$((($size + $bytes_to_mb) / $bytes_to_mb))
|
2019-06-18 13:19:06 +00:00
|
|
|
|
|
|
|
# Create NVMe bdev on specified device and split it so that it has the desired size
|
2019-08-23 13:50:51 +00:00
|
|
|
local nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf)
|
2019-09-11 11:10:43 +00:00
|
|
|
$rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1
|
2019-06-18 13:19:06 +00:00
|
|
|
}
|