test/cuse: cleanup and better describe ns_manage test script
Added more comments for clarity. Moved namespace size calculation to the clean_up() function. Changed size calculation from nvmcap (id-ns) to tnvmcap (id-ctrlr). There is noneed to cache the size before deleting namespace, if we assume that all devices had single namespace encompassing the whole device. Changed blocksize from 512 to 4k. All devices in CI should support that, and usually thats the default. This could be further improved by reading LBAF and checking the Relative Performance (RP), but that would convolute the test scripts. This is good enough. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I8a38d00ae1442edf5480e4e72a8a8aa90380cd79 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2827 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
parent
933ba7f710
commit
2c47df9419
@ -17,12 +17,14 @@ bdfs=$(get_nvme_bdfs)
|
||||
$rootdir/scripts/setup.sh reset
|
||||
sleep 1
|
||||
|
||||
# Find bdf that supports Namespace Managment
|
||||
for bdf in $bdfs; do
|
||||
nvme_name=$(get_nvme_ctrlr_from_bdf ${bdf})
|
||||
if [[ -z "$nvme_name" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check Optional Admin Command Support for Namespace Management
|
||||
oacs=$($NVME_CMD id-ctrl /dev/${nvme_name} | grep oacs | cut -d: -f2)
|
||||
oacs_ns_manage=$((oacs & 0x8))
|
||||
|
||||
@ -32,7 +34,7 @@ for bdf in $bdfs; do
|
||||
done
|
||||
|
||||
if [[ "${nvme_name}" == "" ]] || [[ "$oacs_ns_manage" -eq 0 ]]; then
|
||||
echo "NVMe device not found"
|
||||
echo "No NVMe device supporting Namespace managment found"
|
||||
$rootdir/scripts/setup.sh
|
||||
exit 0
|
||||
fi
|
||||
@ -43,9 +45,6 @@ nvme_dev=/dev/${nvme_name}
|
||||
oaes=$($NVME_CMD id-ctrl ${nvme_dev} | grep oaes | cut -d: -f2)
|
||||
aer_ns_change=$((oaes & 0x100))
|
||||
|
||||
nvmcap=$($NVME_CMD id-ns ${nvme_dev} -n 1 | grep nvmcap | cut -d: -f2)
|
||||
blksize=512
|
||||
|
||||
function reset_nvme_if_aer_unsupported() {
|
||||
if [[ "$aer_ns_change" -eq "0" ]]; then
|
||||
sleep 1
|
||||
@ -56,12 +55,18 @@ function reset_nvme_if_aer_unsupported() {
|
||||
function clean_up() {
|
||||
$rootdir/scripts/setup.sh reset
|
||||
|
||||
size=$((nvmcap / blksize))
|
||||
# This assumes every NVMe controller contains single namespace,
|
||||
# encompassing Total NVM Capacity and formatted as 4k block size.
|
||||
|
||||
tnvmcap=$($NVME_CMD id-ctrl ${nvme_dev} | grep tnvmcap | cut -d: -f2)
|
||||
blksize=4096
|
||||
|
||||
size=$((tnvmcap / blksize))
|
||||
|
||||
echo "Restoring $nvme_dev..."
|
||||
$NVME_CMD detach-ns ${nvme_dev} -n 0xffffffff -c 0 || true
|
||||
$NVME_CMD delete-ns ${nvme_dev} -n 0xffffffff || true
|
||||
$NVME_CMD create-ns ${nvme_dev} -s ${size} -c ${size} -f 0
|
||||
$NVME_CMD create-ns ${nvme_dev} -s ${size} -c ${size} -b ${blksize}
|
||||
$NVME_CMD attach-ns ${nvme_dev} -n 1 -c 0
|
||||
$NVME_CMD reset ${nvme_dev}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user