From patchwork Wed Jan 17 08:17:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guixin Liu X-Patchwork-Id: 13521472 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D211F11184 for ; Wed, 17 Jan 2024 08:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705479483; cv=none; b=JXkOj2hU7eesmfRwPXYCGxtihEpwUL3VT1hxF34IMpnDMg5HALLlEm6uW6raHxFJtFiSqphBxM4nadgnSrQ1hKNSRCStu7HaqJyhWpZGP3BYkINfiXPNkjpzjeUbbRBay4eehNkyTAG1B+ybBnFsCCcFB6rb50gZj+ZNaPF2xxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705479483; c=relaxed/simple; bh=Lu53RUrb3gNjEf5ASVw+dUt0DMjb0/m6Uj/HXxoa5mA=; h=X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=T7hwsZsqo+wMIyqwHh7fMCstOsA6kHzeABMTSDsQpCyWfPWiYTQIecrRjb9d/gibiZDhJiOQn7alqXxX2qRo/YvuwW8NROw8vY2CVLeJ9HfDNWx0gNA/ZU1yFvXRVHjaDkueUvyQ4toA5eqvb97QmsmPvrKSCfKA5QLByQlMmNM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R661e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=kanie@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0W-ogcVh_1705479467; Received: from localhost(mailfrom:kanie@linux.alibaba.com fp:SMTPD_---0W-ogcVh_1705479467) by smtp.aliyun-inc.com; Wed, 17 Jan 2024 16:17:52 +0800 From: Guixin Liu To: shinichiro.kawasaki@wdc.com Cc: chaitanyak@nvidia.com, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH V2 1/2] nvme/{rc,002,016,017,030,031}: introduce --resv_enable argument Date: Wed, 17 Jan 2024 16:17:41 +0800 Message-ID: <20240117081742.93941-2-kanie@linux.alibaba.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117081742.93941-1-kanie@linux.alibaba.com> References: <20240117081742.93941-1-kanie@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add an optional argument --resv_enable to _nvmet_target_setup() and propagate it to _create_nvmet_subsystem() and _create_nvmet_ns(). One can call functions with --resv_enable to enable reservation feature on a specific namespace. Signed-off-by: Guixin Liu Reviewed-by: Daniel Wagner --- tests/nvme/002 | 3 +- tests/nvme/016 | 7 +++- tests/nvme/017 | 10 +++-- tests/nvme/030 | 6 ++- tests/nvme/031 | 3 +- tests/nvme/rc | 100 +++++++++++++++++++++++++++++++++++++++++-------- 6 files changed, 104 insertions(+), 25 deletions(-) diff --git a/tests/nvme/002 b/tests/nvme/002 index 6b84848..37c719b 100755 --- a/tests/nvme/002 +++ b/tests/nvme/002 @@ -30,7 +30,8 @@ test() { local genctr=1 for ((i = 0; i < iterations; i++)); do - _create_nvmet_subsystem "blktests-subsystem-$i" "${loop_dev}" + _create_nvmet_subsystem --subsysnqn "blktests-subsystem-$i" \ + --blkdev "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i" done diff --git a/tests/nvme/016 b/tests/nvme/016 index 908abbd..ba700d1 100755 --- a/tests/nvme/016 +++ b/tests/nvme/016 @@ -25,10 +25,13 @@ test() { loop_dev="$(losetup -f)" local genctr=1 - _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}" + _create_nvmet_subsystem --subsysnqn "${def_subsysnqn}" \ + --blkdev "${loop_dev}" for ((i = 2; i <= iterations; i++)); do - _create_nvmet_ns "${def_subsysnqn}" "${i}" "${loop_dev}" + _create_nvmet_ns --subsysnqn "${def_subsysnqn}" \ + --nsid "${i}" \ + --blkdev "${loop_dev}" done port="$(_create_nvmet_port "${nvme_trtype}")" diff --git a/tests/nvme/017 b/tests/nvme/017 index c8d9b32..d9fbd38 100755 --- a/tests/nvme/017 +++ b/tests/nvme/017 @@ -25,12 +25,14 @@ test() { local genctr=1 - _create_nvmet_subsystem "${def_subsysnqn}" "$(_nvme_def_file_path)" \ - "${def_subsys_uuid}" + _create_nvmet_subsystem --subsysnqn "${def_subsysnqn}" \ + --blkdev "$(_nvme_def_file_path)" \ + --uuid "${def_subsys_uuid}" for ((i = 2; i <= iterations; i++)); do - _create_nvmet_ns "${def_subsysnqn}" "${i}" \ - "$(_nvme_def_file_path)" + _create_nvmet_ns --subsysnqn "${def_subsysnqn}" \ + --nsid "${i}" \ + --blkdev "$(_nvme_def_file_path)" done port="$(_create_nvmet_port "${nvme_trtype}")" diff --git a/tests/nvme/030 b/tests/nvme/030 index 9251e17..8802b16 100755 --- a/tests/nvme/030 +++ b/tests/nvme/030 @@ -26,13 +26,15 @@ test() { port="$(_create_nvmet_port "${nvme_trtype}")" - _create_nvmet_subsystem "${subsys}1" "$(losetup -f)" + _create_nvmet_subsystem --subsysnqn "${subsys}1" \ + --blkdev "$(losetup -f)" _add_nvmet_subsys_to_port "${port}" "${subsys}1" _create_nvmet_host "${subsys}1" "${def_hostnqn}" genctr=$(_discovery_genctr) - _create_nvmet_subsystem "${subsys}2" "$(losetup -f)" + _create_nvmet_subsystem --subsysnqn "${subsys}2" \ + --blkdev "$(losetup -f)" _add_nvmet_subsys_to_port "${port}" "${subsys}2" genctr=$(_check_genctr "${genctr}" "adding a subsystem to a port") diff --git a/tests/nvme/031 b/tests/nvme/031 index ed5f196..191ce72 100755 --- a/tests/nvme/031 +++ b/tests/nvme/031 @@ -40,7 +40,8 @@ test() { port="$(_create_nvmet_port "${nvme_trtype}")" for ((i = 0; i < iterations; i++)); do - _create_nvmet_subsystem "${subsys}$i" "${loop_dev}" + _create_nvmet_subsystem --subsysnqn "${subsys}$i" \ + --blkdev "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "${subsys}$i" _create_nvmet_host "${subsys}$i" "${def_hostnqn}" _nvme_connect_subsys "${nvme_trtype}" "${subsys}$i" diff --git a/tests/nvme/rc b/tests/nvme/rc index b0ef1ee..c6466cc 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -656,32 +656,95 @@ _remove_nvmet_port() { } _create_nvmet_ns() { - local nvmet_subsystem="$1" - local nsid="$2" - local blkdev="$3" + local nvmet_subsystem="" + local nsid="" + local blkdev="" local uuid="00000000-0000-0000-0000-000000000000" - local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" - local ns_path="${subsys_path}/namespaces/${nsid}" + local subsys_path="" + local ns_path="" + local resv_enable=false - if [[ $# -eq 4 ]]; then - uuid="$4" - fi + while [[ $# -gt 0 ]]; do + case $1 in + --subsysnqn) + nvmet_subsystem="$2" + shift 2 + ;; + --nsid) + nsid="$2" + shift 2 + ;; + --blkdev) + blkdev="$2" + shift 2 + ;; + --uuid) + uuid="$2" + shift 2 + ;; + --resv_enable) + resv_enable=true + shift 1 + ;; + *) + echo "WARNING: unknown argument: $1" + shift + ;; + esac + done + + subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + ns_path="${subsys_path}/namespaces/${nsid}" mkdir "${ns_path}" printf "%s" "${blkdev}" > "${ns_path}/device_path" printf "%s" "${uuid}" > "${ns_path}/device_uuid" + if [[ -f "${ns_path}/resv_enable" && "${resv_enable}" = true ]] ; then + printf 1 > "${ns_path}/resv_enable" + fi printf 1 > "${ns_path}/enable" } _create_nvmet_subsystem() { - local nvmet_subsystem="$1" - local blkdev="$2" - local uuid=$3 - local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + local nvmet_subsystem="" + local blkdev="" + local uuid="00000000-0000-0000-0000-000000000000" + local resv_enable="" + local cfs_path="" + while [[ $# -gt 0 ]]; do + case $1 in + --subsysnqn) + nvmet_subsystem="$2" + shift 2 + ;; + --blkdev) + blkdev="$2" + shift 2 + ;; + --uuid) + uuid="$2" + shift 2 + ;; + --resv_enable) + resv_enable="--resv_enable"; + shift 1 + ;; + *) + echo "WARNING: unknown argument: $1" + shift + ;; + esac + done + + cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" mkdir -p "${cfs_path}" echo 0 > "${cfs_path}/attr_allow_any_host" - _create_nvmet_ns "${nvmet_subsystem}" "1" "${blkdev}" "${uuid}" + _create_nvmet_ns --subsysnqn "${nvmet_subsystem}" \ + --nsid "1" \ + --blkdev "${blkdev}" \ + --uuid "${uuid}" \ + ${resv_enable} } _add_nvmet_allow_hosts() { @@ -863,6 +926,7 @@ _nvmet_target_setup() { local ctrlkey="" local hostkey="" local port + local resv_enable="" while [[ $# -gt 0 ]]; do case $1 in @@ -878,6 +942,10 @@ _nvmet_target_setup() { hostkey="$2" shift 2 ;; + --resv_enable) + resv_enable="--resv_enable" + shift 1 + ;; *) echo "WARNING: unknown argument: $1" shift @@ -892,8 +960,10 @@ _nvmet_target_setup() { blkdev="$(_nvme_def_file_path)" fi - _create_nvmet_subsystem "${def_subsysnqn}" "${blkdev}" \ - "${def_subsys_uuid}" + _create_nvmet_subsystem --subsysnqn "${def_subsysnqn}" \ + --blkdev "${blkdev}" \ + --uuid "${def_subsys_uuid}" \ + ${resv_enable} port="$(_create_nvmet_port "${nvme_trtype}")" _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}" _create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \ From patchwork Wed Jan 17 08:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guixin Liu X-Patchwork-Id: 13521471 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B4AD1118C for ; Wed, 17 Jan 2024 08:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705479482; cv=none; b=XlPGw7Txnb9ziK3igCybp3DLw/IgVO6EIBvgJHJQzKRrLEyC+FGOXJrl0l/j2Mxg6F2Hckhu69z5rULl6QScsBP9ruUu15o9n9jmz/6nArHA+6jQjrZUMxs5SV+Iaztpr7UfF3cPFgXfHWfVrMHkkqJcNyrKfj/4IWO9k/7YELM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705479482; c=relaxed/simple; bh=4kZDgRK7rjPVV58we6K7xR4kh0Q8kCdLtQBl0WtiGOQ=; h=X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=Z5fqLkPUTwh04WD6U3VlcW38Q4zBgVK/9doTz1bZvxivUbG+VoCtHguFaNYShaHuSwrJLT5C92xiVrpicD2Gq8IFCvjUwXvm0uvlLFgU1AODB8bysj0oJlLzm0khmj0x2t7vztKu5qdnuyrhm9EkMyUjbPB/vNiB5FFVHl3gFNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=kanie@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0W-ogcXo_1705479472; Received: from localhost(mailfrom:kanie@linux.alibaba.com fp:SMTPD_---0W-ogcXo_1705479472) by smtp.aliyun-inc.com; Wed, 17 Jan 2024 16:17:56 +0800 From: Guixin Liu To: shinichiro.kawasaki@wdc.com Cc: chaitanyak@nvidia.com, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH V2 2/2] test/nvme/050: test the reservation feature Date: Wed, 17 Jan 2024 16:17:42 +0800 Message-ID: <20240117081742.93941-3-kanie@linux.alibaba.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117081742.93941-1-kanie@linux.alibaba.com> References: <20240117081742.93941-1-kanie@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Test the reservation feature, includes register, acquire, release and report. Signed-off-by: Guixin Liu --- tests/nvme/050 | 96 ++++++++++++++++++++++++++++++++++++++++ tests/nvme/050.out | 108 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 tests/nvme/050 create mode 100644 tests/nvme/050.out diff --git a/tests/nvme/050 b/tests/nvme/050 new file mode 100644 index 0000000..7e59de4 --- /dev/null +++ b/tests/nvme/050 @@ -0,0 +1,96 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Guixin Liu +# Copyright (C) 2024 Alibaba Group. +# +# Test the NVMe reservation feature +# +. tests/nvme/rc + +DESCRIPTION="test the reservation feature" +QUICK=1 + +requires() { + _nvme_requires +} + +resv_report() { + local nvmedev=$1 + + if nvme resv-report --help 2>&1 | grep -- '--eds' > /dev/null; then + nvme resv-report "/dev/${nvmedev}n1" --eds | grep -v "hostid" + else + nvme resv-report "/dev/${nvmedev}n1" --cdw11=1 | grep -v "hostid" + fi +} + +test_resv() { + local nvmedev=$1 + + echo "Register" + resv_report "${nvmedev}" + nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0 + resv_report "${nvmedev}" + + echo "Replace" + nvme resv-register "/dev/${nvmedev}n1" --crkey=4 --nrkey=5 --rrega=2 + resv_report "${nvmedev}" + + echo "Unregister" + nvme resv-register "/dev/${nvmedev}n1" --crkey=5 --rrega=1 + resv_report "${nvmedev}" + + echo "Acquire" + nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0 + nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0 + resv_report "${nvmedev}" + + echo "Preempt" + nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --racqa=1 + resv_report "${nvmedev}" + + echo "Release" + nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rtype=2 --rrela=0 + resv_report "${nvmedev}" + + echo "Clear" + nvme resv-register "/dev/${nvmedev}n1" --nrkey=4 --rrega=0 + nvme resv-acquire "/dev/${nvmedev}n1" --crkey=4 --rtype=1 --racqa=0 + resv_report "${nvmedev}" + nvme resv-release "/dev/${nvmedev}n1" --crkey=4 --rrela=1 +} + +test() { + echo "Running ${TEST_NAME}" + + _setup_nvmet + + local nvmedev + local skipped=false + local subsys_path="" + local ns_path="" + + _nvmet_target_setup --blkdev file --resv_enable + subsys_path="${NVMET_CFS}/subsystems/${def_subsysnqn}" + ns_path="${subsys_path}/namespaces/1" + + if [[ -f "${ns_path}/resv_enable" ]] ; then + _nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" + + nvmedev=$(_find_nvme_dev "${def_subsysnqn}") + + test_resv "${nvmedev}" + _nvme_disconnect_subsys "${def_subsysnqn}" + else + SKIP_REASONS+=("missing reservation feature") + skipped=true + fi + + _nvmet_target_cleanup + + if [[ "${skipped}" = true ]] ; then + return 1 + fi + + echo "Test complete" +} diff --git a/tests/nvme/050.out b/tests/nvme/050.out new file mode 100644 index 0000000..2a46b32 --- /dev/null +++ b/tests/nvme/050.out @@ -0,0 +1,108 @@ +Running nvme/050 +Register + +NVME Reservation status: + +gen : 0 +rtype : 0 +regctl : 0 +ptpls : 0 + +NVME Reservation success + +NVME Reservation status: + +gen : 1 +rtype : 0 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 0 + rkey : 4 + +Replace +NVME Reservation success + +NVME Reservation status: + +gen : 2 +rtype : 0 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 0 + rkey : 5 + +Unregister +NVME Reservation success + +NVME Reservation status: + +gen : 3 +rtype : 0 +regctl : 0 +ptpls : 0 + +Acquire +NVME Reservation success +NVME Reservation Acquire success + +NVME Reservation status: + +gen : 4 +rtype : 1 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 1 + rkey : 4 + +Preempt +NVME Reservation Acquire success + +NVME Reservation status: + +gen : 5 +rtype : 2 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 1 + rkey : 4 + +Release +NVME Reservation Release success + +NVME Reservation status: + +gen : 5 +rtype : 0 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 0 + rkey : 4 + +Clear +NVME Reservation success +NVME Reservation Acquire success + +NVME Reservation status: + +gen : 6 +rtype : 1 +regctl : 1 +ptpls : 0 +regctlext[0] : + cntlid : 1 + rcsts : 1 + rkey : 4 + +NVME Reservation Release success +disconnected 1 controller(s) +Test complete