From acbe9bd882bb723be2423dcf942993750994069a Mon Sep 17 00:00:00 2001 From: GangCao Date: Mon, 24 Jan 2022 16:21:59 -0500 Subject: [PATCH] lib/nvme: only active process to operate the unmap operation Fix issue: #2320 Only the primary process will do the unmap bar operation as for the map bar operation. The DevHandle is process specific and the issue here is the secondary process's function pointer of DevHandle is not properly set. Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11216 (master) (cherry picked from commit 765cf74d07cbb6b87a9582cdef003cc6cededaec) Change-Id: I95dddc76c6ce4be8775b6aaf54699002baffd3b9 Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11274 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki Reviewed-by: GangCao --- lib/nvme/nvme_pcie.c | 2 +- test/nvme/nvme.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 23f4d69b0..5711e7b2d 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -830,7 +830,7 @@ nvme_pcie_ctrlr_free_bars(struct nvme_pcie_ctrlr *pctrlr) return -1; } - if (addr) { + if (addr && spdk_process_is_primary()) { /* NOTE: addr may have been remapped here. We're relying on DPDK to call * munmap internally. */ diff --git a/test/nvme/nvme.sh b/test/nvme/nvme.sh index 13dfe2b06..7ba4a7703 100755 --- a/test/nvme/nvme.sh +++ b/test/nvme/nvme.sh @@ -42,13 +42,23 @@ function nvme_fio_test() { } function nvme_multi_secondary() { - $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 & + # Primary process exits last + $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 5 -c 0x1 & pid0=$! $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 & pid1=$! $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x4 wait $pid0 wait $pid1 + + # Secondary process exits last + $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 & + pid0=$! + $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 & + pid1=$! + $SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 5 -c 0x4 + wait $pid0 + wait $pid1 } if [ $(uname) = Linux ]; then