Commit 1469679f authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

setup.sh: cleanup any leftover DPDK files



SPDK deletes those files automatically for single-process
applications and the multi-process' ones can now be freed
with `./setup.sh cleanup`.

The script clears so called DPDK runtime directories, which
are defined as follows (for DPDK 18.05+):
 * If DPDK is running as root, /var/run/dpdk/<per-pid-prefix>/
 * If DPDK is not running as root:
   * If $XDG_RUNTIME_DIR is set, ${XDG_RUNTIME_DIR}/dpdk/<per-pid-prefix>/
   * Otherwise, /tmp/dpdk/<per-pid-prefix>/

Since DPDK 18.08, even the shared config file is placed in
the runtime dir, making it the only dir we have to clear.

Change-Id: I13f58a98f6a07e609b888b4e816dd45eac10f49c
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/422485


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 8f186a81
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -238,7 +238,20 @@ function configure_linux_pci {
}

function cleanup_linux {
	files_to_clean="$(echo /dev/shm/* | egrep '(spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevtest)_trace|spdk_iscsi_conns' || true)"
	shopt -s extglob nullglob
	dirs_to_clean=""
	dirs_to_clean="$(echo {/var/run,/tmp}/dpdk/spdk{,_pid}+([0-9])) "
	if [[ -d $XDG_RUNTIME_DIR && $XDG_RUNTIME_DIR != *" "* ]]; then
		dirs_to_clean+="$(readlink -e assert_not_empty $XDG_RUNTIME_DIR/dpdk/spdk{,_pid}+([0-9]) || true) "
	fi

	files_to_clean=""
	for dir in $dirs_to_clean; do
		files_to_clean+="$(echo $dir/*) "
	done
	shopt -u extglob nullglob

	files_to_clean+="$(echo /dev/shm/* | egrep '(spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevtest)_trace|spdk_iscsi_conns' || true) "
	files_to_clean="$(readlink -e assert_not_empty $files_to_clean || true)"
	if [[ -z "$files_to_clean" ]]; then
		echo "Clean"
@@ -265,9 +278,18 @@ function cleanup_linux {
			echo "Still open: $f"
		fi
	done

	for dir in $dirs_to_clean; do
	if ! echo "$opened_files" | egrep -q "^$dir\$"; then
		echo "Removing:    $dir"
		rmdir $dir
	else
		echo "Still open: $dir"
	fi
	done
	echo "Clean"

	unset files_to_clean opened_files
	unset dirs_to_clean files_to_clean opened_files
}

function configure_linux {