Spdk/test/ftl/common.sh
paul luse eb53c23236 add (c) and SPDX header to bash files as needed
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc)

For intel copyrights added, --follow and -C95% were used.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I2ef86976095b88a9bf5b1003e59f3943cd6bbe4c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15209
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2022-11-29 08:27:51 +00:00

64 lines
1.8 KiB
Bash

# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2019 Intel Corporation
# All rights reserved.
#
# Common utility functions to be sourced by the libftl test scripts
function clear_lvols() {
stores=$("$rootdir/scripts/rpc.py" bdev_lvol_get_lvstores | jq -r ".[] | .uuid")
for lvs in $stores; do
"$rootdir/scripts/rpc.py" bdev_lvol_delete_lvstore -u $lvs
done
}
function create_nv_cache_bdev() {
local name=$1
local cache_bdf=$2
local base_bdev=$3
# use 5% space of base bdev
local size=$(($(get_bdev_size $base_bdev) * 5 / 100))
# Create NVMe bdev on specified device and split it so that it has the desired size
local nvc_bdev
nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf)
local nvc_size
nvc_size=$(get_bdev_size $nvc_bdev)
if [[ $size -gt $nvc_size ]]; then
size=nvc_size
fi
$rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1
}
function create_base_bdev() {
local name=$1
local base_bdf=$2
local size=$3
# Create NVMe bdev on specified device and split it so that it has the desired size
local base_bdev
base_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $base_bdf)
local base_size
base_size=$(get_bdev_size $base_bdev)
if [[ $size -le $base_size ]]; then
$rootdir/scripts/rpc.py bdev_split_create $base_bdev -s $size 1
else
clear_lvols
lvs=$($rootdir/scripts/rpc.py bdev_lvol_create_lvstore $base_bdev lvs)
$rootdir/scripts/rpc.py bdev_lvol_create ${base_bdev}p0 $size -t -u $lvs
fi
}
# Remove not needed files from shared memory
function remove_shm() {
echo Remove shared memory files
rm -f rm -f /dev/shm/ftl*
rm -f rm -f /dev/hugepages/ftl*
rm -f rm -f /dev/shm/spdk*
rm -f rm -f /dev/shm/iscsi
rm -f rm -f /dev/hugepages/spdk*
}