2019-06-18 13:19:06 +00:00
|
|
|
# Common utility functions to be sourced by the libftl test scripts
|
|
|
|
|
|
|
|
function get_chunk_size() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'Logical blks per chunk' | sed 's/[^0-9]//g'
|
2019-06-18 13:19:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 13:01:27 +00:00
|
|
|
function get_num_group() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'Groups' | sed 's/[^0-9]//g'
|
2019-09-10 13:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_num_pu() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'PUs' | sed 's/[^0-9]//g'
|
2019-09-10 13:01:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-25 07:31:14 +00:00
|
|
|
function gen_ftl_nvme_conf() {
|
2020-05-07 11:27:06 +00:00
|
|
|
jq . <<- JSON
|
2020-03-18 10:23:51 +00:00
|
|
|
{
|
|
|
|
"subsystems": [
|
|
|
|
{
|
|
|
|
"subsystem": "bdev",
|
|
|
|
"config": [
|
|
|
|
{
|
|
|
|
"params": {
|
|
|
|
"nvme_adminq_poll_period_us": 100
|
|
|
|
},
|
|
|
|
"method": "bdev_nvme_set_options"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
JSON
|
2019-10-25 07:31:14 +00:00
|
|
|
}
|
2021-06-10 14:26:26 +00:00
|
|
|
|
|
|
|
get_ftl_nvme_dev() {
|
|
|
|
# Find device with LBA matching the FTL_BLOCK_SIZE
|
|
|
|
local nvmes nvme identify lba
|
|
|
|
|
|
|
|
for nvme in $(nvme_in_userspace); do
|
|
|
|
identify=$("$SPDK_EXAMPLE_DIR/identify" -r trtype:pcie -r "traddr:$nvme")
|
2021-08-13 09:39:27 +00:00
|
|
|
# TODO: Skip zoned nvme devices - such setup for FTL is currently not
|
|
|
|
# supported. See https://github.com/spdk/spdk/issues/1992 for details.
|
|
|
|
[[ $identity =~ "NVMe ZNS Zone Report" ]] && continue
|
2021-06-10 14:26:26 +00:00
|
|
|
[[ $identify =~ "Current LBA Format:"\ +"LBA Format #"([0-9]+) ]]
|
|
|
|
[[ $identify =~ "LBA Format #${BASH_REMATCH[1]}: Data Size:"\ +([0-9]+) ]]
|
|
|
|
lba=${BASH_REMATCH[1]}
|
|
|
|
((lba && lba % FTL_BLOCK_SIZE == 0)) && nvmes+=("$nvme")
|
|
|
|
done
|
|
|
|
((${#nvmes[@]} > 0)) || return 1
|
|
|
|
printf '%s\n' "${nvmes[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
bdev_create_zone() {
|
|
|
|
local base_bdev=$1
|
|
|
|
|
|
|
|
# TODO: Consider use of ZNSed nvme controllers
|
|
|
|
"$rpc_py" bdev_zone_block_create \
|
|
|
|
-b "$ZONE_DEV" \
|
|
|
|
-o "$OPTIMAL_OPEN_ZONES" \
|
|
|
|
-z "$ZONE_CAPACITY" \
|
|
|
|
-n "$base_bdev"
|
|
|
|
}
|
|
|
|
|
|
|
|
bdev_delete_zone() {
|
|
|
|
local zone_dev=$1
|
|
|
|
|
|
|
|
# TODO: Consider use of ZNSed nvme controllers
|
|
|
|
"$rpc_py" bdev_zone_block_delete "$zone_dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Optimal number of zones refers to the number of zones that need to be written at the same
|
|
|
|
# time in order to maximize drive's write bandwidth.
|
|
|
|
# ZONE_CAPACITY * FTL_BLOCK_SIZE * OPTIMAL_OPEN_ZONES should be <= size of the drive.
|
|
|
|
FTL_BLOCK_SIZE=4096
|
|
|
|
ZONE_CAPACITY=4096
|
|
|
|
OPTIMAL_OPEN_ZONES=32
|
|
|
|
ZONE_DEV=zone0
|
|
|
|
|
|
|
|
rpc_py=$rootdir/scripts/rpc.py
|