Commit db330b74 authored by Karol Latecki's avatar Karol Latecki Committed by Jim Harris
Browse files

test/nvme: do not use mounted nvme disks in perf script



For kernel-* mode do not use mounted nvme disks for tests.

This was not checked previously and could result in losing
all data on NVMes not meant to be used in test.

Change-Id: I336c95b8e79e2592897c6b354e5a20a9c86f1482
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460326


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJohn Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent aec30219
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -26,6 +26,13 @@ NUMJOBS=1
REPEAT_NO=3
NOIOSCALING=false

function is_bdf_not_mounted() {
	local bdf=$1
	local blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}')
	local mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
	return $mountpoints
}

function get_cores(){
	local cpu_list="$1"
	for cpu in ${cpu_list//,/ }; do
@@ -58,8 +65,11 @@ function get_numa_node(){
			echo $(cat /sys/bus/pci/devices/$bdev_bdf/numa_node)
		done
	else
		# Only target not mounted NVMes
		for bdf in $(iter_pci_class_code 01 08 02); do
			if is_bdf_not_mounted $bdf; then
				echo $(cat /sys/bus/pci/devices/$bdf/numa_node)
			fi
		done
	fi
}
@@ -77,8 +87,12 @@ function get_disks(){
		local bdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf)
		echo $(jq -r '.[].name' <<< $bdevs)
	else
		# Only target not mounted NVMes
		for bdf in $(iter_pci_class_code 01 08 02); do
			echo $(ls -l /sys/block/ | grep $bdf |awk '{print $9}')
			if is_bdf_not_mounted $bdf; then
				local blkname=$(ls -l /sys/block/ | grep $bdf | awk '{print $9}')
				echo $blkname
			fi
		done
	fi
}
@@ -183,8 +197,14 @@ function preconditioning(){
	local filename=""
	local i
	sed -i -e "\$a[preconditioning]" $BASE_DIR/config.fio
	for bdf in $(iter_pci_class_code 01 08 02); do
		dev_name='trtype=PCIe traddr='${bdf//:/.}' ns=1'

	# Generate filename argument for FIO.
	# We only want to target NVMes not bound to nvme driver.
	# If they're still bound to nvme that means they were skipped by
	# setup.sh on purpose.
	local nvme_list=$(get_disks nvme)
	for nvme in $nvme_list; do
		dev_name='trtype=PCIe traddr='${nvme//:/.}' ns=1'
		filename+=$(printf %s":" "$dev_name")
	done
	echo "** Preconditioning disks, this can take a while, depending on the size of disks."