From 1469679f09307351aa183c1ba54156b30d7f5f4d Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Thu, 16 Aug 2018 08:05:00 +0200 Subject: [PATCH] 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// * If DPDK is not running as root: * If $XDG_RUNTIME_DIR is set, ${XDG_RUNTIME_DIR}/dpdk// * Otherwise, /tmp/dpdk// 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: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/422485 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Chandler-Test-Pool: SPDK Automated Test System --- scripts/setup.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index e801d0b49..1a702b465 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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 {