]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/ftl/common.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / test / ftl / common.sh
CommitLineData
f67539c2
TL
1# Common utility functions to be sourced by the libftl test scripts
2
3function get_chunk_size() {
4 $SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
5 | grep 'Logical blks per chunk' | sed 's/[^0-9]//g'
6}
7
8function get_num_group() {
9 $SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
10 | grep 'Groups' | sed 's/[^0-9]//g'
11}
12
13function get_num_pu() {
14 $SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
15 | grep 'PUs' | sed 's/[^0-9]//g'
16}
17
18function has_separate_md() {
19 local md_type
20 md_type=$($SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
21 | grep 'Metadata Transferred' | cut -d: -f2)
22 if [[ "$md_type" =~ Separate ]]; then
23 return 0
24 else
25 return 1
26 fi
27}
28
29function create_nv_cache_bdev() {
30 local name=$1
31 local ocssd_bdf=$2
32 local cache_bdf=$3
33 local num_punits=$4
34
35 local bytes_to_mb=$((1024 * 1024))
36 local chunk_size
37 chunk_size=$(get_chunk_size $ocssd_bdf)
38
39 # We need at least 2 bands worth of data + 1 block
40 local size=$((2 * 4096 * chunk_size * num_punits + 1))
41 # Round the size up to the nearest megabyte
42 local size=$(((size + bytes_to_mb) / bytes_to_mb))
43
44 # Create NVMe bdev on specified device and split it so that it has the desired size
45 local nvc_bdev
46 nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf)
47 $rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1
48}
49
50function gen_ftl_nvme_conf() {
51 jq . <<- JSON
52 {
53 "subsystems": [
54 {
55 "subsystem": "bdev",
56 "config": [
57 {
58 "params": {
59 "nvme_adminq_poll_period_us": 100
60 },
61 "method": "bdev_nvme_set_options"
62 }
63 ]
64 }
65 ]
66 }
67 JSON
68}