Commit bfe2897d authored by Ziye Yang's avatar Ziye Yang Committed by Ben Walker
Browse files

nvmf,target: solve shutdown coredump issue



It is caused by this commit:
4163626c

nvmf_tgt_delete_subsystem registers the poller
with function subsystem_delete_event.
subsystem_delete_event is called asynchronously,
the deletion should happen in this function.
Otherwise, with the current code,

g_subsystems_shutdown = true
TAILQ_EMPTY(&g_subsystems) = true
when subsystem_delete_event is firstly called.

If there are multiple subsystems, the logic is wrong.
Thus other subsystem will never be delete. since
we already execute shutdown_complete().

Also add related test scripts.

Change-Id: I3823563fc9e8611c11a6d798685ff64e2939842e
Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
parent b21fd064
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ subsystem_delete_event(void *arg1, void *arg2)
	struct nvmf_tgt_subsystem *app_subsys = arg1;
	struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;

	TAILQ_REMOVE(&g_subsystems, app_subsys, tailq);
	free(app_subsys);

	spdk_nvmf_delete_subsystem(subsystem);
@@ -111,7 +112,6 @@ shutdown_subsystems(void)

	g_subsystems_shutdown = true;
	TAILQ_FOREACH_SAFE(app_subsys, &g_subsystems, tailq, tmp) {
		TAILQ_REMOVE(&g_subsystems, app_subsys, tailq);
		nvmf_tgt_delete_subsystem(app_subsys);
	}
}
@@ -286,7 +286,6 @@ nvmf_tgt_shutdown_subsystem_by_nqn(const char *nqn)

	TAILQ_FOREACH_SAFE(tgt_subsystem, &g_subsystems, tailq, subsys_tmp) {
		if (strcmp(tgt_subsystem->subsystem->subnqn, nqn) == 0) {
			TAILQ_REMOVE(&g_subsystems, tgt_subsystem, tailq);
			nvmf_tgt_delete_subsystem(tgt_subsystem);
			return 0;
		}
+1 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ run_test test/nvmf/fio/fio.sh
run_test test/nvmf/filesystem/filesystem.sh
run_test test/nvmf/discovery/discovery.sh
run_test test/nvmf/nvme_cli/nvme_cli.sh
run_test test/nvmf/shutdown/shutdown.sh

if [ $RUN_NIGHTLY -eq 1 ]; then
	run_test test/nvmf/multiconnection/multiconnection.sh
+43 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../..)
source $rootdir/scripts/autotest_common.sh
source $rootdir/test/nvmf/common.sh

MALLOC_BDEV_SIZE=128
MALLOC_BLOCK_SIZE=512

rpc_py="python $rootdir/scripts/rpc.py"

set -e

if ! rdma_nic_available; then
	echo "no NIC for nvmf test"
	exit 0
fi

timing_enter shutdown

# Start up the NVMf target in another process
$rootdir/app/nvmf_tgt/nvmf_tgt -c $testdir/../nvmf.conf &
pid=$!

trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT

waitforlisten $pid ${RPC_PORT}

# Create 12 subsystems
for i in `seq 1 12`
do
	bdevs="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
	$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode${i} "transport:RDMA traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" '' -s SPDK${i} -n "$bdevs"
done

# Kill nvmf tgt without removing any subsystem to check whether it can shutdown correctly
rm -f ./local-job0-0-verify.state

trap - SIGINT SIGTERM EXIT

killprocess $pid
timing_exit shutdown