]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/dd/common.sh
1 source "$rootdir/test/common/autotest_common.sh"
2 source "$rootdir/scripts/common.sh"
7 local size
=${3:-0xffff}
9 local bs
=$
((1024 << 10)) # 1M
10 local count=$(((size / bs) + (size % bs ? 1 : 0)))
17 --json <(gen_conf $nvme_ref)
22 for f; do : > "$f"; done
33 # Pick references to all assoc arrays and build subsystem's config
34 # around them. The assoc array should be the name of the rpc method
35 # suffixed with unique _ID (ID may be any string). Default arrays
36 # should be prefixed with _method string. The keys of the array
37 # should store names of the method's parameters - proper quoting
38 # of the values is done here. extra_subsystems[] can store extra
39 # json configuration for different subsystems, other than bdev.
41 methods=("${@:-${!method_@}}")
44 for ref_name in "${methods[@]}"; do
45 method=${ref_name#*method_} method=${method%_*} params=()
47 # FIXME: centos7's Bash got trapped in 2011:
48 # local -n ref=$ref_name -> local: -n: invalid option
49 # HACK: it with eval and partial refs instead.
50 eval "local refs=(\${!${ref_name}[@]})"
53 for param in "${refs[@]}"; do
54 param_ref="${ref_name}[$param]"
55 if [[ ${!param_ref} =~ ^([0-9]+|true|false|\{.*\})$ ]]; then
56 params+=("\"$param\": ${!param_ref}")
58 params+=("\"$param\": \"${!param_ref}\"")
74 jq . <<- JSON | tee /dev/stderr
83 ${extra_subsystems[*]:+,${extra_subsystems[*]}}
100 bytes=({a..z} {0..9})
105 for ((byte = 0; byte < max; byte++)); do
106 string+=${bytes[RANDOM % ${#bytes[@]}]}
108 printf '%b' "$string"
113 get_native_nvme_bs() {
114 # This is now needed since spdk_dd will reject all bs smaller than the
115 # native bs of given nvme. We need to make sure all tests are using
116 # bs >= native_bs. Use identify here so we don't have to switch nvmes
117 # between user space and the kernel back and forth.
120 mapfile -t id < <("$rootdir/build/examples/identify" -r trtype:pcie "traddr:$pci")
122 # Get size of the current LBAF
123 [[ ${id[*]} =~ "Current LBA Format:"\ *"LBA Format #"([0-9]+) ]]
124 lbaf=${BASH_REMATCH[1]}
125 [[ ${id[*]} =~ "LBA Format #$lbaf: Data Size:"\ *([0-9]+) ]]
126 lbaf=${BASH_REMATCH[1]}
132 # Simply check if spdk_dd links to liburing. If yes, log that information.
134 local -g liburing_in_use=0
136 while read -r lib _ so _; do
137 if [[ $lib == liburing.so.* ]]; then
138 printf '* spdk_dd linked to liburing\n'
139 # For sanity, check build config to see if liburing was requested.
140 if [[ -e $rootdir/test/common/build_config.sh ]]; then
141 source "$rootdir/test/common/build_config.sh"
143 if [[ $CONFIG_URING != y ]]; then
144 printf '* spdk_dd built with liburing, but no liburing support requested?\n'
146 if [[ ! -e $so ]]; then
147 printf '* %s is missing, aborting\n' "$lib"
150 export liburing_in_use=1
153 done < <(LD_TRACE_LOADED_OBJECTS=1 "${DD_APP[@]}") >&2